mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 00:49:03 +00:00
Fleet UI: [small bug] Creating multiple new policies save button always enabled (#14042)
This commit is contained in:
parent
0958cb8ea1
commit
8dab938a89
3 changed files with 12 additions and 2 deletions
1
changes/14038-fix-save-multiple-new-policies
Normal file
1
changes/14038-fix-save-multiple-new-policies
Normal file
|
|
@ -0,0 +1 @@
|
|||
* Fix save button for a new policy after newly creating another policy
|
||||
|
|
@ -57,7 +57,7 @@ type InitialStateType = {
|
|||
lastEditedQueryCritical: boolean;
|
||||
lastEditedQueryPlatform: SelectedPlatformString | null;
|
||||
defaultPolicy: boolean;
|
||||
setLastEditedQueryId: (value: number) => void;
|
||||
setLastEditedQueryId: (value: number | null) => void;
|
||||
setLastEditedQueryName: (value: string) => void;
|
||||
setLastEditedQueryDescription: (value: string) => void;
|
||||
setLastEditedQueryBody: (value: string) => void;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const AddPolicyModal = ({
|
|||
setLastEditedQueryResolution,
|
||||
setLastEditedQueryCritical,
|
||||
setLastEditedQueryPlatform,
|
||||
setLastEditedQueryId,
|
||||
setPolicyTeamId,
|
||||
setDefaultPolicy,
|
||||
} = useContext(PolicyContext);
|
||||
|
|
@ -46,6 +47,7 @@ const AddPolicyModal = ({
|
|||
setLastEditedQueryBody(selectedPolicy.query);
|
||||
setLastEditedQueryResolution(selectedPolicy.resolution);
|
||||
setLastEditedQueryCritical(selectedPolicy.critical || false);
|
||||
setLastEditedQueryId(null);
|
||||
setPolicyTeamId(teamId);
|
||||
setLastEditedQueryPlatform(selectedPolicy.platform || null);
|
||||
router.push(
|
||||
|
|
@ -56,10 +58,17 @@ const AddPolicyModal = ({
|
|||
const onCreateYourOwnPolicyClick = useCallback(() => {
|
||||
setPolicyTeamId(teamId);
|
||||
setLastEditedQueryBody(DEFAULT_POLICY.query);
|
||||
setLastEditedQueryId(null);
|
||||
router.push(
|
||||
!teamId ? PATHS.NEW_POLICY : `${PATHS.NEW_POLICY}?team_id=${teamId}`
|
||||
);
|
||||
}, [router, setLastEditedQueryBody, setPolicyTeamId, teamId]);
|
||||
}, [
|
||||
router,
|
||||
setLastEditedQueryBody,
|
||||
setLastEditedQueryId,
|
||||
setPolicyTeamId,
|
||||
teamId,
|
||||
]);
|
||||
|
||||
const policiesAvailable = DEFAULT_POLICIES.map((policy: IPolicyNew) => {
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue