mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Enhancement(api): Update useGetWorkspaceIntegrations to accept options for enabled state and refetch interval; adjust integration fetching in PolicySelectionModal and RolePermissionsSection based on project type.
This commit is contained in:
@@ -191,12 +191,15 @@ export const fetchWorkspaceIntegrations = async (projectId: string) => {
|
|||||||
return data.integrations;
|
return data.integrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useGetWorkspaceIntegrations = (projectId: string) =>
|
export const useGetWorkspaceIntegrations = (
|
||||||
|
projectId: string,
|
||||||
|
options?: { enabled?: boolean; refetchInterval?: number | false }
|
||||||
|
) =>
|
||||||
useQuery({
|
useQuery({
|
||||||
queryKey: projectKeys.getProjectIntegrations(projectId),
|
queryKey: projectKeys.getProjectIntegrations(projectId),
|
||||||
queryFn: () => fetchWorkspaceIntegrations(projectId),
|
queryFn: () => fetchWorkspaceIntegrations(projectId),
|
||||||
enabled: Boolean(projectId),
|
enabled: Boolean(projectId) && (options?.enabled ?? true),
|
||||||
refetchInterval: 4000
|
refetchInterval: options?.refetchInterval ?? 4000
|
||||||
});
|
});
|
||||||
|
|
||||||
export const createWorkspace = (
|
export const createWorkspace = (
|
||||||
|
|||||||
@@ -48,7 +48,11 @@ const Content = ({ onClose, type: projectType }: ContentProps) => {
|
|||||||
const rootForm = useFormContext<TFormSchema>();
|
const rootForm = useFormContext<TFormSchema>();
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const { currentProject } = useProject();
|
const { currentProject } = useProject();
|
||||||
const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject?.id ?? "");
|
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
|
||||||
|
const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject?.id ?? "", {
|
||||||
|
enabled: isSecretManagerProject,
|
||||||
|
refetchInterval: false
|
||||||
|
});
|
||||||
|
|
||||||
const {
|
const {
|
||||||
control,
|
control,
|
||||||
|
|||||||
@@ -105,11 +105,16 @@ export const renderConditionalComponents = (
|
|||||||
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
||||||
const { currentProject } = useProject();
|
const { currentProject } = useProject();
|
||||||
const projectId = currentProject?.id || "";
|
const projectId = currentProject?.id || "";
|
||||||
|
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
|
||||||
|
|
||||||
const { data: role, isPending } = useGetProjectRoleBySlug(
|
const { data: role, isPending } = useGetProjectRoleBySlug(
|
||||||
currentProject?.id ?? "",
|
currentProject?.id ?? "",
|
||||||
roleSlug as string
|
roleSlug as string
|
||||||
);
|
);
|
||||||
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId);
|
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
|
||||||
|
enabled: isSecretManagerProject,
|
||||||
|
refetchInterval: false
|
||||||
|
});
|
||||||
const hasNativeIntegrations = integrations.length > 0;
|
const hasNativeIntegrations = integrations.length > 0;
|
||||||
|
|
||||||
const [showAccessTree, setShowAccessTree] = useState<ProjectPermissionSub | null>(null);
|
const [showAccessTree, setShowAccessTree] = useState<ProjectPermissionSub | null>(null);
|
||||||
@@ -142,8 +147,6 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
|||||||
(role?.slug ?? "") as ProjectMembershipRole
|
(role?.slug ?? "") as ProjectMembershipRole
|
||||||
);
|
);
|
||||||
|
|
||||||
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
|
|
||||||
|
|
||||||
const permissions = form.watch("permissions");
|
const permissions = form.watch("permissions");
|
||||||
|
|
||||||
const formattedPermissions = useMemo(
|
const formattedPermissions = useMemo(
|
||||||
|
|||||||
Reference in New Issue
Block a user