diff --git a/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js b/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js index 71952d654..9dde0f0bf 100644 --- a/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js +++ b/public/pages/CreateTrigger/containers/ConfigureActions/ConfigureActions.js @@ -121,11 +121,12 @@ class ConfigureActions extends React.Component { let channels = []; let index = 0; const getChannels = async () => { - const config_types = await this.props.notificationService.getServerFeatures(); + const serverFeatures = await this.props.notificationService.getServerFeatures(); + const configTypes = Object.keys(serverFeatures.availableChannels); const getChannelsQuery = { from_index: index, max_items: MAX_CHANNELS_RESULT_SIZE, - config_type: config_types, + config_type: configTypes, sort_field: 'name', sort_order: 'asc', }; diff --git a/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotifications.js b/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotifications.js index 901a5717e..39ef4e654 100644 --- a/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotifications.js +++ b/public/pages/CreateTrigger/containers/DefineCompositeLevelTrigger/TriggerNotifications.js @@ -51,11 +51,12 @@ const TriggerNotifications = ({ let channels = []; let index = 0; const getChannels = async () => { - const config_types = await notificationService.getServerFeatures(); + const serverFeatures = await notificationService.getServerFeatures(); + const configTypes = Object.keys(serverFeatures.availableChannels); const getChannelsQuery = { from_index: index, max_items: MAX_CHANNELS_RESULT_SIZE, - config_type: config_types, + config_type: configTypes, sort_field: 'name', sort_order: 'asc', }; diff --git a/public/services/NotificationService.ts b/public/services/NotificationService.ts index 0a1cbe5b9..d48fc29c5 100644 --- a/public/services/NotificationService.ts +++ b/public/services/NotificationService.ts @@ -4,7 +4,7 @@ */ import { HttpFetchQuery, HttpSetup } from '../../../../src/core/public'; -import { ChannelItemType } from './models/interfaces'; +import { ChannelItemType, NotificationServerFeatures } from './models/interfaces'; import { configListToChannels, configToChannel } from './utils/helper'; interface ConfigsResponse { @@ -26,15 +26,19 @@ export default class NotificationService { this.httpClient = httpClient; } - getServerFeatures = async (): Promise> => { + getServerFeatures = async (): Promise => { try { const response = await this.httpClient.get( NODE_API.GET_AVAILABLE_FEATURES ); - return response.allowed_config_type_list as Array; + return response as NotificationServerFeatures; } catch (error) { console.error('error fetching available features', error); - return []; + return { + availableChannels: {}, + availableConfigTypes: [], + tooltipSupport: false + }; } }; diff --git a/public/services/models/interfaces.ts b/public/services/models/interfaces.ts index eab786e97..cfba7d3e1 100644 --- a/public/services/models/interfaces.ts +++ b/public/services/models/interfaces.ts @@ -37,3 +37,9 @@ export interface ChannelItemType extends ConfigType { }; }; } + +export interface NotificationServerFeatures { + availableChannels: Partial; + availableConfigTypes: string[]; // available backend config types + tooltipSupport: boolean; // if true, IAM role for SNS is optional and helper text should be available +}