Skip to content

Commit 8ffd0b8

Browse files
committed
[frontend] fix: allow update payloads withh paylaod arguments
1 parent 9ab8f5c commit 8ffd0b8

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

openaev-front/src/admin/components/threat_arsenal/ThreatArsenalActionForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ const ThreatArsenalActionForm = ({
100100
default_value: z.string().nonempty(t('Should not be empty')),
101101
key: z.string().nonempty(t('Should not be empty')),
102102
type: z.enum(['text', 'number', 'port', 'portscan', 'ipv4', 'ipv6', 'credentials', 'cve', 'document', 'targeted-asset', 'kerberoastable_account', 'asreproastable_account', 'account_with_password_not_required', 'vulnerability', 'sid', 'delegation', 'password_policy', 'computer', 'group', 'admin_username', 'share', 'username'], { error: t('Should not be empty') }),
103-
subtype: z.enum(['host', 'port', 'service', 'username', 'password', 'severity', 'domain']).optional(),
103+
subtype: z.enum(['host', 'port', 'service', 'username', 'password', 'severity', 'domain']).optional().nullable(),
104104
description: z.string().optional().nullable(),
105105
separator: z.string().optional().nullable(),
106106
}).refine(
@@ -159,7 +159,7 @@ const ThreatArsenalActionForm = ({
159159

160160
const methods = useForm<ThreatArsenalActionCreateCustomInput>({
161161
mode: 'onTouched',
162-
resolver: zodResolver(schema),
162+
resolver: zodResolver(schema) as never,
163163
defaultValues: initialValues,
164164
});
165165
const {

openaev-front/src/admin/components/threat_arsenal/ThreatArsenalActionPopover.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ const ThreatArsenalActionPopover = ({
129129
setFetchedAction(null);
130130
};
131131

132-
const onSubmitEdit = (data: ThreatArsenalActionCreateCustomInput) => {
132+
const onSubmitEdit = async (data: ThreatArsenalActionCreateCustomInput) => {
133133
const inputValues: ThreatArsenalActionCreateInput = {
134134
...data,
135135
action_cleanup_executor: handleCleanupExecutorValue(
@@ -150,12 +150,11 @@ const ThreatArsenalActionPopover = ({
150150
}),
151151
} as ThreatArsenalActionCreateInput;
152152

153-
return dispatch(updateThreatArsenalAction(actionId, inputValues).then(({ data }: { data: ThreatArsenalAction }) => {
154-
if (data && onUpdate) {
155-
onUpdate(data);
156-
}
157-
handleCloseEdit();
158-
}));
153+
const response = await updateThreatArsenalAction(actionId, inputValues);
154+
if (response.data && onUpdate) {
155+
onUpdate(response.data as ThreatArsenalAction);
156+
}
157+
handleCloseEdit();
159158
};
160159

161160
// -- Delete --
@@ -176,13 +175,12 @@ const ThreatArsenalActionPopover = ({
176175
};
177176
const handleCloseDuplicate = () => setOpenDuplicate(false);
178177

179-
const submitDuplicate = () => {
180-
return dispatch(duplicateThreatArsenalAction(actionId).then(({ data }: { data: ThreatArsenalAction }) => {
181-
if (data && onDuplicate) {
182-
onDuplicate(data);
183-
}
184-
handleCloseDuplicate();
185-
}));
178+
const submitDuplicate = async () => {
179+
const response = await duplicateThreatArsenalAction(actionId);
180+
if (response.data && onDuplicate) {
181+
onDuplicate(response.data as ThreatArsenalAction);
182+
}
183+
handleCloseDuplicate();
186184
};
187185

188186
const hasUpdateCapability = ability.can(ACTIONS.MANAGE, SUBJECTS.PAYLOADS) || ability.can(ACTIONS.MANAGE, SUBJECTS.RESOURCE, payloadId);

0 commit comments

Comments
 (0)