mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00
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.
This commit is contained in:
parent
1db6f60776
commit
066d908b4f
1
changelog.d/865.bugfix
Normal file
1
changelog.d/865.bugfix
Normal file
@ -0,0 +1 @@
|
|||||||
|
Fix notify on failure not being toggleable in the feeds widget interface.
|
@ -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<string, unknown> = {}, { intent, config }: ProvisionConnectionOpts) {
|
static async provisionConnection(roomId: string, _userId: string, data: Record<string, unknown> = {}, { intent, config }: ProvisionConnectionOpts) {
|
||||||
|
@ -32,9 +32,10 @@ const ConnectionConfiguration: FunctionComponent<ConnectionConfigurationProps<Se
|
|||||||
const urlRef = createRef<HTMLInputElement>();
|
const urlRef = createRef<HTMLInputElement>();
|
||||||
const labelRef = createRef<HTMLInputElement>();
|
const labelRef = createRef<HTMLInputElement>();
|
||||||
const templateRef = createRef<HTMLInputElement>();
|
const templateRef = createRef<HTMLInputElement>();
|
||||||
const notifyRef = createRef<HTMLInputElement>();
|
|
||||||
const canSave = !existingConnection?.id || (existingConnection?.canEdit ?? false);
|
const canSave = !existingConnection?.id || (existingConnection?.canEdit ?? false);
|
||||||
const canEdit = canSave && !isMigrationCandidate;
|
const canEdit = canSave && !isMigrationCandidate;
|
||||||
|
const [notifyOnFailure, setNotifyOnFailure] = useState<boolean>(existingConnection?.config.notifyOnFailure ?? false);
|
||||||
|
|
||||||
const handleSave = useCallback((evt: Event) => {
|
const handleSave = useCallback((evt: Event) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
if (!canSave) {
|
if (!canSave) {
|
||||||
@ -46,12 +47,13 @@ const ConnectionConfiguration: FunctionComponent<ConnectionConfigurationProps<Se
|
|||||||
url,
|
url,
|
||||||
label: labelRef?.current?.value || existingConnection?.config.label,
|
label: labelRef?.current?.value || existingConnection?.config.label,
|
||||||
template: templateRef.current?.value || existingConnection?.config.template,
|
template: templateRef.current?.value || existingConnection?.config.template,
|
||||||
notifyOnFailure: notifyRef.current?.checked || existingConnection?.config.notifyOnFailure,
|
notifyOnFailure,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [canSave, onSave, urlRef, labelRef, templateRef, notifyRef, existingConnection]);
|
}, [canSave, onSave, urlRef, labelRef, templateRef, notifyOnFailure, existingConnection]);
|
||||||
|
|
||||||
const onlyVisibleOnExistingConnection = !!existingConnection;
|
const onlyVisibleOnExistingConnection = !!existingConnection;
|
||||||
|
|
||||||
|
|
||||||
return <form onSubmit={handleSave}>
|
return <form onSubmit={handleSave}>
|
||||||
{ existingConnection && <FeedRecentResults item={existingConnection} />}
|
{ existingConnection && <FeedRecentResults item={existingConnection} />}
|
||||||
@ -63,7 +65,7 @@ const ConnectionConfiguration: FunctionComponent<ConnectionConfigurationProps<Se
|
|||||||
<input ref={labelRef} disabled={!canSave} type="text" value={existingConnection?.config.label} />
|
<input ref={labelRef} disabled={!canSave} type="text" value={existingConnection?.config.label} />
|
||||||
</InputField>
|
</InputField>
|
||||||
<InputField visible={onlyVisibleOnExistingConnection} label="Send a notice on read failure" noPadding={true}>
|
<InputField visible={onlyVisibleOnExistingConnection} label="Send a notice on read failure" noPadding={true}>
|
||||||
<input ref={notifyRef} disabled={!canSave} type="checkbox" checked={existingConnection?.config.notifyOnFailure} />
|
<input disabled={!canSave} type="checkbox" checked={notifyOnFailure} onChange={useCallback(() => setNotifyOnFailure(v => !v), [])} />
|
||||||
</InputField>
|
</InputField>
|
||||||
<InputField visible={onlyVisibleOnExistingConnection} label="Template" noPadding={true}>
|
<InputField visible={onlyVisibleOnExistingConnection} label="Template" noPadding={true}>
|
||||||
<input ref={templateRef} disabled={!canSave} type="text" value={existingConnection?.config.template} placeholder={DEFAULT_TEMPLATE} />
|
<input ref={templateRef} disabled={!canSave} type="text" value={existingConnection?.config.template} placeholder={DEFAULT_TEMPLATE} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user