Merge pull request #102 from sartography/feature/waku-fault-message

Feature/waku fault message
This commit is contained in:
Kevin Burnett 2023-01-13 11:47:05 -08:00 committed by GitHub
commit 94f31579a7
2 changed files with 118 additions and 0 deletions

View File

@ -8,6 +8,8 @@ import {
TextInput,
Grid,
Column,
Select,
SelectItem,
// @ts-ignore
} from '@carbon/react';
// @ts-ignore
@ -76,6 +78,9 @@ export default function ProcessModelForm({
display_name: processModel.display_name,
description: processModel.description,
metadata_extraction_paths: processModel.metadata_extraction_paths,
fault_or_suspend_on_exception: processModel.fault_or_suspend_on_exception,
exception_notification_addresses:
processModel.exception_notification_addresses,
};
if (mode === 'new') {
Object.assign(postBody, {
@ -173,6 +178,69 @@ export default function ProcessModelForm({
updateProcessModel({ metadata_extraction_paths: cep });
};
const notificationAddressForm = (
index: number,
notificationAddress: string
) => {
return (
<Grid>
<Column md={3} lg={7} sm={1}>
<TextInput
id={`process-model-notification-address-key-${index}`}
labelText="Address"
value={notificationAddress}
onChange={(event: any) => {
const notificationAddresses: string[] =
processModel.exception_notification_addresses || [];
notificationAddresses[index] = event.target.value;
updateProcessModel({
exception_notification_addresses: notificationAddresses,
});
}}
/>
</Column>
<Column md={1} lg={1} sm={1}>
<Button
kind="ghost"
renderIcon={TrashCan}
iconDescription="Remove Address"
hasIconOnly
size="lg"
className="with-extra-top-margin"
onClick={() => {
const notificationAddresses: string[] =
processModel.exception_notification_addresses || [];
notificationAddresses.splice(index, 1);
updateProcessModel({
exception_notification_addresses: notificationAddresses,
});
}}
/>
</Column>
</Grid>
);
};
const notificationAddressFormArea = () => {
if (processModel.exception_notification_addresses) {
return processModel.exception_notification_addresses.map(
(notificationAddress: string, index: number) => {
return notificationAddressForm(index, notificationAddress);
}
);
}
return null;
};
const addBlankNotificationAddress = () => {
const notificationAddresses: string[] =
processModel.exception_notification_addresses || [];
notificationAddresses.push('');
updateProcessModel({
exception_notification_addresses: notificationAddresses,
});
};
const onDisplayNameChanged = (newDisplayName: any) => {
setDisplayNameInvalid(false);
const updateDict = { display_name: newDisplayName };
@ -182,6 +250,11 @@ export default function ProcessModelForm({
updateProcessModel(updateDict);
};
const onNotificationTypeChanged = (newNotificationType: string) => {
const updateDict = { fault_or_suspend_on_exception: newNotificationType };
updateProcessModel(updateDict);
};
const formElements = () => {
const textInputs = [
<TextInput
@ -230,6 +303,49 @@ export default function ProcessModelForm({
/>
);
textInputs.push(
<Select
id="notification-type"
defaultValue="fault"
labelText="Notification Type"
onChange={(event: any) => {
onNotificationTypeChanged(event.target.value);
}}
>
<SelectItem value="fault" text="Fault" />
<SelectItem value="suspend" text="Suspend" />
</Select>
);
textInputs.push(<h2>Notification Addresses</h2>);
textInputs.push(
<Grid>
<Column md={8} lg={16} sm={4}>
<p className="data-table-description">
You can provide one or more addresses to notify if this model fails.
</p>
</Column>
</Grid>
);
textInputs.push(<>{notificationAddressFormArea()}</>);
textInputs.push(
<Grid>
<Column md={4} lg={8} sm={2}>
<Button
data-qa="add-notification-address-button"
renderIcon={AddAlt}
className="button-white-background"
kind=""
size="sm"
onClick={() => {
addBlankNotificationAddress();
}}
>
Add Notification Address
</Button>
</Column>
</Grid>
);
textInputs.push(<h2>Metadata Extractions</h2>);
textInputs.push(
<Grid>

View File

@ -151,6 +151,8 @@ export interface ProcessModel {
files: ProcessFile[];
parent_groups?: ProcessGroupLite[];
metadata_extraction_paths?: MetadataExtractionPath[];
fault_or_suspend_on_exception?: string;
exception_notification_addresses?: string[];
}
export interface ProcessGroup {