mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 08:55:24 +00:00
Set initial platform values for template policies (#4435)
This commit is contained in:
parent
1db1ab933d
commit
c2ee68cf59
@ -42,6 +42,19 @@ describe("Policies flow (empty)", () => {
|
||||
cy.findByText(/add a policy/i).click();
|
||||
});
|
||||
cy.findByText(/gatekeeper enabled/i).click();
|
||||
cy.getAttached(".platforms-select")
|
||||
.children()
|
||||
.first()
|
||||
.within(() => {
|
||||
cy.getAttached('[type="checkbox"]').should("be.checked");
|
||||
});
|
||||
cy.getAttached(".platforms-select")
|
||||
.children()
|
||||
.first()
|
||||
.next()
|
||||
.within(() => {
|
||||
cy.getAttached('[type="checkbox"]').should("not.be.checked");
|
||||
});
|
||||
cy.findByRole("button", { name: /save policy/i }).click();
|
||||
cy.findByRole("button", { name: /^Save$/ }).click();
|
||||
|
||||
|
@ -13,6 +13,7 @@ import { AppContext } from "context/app";
|
||||
import { PolicyContext } from "context/policy";
|
||||
import { IPolicy, IPolicyFormData } from "interfaces/policy";
|
||||
import { IQueryPlatform } from "interfaces/query";
|
||||
import { DEFAULT_POLICIES } from "utilities/constants";
|
||||
|
||||
import Avatar from "components/Avatar";
|
||||
import FleetAce from "components/FleetAce";
|
||||
@ -131,6 +132,10 @@ const PolicyForm = ({
|
||||
|
||||
const isEditMode = !!policyIdForEdit && !isTeamObserver && !isGlobalObserver;
|
||||
|
||||
const isNewTemplatePolicy =
|
||||
!policyIdForEdit &&
|
||||
DEFAULT_POLICIES.find((p) => p.name === lastEditedQueryName);
|
||||
|
||||
const hasSavePermissions =
|
||||
isGlobalAdmin || isGlobalMaintainer || isTeamAdmin || isTeamMaintainer;
|
||||
|
||||
@ -154,7 +159,7 @@ const PolicyForm = ({
|
||||
enableLinking: true,
|
||||
});
|
||||
|
||||
if (policyIdForEdit) {
|
||||
if (policyIdForEdit || isNewTemplatePolicy) {
|
||||
setIsWindowsCompatible(!!lastEditedQueryPlatform?.includes("windows"));
|
||||
setIsDarwinCompatible(!!lastEditedQueryPlatform?.includes("darwin"));
|
||||
setIsLinuxCompatible(!!lastEditedQueryPlatform?.includes("linux"));
|
||||
|
Loading…
Reference in New Issue
Block a user