mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 05:27:48 +00:00
misc: added neat check all condition
This commit is contained in:
+12
-1
@@ -32,10 +32,21 @@ export const UpgradePrivilegeSystemModal = ({ isOpen, onOpenChange }: Props) =>
|
|||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
|
watch,
|
||||||
formState: { isSubmitting }
|
formState: { isSubmitting }
|
||||||
} = useForm({ resolver: zodResolver(formSchema) });
|
} = useForm({ resolver: zodResolver(formSchema) });
|
||||||
const { mutateAsync: upgradePrivilegeSystem } = useUpgradePrivilegeSystem();
|
const { mutateAsync: upgradePrivilegeSystem } = useUpgradePrivilegeSystem();
|
||||||
|
|
||||||
|
const isProjectPrivilegesUpdated = watch("isProjectPrivilegesUpdated");
|
||||||
|
const isOrgPrivilegesUpdated = watch("isOrgPrivilegesUpdated");
|
||||||
|
const isInfrastructureUpdated = watch("isInfrastructureUpdated");
|
||||||
|
const acknowledgesPermanentChange = watch("acknowledgesPermanentChange");
|
||||||
|
const isAllChecksCompleted =
|
||||||
|
isProjectPrivilegesUpdated &&
|
||||||
|
isOrgPrivilegesUpdated &&
|
||||||
|
isInfrastructureUpdated &&
|
||||||
|
acknowledgesPermanentChange;
|
||||||
|
|
||||||
const handlePrivilegeSystemUpgrade = async () => {
|
const handlePrivilegeSystemUpgrade = async () => {
|
||||||
try {
|
try {
|
||||||
await upgradePrivilegeSystem();
|
await upgradePrivilegeSystem();
|
||||||
@@ -231,7 +242,7 @@ export const UpgradePrivilegeSystemModal = ({ isOpen, onOpenChange }: Props) =>
|
|||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
isDisabled={!isAdmin}
|
isDisabled={!isAdmin || !isAllChecksCompleted}
|
||||||
isLoading={isSubmitting}
|
isLoading={isSubmitting}
|
||||||
className="mt-5 w-full"
|
className="mt-5 w-full"
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user