Skip to content

Commit 738295f

Browse files
bug fix for duplicate notification channels (#981)
* bug fix for duplicate notification channels Signed-off-by: Riya Saxena <riysaxen@amazon.com> * bug fix for UI dropdown Signed-off-by: Riya Saxena <riysaxen@amazon.com> --------- Signed-off-by: Riya Saxena <riysaxen@amazon.com>
1 parent 722047d commit 738295f

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

public/pages/CreateTrigger/components/Action/Action.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ const Action = ({
156156
</EuiText>
157157
</React.Fragment>
158158
),
159-
rowHeight: 45,
159+
rowHeight: 30,
160160
isLoading: !flyoutMode && loadingDestinations,
161161
}}
162162
/>

public/pages/CreateTrigger/utils/helper.js

+24-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,30 @@ import moment from 'moment-timezone';
1919
import { formikToTrigger } from '../containers/CreateTrigger/utils/formikToTrigger';
2020
import { getUISettings } from '../../../services';
2121

22-
export const getChannelOptions = (channels) =>
23-
channels.map((channel) => ({
24-
key: channel.type,
25-
label: channel.type,
26-
options: channels
27-
.filter((local_channel) => local_channel.type === channel.type)
28-
.map((option) => ({ key: option.value, ...option })),
29-
}));
22+
export const getChannelOptions = (channels) => {
23+
const channelMap = {};
24+
25+
// Iterate over channels to group options by channel type
26+
channels.forEach(channel => {
27+
if (!channelMap[channel.type]) {
28+
channelMap[channel.type] = {
29+
key: channel.type,
30+
label: channel.type,
31+
options: []
32+
};
33+
}
34+
// Add the option to the corresponding channel type
35+
channelMap[channel.type].options.push({
36+
key: channel.value,
37+
...channel
38+
});
39+
});
40+
41+
// Convert the channelMap object to an array of values
42+
const channelOptions = Object.values(channelMap);
43+
44+
return channelOptions;
45+
};
3046

3147
// Custom Webhooks for Destinations used `custom_webhook` for the type whereas Notification Channels use 'webhook'
3248
// This conversion ensures Notifications' nomenclature is used for the labeling for consistency

0 commit comments

Comments
 (0)