From 066d908b4f4a7d8d2e6551ade4e55a86676f3437 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Wed, 27 Dec 2023 15:25:30 +0000 Subject: [PATCH] Fix feeds config UI not allowing notifyOnFailure to be toggled. (#865) * Fix feeds config UI not allowing notifyOnFailure to be toggled. * changelog * amend changelog to be cohierent * Actual fixes. --- changelog.d/865.bugfix | 1 + src/Connections/FeedConnection.ts | 5 ++++- web/components/roomConfig/FeedsConfig.tsx | 10 ++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 changelog.d/865.bugfix diff --git a/changelog.d/865.bugfix b/changelog.d/865.bugfix new file mode 100644 index 00000000..d7968362 --- /dev/null +++ b/changelog.d/865.bugfix @@ -0,0 +1 @@ +Fix notify on failure not being toggleable in the feeds widget interface. diff --git a/src/Connections/FeedConnection.ts b/src/Connections/FeedConnection.ts index 26802693..fe2d520c 100644 --- a/src/Connections/FeedConnection.ts +++ b/src/Connections/FeedConnection.ts @@ -97,8 +97,11 @@ export class FeedConnection extends BaseConnection implements IConnection { } } + if (typeof data.notifyOnFailure !== 'undefined' && typeof data.notifyOnFailure !== 'boolean') { + throw new ApiError('notifyOnFailure must be a boolean', ErrCode.BadValue); + } - return { url, label: data.label, template: data.template }; + return { url, label: data.label, template: data.template, notifyOnFailure: data.notifyOnFailure }; } static async provisionConnection(roomId: string, _userId: string, data: Record = {}, { intent, config }: ProvisionConnectionOpts) { diff --git a/web/components/roomConfig/FeedsConfig.tsx b/web/components/roomConfig/FeedsConfig.tsx index e4663dab..ec9697bc 100644 --- a/web/components/roomConfig/FeedsConfig.tsx +++ b/web/components/roomConfig/FeedsConfig.tsx @@ -32,9 +32,10 @@ const ConnectionConfiguration: FunctionComponent(); const labelRef = createRef(); const templateRef = createRef(); - const notifyRef = createRef(); const canSave = !existingConnection?.id || (existingConnection?.canEdit ?? false); const canEdit = canSave && !isMigrationCandidate; + const [notifyOnFailure, setNotifyOnFailure] = useState(existingConnection?.config.notifyOnFailure ?? false); + const handleSave = useCallback((evt: Event) => { evt.preventDefault(); if (!canSave) { @@ -46,12 +47,13 @@ const ConnectionConfiguration: FunctionComponent { existingConnection && } @@ -63,7 +65,7 @@ const ConnectionConfiguration: FunctionComponent - + setNotifyOnFailure(v => !v), [])} />