Skip to content

Commit a287f1f

Browse files
authored
Merge pull request #4983 from Infisical/fix/fetch-native-integrations-only-if-secret-manager
improvement(integrations): adjust integration fetching in PolicySelectionModal and RolePermissionsSection based on project type
2 parents 6430f7e + 8f3e5a8 commit a287f1f

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

frontend/src/hooks/api/projects/queries.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,12 +191,15 @@ export const fetchWorkspaceIntegrations = async (projectId: string) => {
191191
return data.integrations;
192192
};
193193

194-
export const useGetWorkspaceIntegrations = (projectId: string) =>
194+
export const useGetWorkspaceIntegrations = (
195+
projectId: string,
196+
options?: { enabled?: boolean; refetchInterval?: number | false }
197+
) =>
195198
useQuery({
196199
queryKey: projectKeys.getProjectIntegrations(projectId),
197200
queryFn: () => fetchWorkspaceIntegrations(projectId),
198-
enabled: Boolean(projectId),
199-
refetchInterval: 4000
201+
enabled: Boolean(projectId) && (options?.enabled ?? true),
202+
refetchInterval: options?.refetchInterval ?? 4000
200203
});
201204

202205
export const createWorkspace = (

frontend/src/pages/project/RoleDetailsBySlugPage/components/PolicySelectionModal.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ type TForm = { permissions: Record<ProjectPermissionSub, boolean> };
4747
const Content = ({ onClose, type: projectType }: ContentProps) => {
4848
const rootForm = useFormContext<TFormSchema>();
4949
const [search, setSearch] = useState("");
50-
const { currentProject } = useProject();
51-
const { data: integrations = [] } = useGetWorkspaceIntegrations(currentProject?.id ?? "");
50+
const { currentProject, projectId } = useProject();
51+
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
52+
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
53+
enabled: isSecretManagerProject,
54+
refetchInterval: false
55+
});
5256

5357
const {
5458
control,

frontend/src/pages/project/RoleDetailsBySlugPage/components/RolePermissionsSection.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,15 @@ export const renderConditionalComponents = (
103103
};
104104

105105
export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
106-
const { currentProject } = useProject();
107-
const projectId = currentProject?.id || "";
108-
const { data: role, isPending } = useGetProjectRoleBySlug(
109-
currentProject?.id ?? "",
110-
roleSlug as string
111-
);
112-
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId);
106+
const { currentProject, projectId } = useProject();
107+
108+
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
109+
110+
const { data: role, isPending } = useGetProjectRoleBySlug(projectId, roleSlug as string);
111+
const { data: integrations = [] } = useGetWorkspaceIntegrations(projectId, {
112+
enabled: isSecretManagerProject,
113+
refetchInterval: false
114+
});
113115
const hasNativeIntegrations = integrations.length > 0;
114116

115117
const [showAccessTree, setShowAccessTree] = useState<ProjectPermissionSub | null>(null);
@@ -142,8 +144,6 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
142144
(role?.slug ?? "") as ProjectMembershipRole
143145
);
144146

145-
const isSecretManagerProject = currentProject.type === ProjectType.SecretManager;
146-
147147
const permissions = form.watch("permissions");
148148

149149
const formattedPermissions = useMemo(

0 commit comments

Comments
 (0)