mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 13:28:27 +00:00
Fix: Move to project slug
This commit is contained in:
+23
-15
@@ -21,7 +21,8 @@ import {
|
|||||||
ProjectPermissionActions,
|
ProjectPermissionActions,
|
||||||
ProjectPermissionSub,
|
ProjectPermissionSub,
|
||||||
useProjectPermission,
|
useProjectPermission,
|
||||||
useSubscription
|
useSubscription,
|
||||||
|
useWorkspace
|
||||||
} from "@app/context";
|
} from "@app/context";
|
||||||
import { usePopUp } from "@app/hooks";
|
import { usePopUp } from "@app/hooks";
|
||||||
import { useDeleteAccessApprovalPolicy, useGetWorkspaceUsers } from "@app/hooks/api";
|
import { useDeleteAccessApprovalPolicy, useGetWorkspaceUsers } from "@app/hooks/api";
|
||||||
@@ -43,12 +44,15 @@ export const AccessApprovalPolicyList = ({ workspaceId }: IProps) => {
|
|||||||
] as const);
|
] as const);
|
||||||
const { permission } = useProjectPermission();
|
const { permission } = useProjectPermission();
|
||||||
const { subscription } = useSubscription();
|
const { subscription } = useSubscription();
|
||||||
|
const { currentWorkspace } = useWorkspace();
|
||||||
|
|
||||||
const { data: members } = useGetWorkspaceUsers(workspaceId);
|
const { data: members } = useGetWorkspaceUsers(workspaceId);
|
||||||
const { data: policies, isLoading: isPoliciesLoading } = useGetAccessApprovalPolicies({
|
const { data: policies, isLoading: isPoliciesLoading } = useGetAccessApprovalPolicies({
|
||||||
workspaceId,
|
projectSlug: currentWorkspace?.slug as string,
|
||||||
options: {
|
options: {
|
||||||
enabled: permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval)
|
enabled:
|
||||||
|
permission.can(ProjectPermissionActions.Read, ProjectPermissionSub.SecretApproval) &&
|
||||||
|
!!currentWorkspace?.slug
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -56,9 +60,11 @@ export const AccessApprovalPolicyList = ({ workspaceId }: IProps) => {
|
|||||||
|
|
||||||
const handleDeletePolicy = async () => {
|
const handleDeletePolicy = async () => {
|
||||||
const { id } = popUp.deletePolicy.data as TAccessApprovalPolicy;
|
const { id } = popUp.deletePolicy.data as TAccessApprovalPolicy;
|
||||||
|
if (!currentWorkspace?.slug) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await deleteSecretApprovalPolicy({
|
await deleteSecretApprovalPolicy({
|
||||||
workspaceId,
|
projectSlug: currentWorkspace?.slug,
|
||||||
id
|
id
|
||||||
});
|
});
|
||||||
createNotification({
|
createNotification({
|
||||||
@@ -114,6 +120,7 @@ export const AccessApprovalPolicyList = ({ workspaceId }: IProps) => {
|
|||||||
<Th>Name</Th>
|
<Th>Name</Th>
|
||||||
<Th>Environment</Th>
|
<Th>Environment</Th>
|
||||||
<Th>Secret Path</Th>
|
<Th>Secret Path</Th>
|
||||||
|
<Th>Eligible Approvers</Th>
|
||||||
<Th>Approval Required</Th>
|
<Th>Approval Required</Th>
|
||||||
<Th />
|
<Th />
|
||||||
</Tr>
|
</Tr>
|
||||||
@@ -129,21 +136,22 @@ export const AccessApprovalPolicyList = ({ workspaceId }: IProps) => {
|
|||||||
</Td>
|
</Td>
|
||||||
</Tr>
|
</Tr>
|
||||||
)}
|
)}
|
||||||
{policies?.map((policy) => (
|
{!!currentWorkspace &&
|
||||||
<AccessApprovalPolicyRow
|
policies?.map((policy) => (
|
||||||
workspaceId={workspaceId}
|
<AccessApprovalPolicyRow
|
||||||
policy={policy}
|
projectSlug={currentWorkspace.slug}
|
||||||
key={policy.id}
|
policy={policy}
|
||||||
members={members}
|
key={policy.id}
|
||||||
onEdit={() => handlePopUpOpen("secretPolicyForm", policy)}
|
members={members}
|
||||||
onDelete={() => handlePopUpOpen("deletePolicy", policy)}
|
onEdit={() => handlePopUpOpen("secretPolicyForm", policy)}
|
||||||
/>
|
onDelete={() => handlePopUpOpen("deletePolicy", policy)}
|
||||||
))}
|
/>
|
||||||
|
))}
|
||||||
</TBody>
|
</TBody>
|
||||||
</Table>
|
</Table>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
<AccessPolicyForm
|
<AccessPolicyForm
|
||||||
workspaceId={workspaceId}
|
projectSlug={currentWorkspace?.slug!}
|
||||||
isOpen={popUp.secretPolicyForm.isOpen}
|
isOpen={popUp.secretPolicyForm.isOpen}
|
||||||
onToggle={(isOpen) => handlePopUpToggle("secretPolicyForm", isOpen)}
|
onToggle={(isOpen) => handlePopUpToggle("secretPolicyForm", isOpen)}
|
||||||
members={members}
|
members={members}
|
||||||
|
|||||||
Reference in New Issue
Block a user