Skip to content

Commit ad7ba55

Browse files
committed
fix(ui/incident): Add validation for custom type
1 parent 41895fe commit ad7ba55

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

datahub-web-react/src/app/entityV2/shared/tabs/Incident/AcrylComponents/IncidentEditor.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export const IncidentEditor = ({
3838
mode = IncidentAction.ADD,
3939
}: IncidentEditorProps) => {
4040
const assigneeValues = data?.assignees && getAssigneeWithURN(data.assignees);
41-
const isFormValid = Boolean(data?.title?.length && data?.description && data?.type && data?.customType);
41+
const isFormValid = Boolean(
42+
data?.title?.length &&
43+
data?.description &&
44+
data?.type &&
45+
(data?.type !== IncidentType.Custom || data?.customType),
46+
);
4247
const { user } = useUserContext();
4348
const userHasChangedState = useRef(false);
4449
const isFirstRender = useRef(true);
@@ -47,7 +52,7 @@ export const IncidentEditor = ({
4752
const [isLoadingAssigneeOrAssets, setIsLoadingAssigneeOrAssets] = useState(true);
4853

4954
const [isRequiredFieldsFilled, setIsRequiredFieldsFilled] = useState<boolean>(
50-
mode === IncidentAction.VIEW ? !isFormValid : false,
55+
mode === IncidentAction.VIEW ? isFormValid : false,
5156
);
5257

5358
const { handleSubmit, form, isLoading } = useIncidentHandler({
@@ -171,6 +176,7 @@ export const IncidentEditor = ({
171176
styles={{
172177
width: '50%',
173178
}}
179+
isDisabled={mode === IncidentAction.VIEW}
174180
id="custom-incident-type-input"
175181
/>
176182
</SelectFormItem>

datahub-web-react/src/app/entityV2/shared/tabs/Incident/AcrylComponents/hooks/useIncidentHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const useIncidentHandler = ({ mode, onSubmit, incidentUrn, onClose, user,
146146
},
147147
};
148148
const newInput = _.omit(baseInput, ['state', 'message']);
149-
const newUpdateInput = _.omit(newInput, ['resourceUrn', 'type']);
149+
const newUpdateInput = _.omit(newInput, ['resourceUrn', 'type', 'customType']);
150150
const input = !isAddIncidentMode ? newUpdateInput : newInput;
151151

152152
if (isAddIncidentMode) {

0 commit comments

Comments
 (0)