Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for duplicate notification channels #981

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/pages/CreateTrigger/components/Action/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const Action = ({
</EuiText>
</React.Fragment>
),
rowHeight: 45,
rowHeight: 30,
isLoading: !flyoutMode && loadingDestinations,
}}
/>
Expand Down
32 changes: 24 additions & 8 deletions public/pages/CreateTrigger/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,30 @@ import moment from 'moment-timezone';
import { formikToTrigger } from '../containers/CreateTrigger/utils/formikToTrigger';
import { getUISettings } from '../../../services';

export const getChannelOptions = (channels) =>
channels.map((channel) => ({
key: channel.type,
label: channel.type,
options: channels
.filter((local_channel) => local_channel.type === channel.type)
.map((option) => ({ key: option.value, ...option })),
}));
export const getChannelOptions = (channels) => {
const channelMap = {};

// Iterate over channels to group options by channel type
channels.forEach(channel => {
if (!channelMap[channel.type]) {
channelMap[channel.type] = {
key: channel.type,
label: channel.type,
options: []
};
}
// Add the option to the corresponding channel type
channelMap[channel.type].options.push({
key: channel.value,
...channel
});
});

// Convert the channelMap object to an array of values
const channelOptions = Object.values(channelMap);

return channelOptions;
};

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