fix: dedupe bulletin board messages and combine details as needed
@@ -62,7 +62,38 @@ export const IntegrationDetailHeader: React.FunctionComponent<
return (
<Translation ns={['integrations', 'shared']}>
- {t => (
+ {t => {
+ const bbMap = (
+ (props.data.integration.board &&
+ props.data.integration.board.messages) ||
+ []
+ ).reduce((acc, current, index, arr) => {
+ try {
+ if (!current) {
+ return acc;
+ }
+ const key = current.code || current.message;
+ if (!key || key === '') {
+ return acc;
+ }
+ if (!(key in acc)) {
+ acc[key] = current;
+ return acc;
+ }
+ acc[key].detail += (
+ acc[key].detail +
+ '\n\n' +
+ current.detail
+ ).substring(0, 256);
+ } catch (err) {
+ // skip that one and keep going
+ }
+ return acc;
+ }, {});
+ const bulletinBoards = Object.keys(bbMap).map(
+ (key: string) => bbMap[key]
+ );
+ return (
<>
<IntegrationDetailBreadcrumb
editHref={props.editAction.href}
@@ -132,15 +163,15 @@ export const IntegrationDetailHeader: React.FunctionComponent<
/>
</PageSection>
<PageSection variant={'light'}>
- {(
- (props.data.integration.board &&
- props.data.integration.board.messages) ||
- []
- ).map((message: LeveledMessage, index) => (
+ {bulletinBoards.map((message: LeveledMessage, index) => (
<IntegrationBulletinBoardAlert
key={index}
level={toAlertLevel(message.level || 'INFO')}
- message={t(`shared:${message.code!.toLocaleLowerCase()}`)}
+ message={
+ message.message
+ ? message.message
+ : t(`shared:${message.code!.toLocaleLowerCase()}`)
+ }
detail={message.detail}
i18nTextExpanded={t('shared:HideDetails')}
i18nTextCollapsed={t('shared:ShowDetails')}
@@ -151,7 +182,8 @@ export const IntegrationDetailHeader: React.FunctionComponent<
<IntegrationDetailNavBar integration={props.data.integration} />
</PageSection>
</>
- )}
+ );
+ }}
</Translation>
);
};
