mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 05:26:25 +00:00
feat(rbac): resolved submit button getting disabled
This commit is contained in:
@@ -337,10 +337,21 @@ export const DashboardPage = () => {
|
|||||||
permission.cannot(
|
permission.cannot(
|
||||||
ProjectPermissionActions.Create,
|
ProjectPermissionActions.Create,
|
||||||
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
||||||
|
) &&
|
||||||
|
permission.cannot(
|
||||||
|
ProjectPermissionActions.Delete,
|
||||||
|
subject(ProjectPermissionSub.Secrets, { environment, secretPath })
|
||||||
);
|
);
|
||||||
|
|
||||||
const canDoRollback = !isReadOnly;
|
const canDoRollback = !isReadOnly;
|
||||||
const isSubmitDisabled = isReadOnly || (!isRollbackMode && !isDirty) || isSubmitting;
|
const isSubmitDisabled =
|
||||||
|
isReadOnly ||
|
||||||
|
// not in rollback mode and no form has changed
|
||||||
|
(!isRollbackMode && !isDirty) ||
|
||||||
|
// in rollback mode and don't have permission to do it
|
||||||
|
(isRollbackMode &&
|
||||||
|
permission.cannot(ProjectPermissionActions.Create, ProjectPermissionSub.SecretRollback)) ||
|
||||||
|
isSubmitting;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isSnapshotChanging && Boolean(snapshotId)) {
|
if (!isSnapshotChanging && Boolean(snapshotId)) {
|
||||||
@@ -455,7 +466,6 @@ export const DashboardPage = () => {
|
|||||||
await onSecretRollback();
|
await onSecretRollback();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(userSec);
|
|
||||||
// just closing this if save is triggered from drawer
|
// just closing this if save is triggered from drawer
|
||||||
handlePopUpClose("secretDetails");
|
handlePopUpClose("secretDetails");
|
||||||
// encrypt and format the secrets to batch api format
|
// encrypt and format the secrets to batch api format
|
||||||
@@ -471,7 +481,6 @@ export const DashboardPage = () => {
|
|||||||
reset();
|
reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(batchedSecret);
|
|
||||||
try {
|
try {
|
||||||
await batchSecretOp({
|
await batchSecretOp({
|
||||||
requests: batchedSecret,
|
requests: batchedSecret,
|
||||||
@@ -990,35 +999,25 @@ export const DashboardPage = () => {
|
|||||||
Go back
|
Go back
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<ProjectPermissionCan
|
|
||||||
I={
|
<Tooltip
|
||||||
isRollbackMode
|
isOpen={
|
||||||
? ProjectPermissionActions.Create
|
!isSubmitting && isSubmitDisabled && isReadOnly && !isDirty ? undefined : false
|
||||||
: (ProjectPermissionActions.Edit as any)
|
|
||||||
}
|
|
||||||
a={
|
|
||||||
isRollbackMode
|
|
||||||
? ProjectPermissionSub.SecretRollback
|
|
||||||
: subject(ProjectPermissionSub.Secrets, {
|
|
||||||
environment,
|
|
||||||
secretPath
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
content="Access restricted"
|
||||||
>
|
>
|
||||||
{(isAllowed) => (
|
<Button
|
||||||
<Button
|
isDisabled={isSubmitDisabled}
|
||||||
isDisabled={isSubmitDisabled || !isAllowed}
|
isLoading={isSubmitting}
|
||||||
isLoading={isSubmitting}
|
leftIcon={<FontAwesomeIcon icon={isRollbackMode ? faClockRotateLeft : faCheck} />}
|
||||||
leftIcon={<FontAwesomeIcon icon={isRollbackMode ? faClockRotateLeft : faCheck} />}
|
onClick={handleSubmit(onSaveSecret)}
|
||||||
onClick={handleSubmit(onSaveSecret)}
|
className="h-10 text-black"
|
||||||
className="h-10 text-black"
|
color="primary"
|
||||||
color="primary"
|
variant="solid"
|
||||||
variant="solid"
|
>
|
||||||
>
|
{isRollbackMode ? "Rollback" : "Save Changes"}
|
||||||
{isRollbackMode ? "Rollback" : "Save Changes"}
|
</Button>
|
||||||
</Button>
|
</Tooltip>
|
||||||
)}
|
|
||||||
</ProjectPermissionCan>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|||||||
Reference in New Issue
Block a user