Skip to content

Commit

Permalink
Add confirmation dialog to save standards
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Aug 8, 2024
1 parent 6fdd68b commit 6a77f2b
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions src/views/tenant/standards/ListAppliedStandards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ const DeleteAction = () => {
</>
)
}

const ApplyNewStandard = () => {
const [templateStandard, setTemplateStandard] = useState()
const [loadedTemplate, setLoadedTemplate] = useState(false)
Expand Down Expand Up @@ -268,6 +269,7 @@ const ApplyNewStandard = () => {
})

const tenantDomain = useSelector((state) => state.app.currentTenant.defaultDomainName)
const tenantDisplayName = useSelector((state) => state.app.currentTenant.displayName)
//console.log('tenantDomain', tenantDomain)
const [genericPostRequest, postResults] = useLazyGenericPostRequestQuery()

Expand All @@ -294,20 +296,27 @@ const ApplyNewStandard = () => {
})

const handleSubmit = async (values) => {
Object.keys(values.standards).filter(function (x) {
if (values.standards[x] === false) {
delete values.standards[x]
}
return null
})

//filter on only objects that are 'true'
genericPostRequest({
path: '/api/AddStandardsDeploy',
values: { ...values.standards, tenant: tenantDomain },
}).then(() => {
refetchStandards()
refetchConsolidated()
ModalService.confirm({
title: 'Save Standards',
body: (
<div>
<p>
Are you sure you want to save these standards to {tenantDisplayName}? This will apply
all Remediate options on the next run.
</p>
</div>
),
confirmLabel: 'Save',
cancelLabel: 'Cancel',
onConfirm: () => {
genericPostRequest({
path: '/api/AddStandardsDeploy',
values: { ...values.standards, tenant: tenantDomain },
}).then(() => {
refetchStandards()
refetchConsolidated()
})
},
})
}
const [intuneGetRequest, intuneTemplates] = useLazyGenericGetRequestQuery()
Expand Down

0 comments on commit 6a77f2b

Please sign in to comment.