| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- import { Container } from 'unstated';
- /**
- * Service container for admin Notification setting page (NotificationSetting.jsx)
- * @extends {Container} unstated Container
- */
- export default class AdminNotificationContainer extends Container {
- constructor(appContainer) {
- super();
- this.appContainer = appContainer;
- this.state = {
- retrieveError: null,
- selectSlackOption: 'Incoming Webhooks',
- webhookUrl: '',
- isIncomingWebhookPrioritized: false,
- slackToken: '',
- userNotifications: [],
- grobalNotifications: [],
- };
- }
- /**
- * Workaround for the mangling in production build to break constructor.name
- */
- static getClassName() {
- return 'AdminNotificationContainer';
- }
- /**
- * Retrieve notificationData
- */
- retrieveNotificationData() {
- // TODO GW-821 retrive data from api
- }
- /**
- * Switch slackOption
- */
- switchSlackOption(slackOption) {
- this.setState({ selectSlackOption: slackOption });
- }
- /**
- * Change webhookUrl
- */
- changeWebhookUrl(webhookUrl) {
- this.setState({ webhookUrl });
- }
- /**
- * Switch incomingWebhookPrioritized
- */
- switchIsIncomingWebhookPrioritized() {
- this.setState({ isIncomingWebhookPrioritized: !this.state.isIncomingWebhookPrioritized });
- }
- /**
- * Change slackToken
- */
- changeSlackToken(slackToken) {
- this.setState({ slackToken });
- }
- /**
- * Update slackAppConfiguration
- * @memberOf SlackAppConfiguration
- */
- async updateSlackAppConfiguration() {
- const response = await this.appContainer.apiv3.put('/notification-setting/slack-configuration', {
- webhookUrl: this.state.webhookUrl,
- isIncomingWebhookPrioritized: this.state.isIncomingWebhookPrioritized,
- slackToken: this.state.slackToken,
- });
- return response;
- }
- /**
- * Add notificationPattern
- * @memberOf SlackAppConfiguration
- */
- async addNotificationPattern(pathPattern, channel) {
- return this.appContainer.apiv3.post('/notification-setting/user-notification', {
- pathPattern,
- channel,
- });
- }
- }
|