| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- 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) {
- const response = await this.appContainer.apiv3.post('/notification-setting/user-notification', {
- pathPattern,
- channel,
- });
- return response;
- }
- }
|