mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 20:26:05 +00:00
fix: Missing project ID error when editing or creating project template roles
This commit is contained in:
+5
-1
@@ -220,7 +220,11 @@ export const IdentityProjectAdditionalPrivilegeModifySection = ({
|
|||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
<AddPoliciesButton
|
||||||
|
isDisabled={isDisabled}
|
||||||
|
projectType={currentProject.type}
|
||||||
|
projectId={projectId}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+5
-1
@@ -216,7 +216,11 @@ export const MembershipProjectAdditionalPrivilegeModifySection = ({
|
|||||||
>
|
>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
<AddPoliciesButton
|
||||||
|
isDisabled={isDisabled}
|
||||||
|
projectType={currentProject.type}
|
||||||
|
projectId={projectId}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ import { VaultPolicyImportModal } from "@app/pages/project/RoleDetailsBySlugPage
|
|||||||
type Props = {
|
type Props = {
|
||||||
isDisabled?: boolean;
|
isDisabled?: boolean;
|
||||||
projectType: ProjectType;
|
projectType: ProjectType;
|
||||||
|
projectId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AddPoliciesButton = ({ isDisabled, projectType }: Props) => {
|
export const AddPoliciesButton = ({ isDisabled, projectType, projectId }: Props) => {
|
||||||
const { popUp, handlePopUpToggle, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
const { popUp, handlePopUpToggle, handlePopUpOpen, handlePopUpClose } = usePopUp([
|
||||||
"addPolicy",
|
"addPolicy",
|
||||||
"addPolicyOptions",
|
"addPolicyOptions",
|
||||||
@@ -109,6 +110,7 @@ export const AddPoliciesButton = ({ isDisabled, projectType }: Props) => {
|
|||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
<PolicySelectionModal
|
<PolicySelectionModal
|
||||||
|
projectId={projectId}
|
||||||
type={projectType}
|
type={projectType}
|
||||||
isOpen={popUp.addPolicy.isOpen}
|
isOpen={popUp.addPolicy.isOpen}
|
||||||
onOpenChange={(isOpen) => handlePopUpToggle("addPolicy", isOpen)}
|
onOpenChange={(isOpen) => handlePopUpToggle("addPolicy", isOpen)}
|
||||||
|
|||||||
+10
-8
@@ -18,7 +18,7 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Tr
|
Tr
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { ProjectPermissionSub, useProject } from "@app/context";
|
import { ProjectPermissionSub } from "@app/context";
|
||||||
import { useGetWorkspaceIntegrations } from "@app/hooks/api";
|
import { useGetWorkspaceIntegrations } from "@app/hooks/api";
|
||||||
import { ProjectType } from "@app/hooks/api/projects/types";
|
import { ProjectType } from "@app/hooks/api/projects/types";
|
||||||
|
|
||||||
@@ -34,23 +34,25 @@ type Props = {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onOpenChange: (isOpen: boolean) => void;
|
onOpenChange: (isOpen: boolean) => void;
|
||||||
type: ProjectType;
|
type: ProjectType;
|
||||||
|
projectId?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ContentProps = {
|
type ContentProps = {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
|
||||||
|
// note(daniel): we allow projectId to be undefined because we use this component for project templates, in which case no project ID will be present.
|
||||||
|
projectId?: string;
|
||||||
type: ProjectType;
|
type: ProjectType;
|
||||||
};
|
};
|
||||||
|
|
||||||
type TForm = { permissions: Record<ProjectPermissionSub, boolean> };
|
type TForm = { permissions: Record<ProjectPermissionSub, boolean> };
|
||||||
|
|
||||||
const Content = ({ onClose, type: projectType }: ContentProps) => {
|
const Content = ({ onClose, projectId, type: projectType }: ContentProps) => {
|
||||||
const rootForm = useFormContext<TFormSchema>();
|
const rootForm = useFormContext<TFormSchema>();
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const { currentProject, projectId } = useProject();
|
const isSecretManagerProject = projectType === ProjectType.SecretManager;
|
||||||
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
|
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId ?? "", {
|
||||||
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
|
enabled: Boolean(isSecretManagerProject && projectId),
|
||||||
enabled: isSecretManagerProject,
|
|
||||||
refetchInterval: false
|
refetchInterval: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -216,7 +218,7 @@ const Content = ({ onClose, type: projectType }: ContentProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PolicySelectionModal = ({ isOpen, onOpenChange, type }: Props) => {
|
export const PolicySelectionModal = ({ isOpen, onOpenChange, type, projectId }: Props) => {
|
||||||
return (
|
return (
|
||||||
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
|
<Modal isOpen={isOpen} onOpenChange={onOpenChange}>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
@@ -224,7 +226,7 @@ export const PolicySelectionModal = ({ isOpen, onOpenChange, type }: Props) => {
|
|||||||
subTitle="Select one or more policies to add to this role."
|
subTitle="Select one or more policies to add to this role."
|
||||||
className="max-w-3xl"
|
className="max-w-3xl"
|
||||||
>
|
>
|
||||||
<Content onClose={() => onOpenChange(false)} type={type} />
|
<Content onClose={() => onOpenChange(false)} type={type} projectId={projectId} />
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
+5
-1
@@ -209,7 +209,11 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
|||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
<div className="ml-2 border-l border-mineshaft-500 pl-4">
|
<div className="ml-2 border-l border-mineshaft-500 pl-4">
|
||||||
<AddPoliciesButton isDisabled={isDisabled} projectType={currentProject.type} />
|
<AddPoliciesButton
|
||||||
|
isDisabled={isDisabled}
|
||||||
|
projectType={currentProject.type}
|
||||||
|
projectId={projectId}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user