mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat: completed all workspace prefix routes
This commit is contained in:
@@ -7,10 +7,10 @@ import { TReactQueryOptions } from "@app/types/reactQuery";
|
||||
import { Actor, AuditLog, TGetAuditLogsFilter } from "./types";
|
||||
|
||||
export const auditLogKeys = {
|
||||
getAuditLogs: (workspaceId: string | null, filters: TGetAuditLogsFilter) =>
|
||||
[{ workspaceId, filters }, "audit-logs"] as const,
|
||||
getAuditLogActorFilterOpts: (workspaceId: string) =>
|
||||
[{ workspaceId }, "audit-log-actor-filters"] as const
|
||||
getAuditLogs: (projectId: string | null, filters: TGetAuditLogsFilter) =>
|
||||
[{ projectId, filters }, "audit-logs"] as const,
|
||||
getAuditLogActorFilterOpts: (projectId: string) =>
|
||||
[{ projectId }, "audit-log-actor-filters"] as const
|
||||
};
|
||||
|
||||
export const useGetAuditLogs = (
|
||||
@@ -56,12 +56,12 @@ export const useGetAuditLogs = (
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetAuditLogActorFilterOpts = (workspaceId: string) => {
|
||||
export const useGetAuditLogActorFilterOpts = (projectId: string) => {
|
||||
return useQuery({
|
||||
queryKey: auditLogKeys.getAuditLogActorFilterOpts(workspaceId),
|
||||
queryKey: auditLogKeys.getAuditLogActorFilterOpts(projectId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ actors: Actor[] }>(
|
||||
`/api/v1/workspace/${workspaceId}/audit-logs/filters/actors`
|
||||
`/api/v1/projects/${projectId}/audit-logs/filters/actors`
|
||||
);
|
||||
return data.actors;
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ export const useListProjectGroupUsers = ({
|
||||
});
|
||||
|
||||
const { data } = await apiRequest.get<{ users: TGroupUser[]; totalCount: number }>(
|
||||
`/api/v2/workspace/${projectId}/groups/${id}/users`,
|
||||
`/api/v1/projects/${projectId}/groups/${id}/users`,
|
||||
{
|
||||
params
|
||||
}
|
||||
|
||||
@@ -4,23 +4,23 @@ import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { CreateTagDTO, DeleteTagDTO, UserWsTags, WsTag } from "./types";
|
||||
|
||||
const workspaceTags = {
|
||||
getWsTags: (workspaceID: string) => ["workspace-tags", { workspaceID }] as const
|
||||
const projectTags = {
|
||||
getWsTags: (projectID: string) => ["project-tags", { projectID }] as const
|
||||
};
|
||||
|
||||
const fetchWsTag = async (workspaceID: string) => {
|
||||
const { data } = await apiRequest.get<{ workspaceTags: UserWsTags }>(
|
||||
`/api/v1/workspace/${workspaceID}/tags`
|
||||
const fetchWsTag = async (projectID: string) => {
|
||||
const { data } = await apiRequest.get<{ projectTags: UserWsTags }>(
|
||||
`/api/v1/projects/${projectID}/tags`
|
||||
);
|
||||
|
||||
return data.workspaceTags;
|
||||
return data.projectTags;
|
||||
};
|
||||
|
||||
export const useGetWsTags = (workspaceID: string) => {
|
||||
export const useGetWsTags = (projectID: string) => {
|
||||
return useQuery({
|
||||
queryKey: workspaceTags.getWsTags(workspaceID),
|
||||
queryFn: () => fetchWsTag(workspaceID),
|
||||
enabled: Boolean(workspaceID)
|
||||
queryKey: projectTags.getWsTags(projectID),
|
||||
queryFn: () => fetchWsTag(projectID),
|
||||
enabled: Boolean(projectID)
|
||||
});
|
||||
};
|
||||
|
||||
@@ -28,18 +28,18 @@ export const useCreateWsTag = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<WsTag, object, CreateTagDTO>({
|
||||
mutationFn: async ({ workspaceID, tagColor, tagSlug }) => {
|
||||
const { data } = await apiRequest.post<{ workspaceTag: WsTag }>(
|
||||
`/api/v1/workspace/${workspaceID}/tags`,
|
||||
mutationFn: async ({ projectID, tagColor, tagSlug }) => {
|
||||
const { data } = await apiRequest.post<{ projectTag: WsTag }>(
|
||||
`/api/v1/projects/${projectID}/tags`,
|
||||
{
|
||||
color: tagColor || "",
|
||||
slug: tagSlug
|
||||
}
|
||||
);
|
||||
return data.workspaceTag;
|
||||
return data.projectTag;
|
||||
},
|
||||
onSuccess: (tagData) => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: projectTags.getWsTags(tagData?.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -49,13 +49,13 @@ export const useDeleteWsTag = () => {
|
||||
|
||||
return useMutation<WsTag, object, DeleteTagDTO>({
|
||||
mutationFn: async ({ tagID, projectId }) => {
|
||||
const { data } = await apiRequest.delete<{ workspaceTag: WsTag }>(
|
||||
`/api/v1/workspace/${projectId}/tags/${tagID}`
|
||||
const { data } = await apiRequest.delete<{ projectTag: WsTag }>(
|
||||
`/api/v1/projects/${projectId}/tags/${tagID}`
|
||||
);
|
||||
return data.workspaceTag;
|
||||
return data.projectTag;
|
||||
},
|
||||
onSuccess: (tagData) => {
|
||||
queryClient.invalidateQueries({ queryKey: workspaceTags.getWsTags(tagData?.projectId) });
|
||||
queryClient.invalidateQueries({ queryKey: projectTags.getWsTags(tagData?.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ export type WsTag = {
|
||||
export type WorkspaceTag = { id: string; name: string; slug: string };
|
||||
|
||||
export type CreateTagDTO = {
|
||||
workspaceID: string;
|
||||
projectID: string;
|
||||
tagSlug: string;
|
||||
tagColor: string;
|
||||
};
|
||||
|
||||
@@ -118,13 +118,13 @@ export const useUpdateProjectWorkflowIntegrationConfig = () => {
|
||||
return useMutation({
|
||||
mutationFn: async (dto: TUpdateProjectWorkflowIntegrationConfigDTO) => {
|
||||
const { data } = await apiRequest.put(
|
||||
`/api/v1/workspace/${dto.workspaceId}/workflow-integration`,
|
||||
`/api/v1/projects/${dto.projectId}/workflow-integration`,
|
||||
dto
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId, integration }) => {
|
||||
onSuccess: (_, { projectId: workspaceId, integration }) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectKeys.getWorkspaceWorkflowIntegrationConfig(workspaceId, integration)
|
||||
});
|
||||
@@ -138,7 +138,7 @@ export const useDeleteProjectWorkflowIntegration = () => {
|
||||
return useMutation({
|
||||
mutationFn: async (dto: TDeleteProjectWorkflowIntegrationDTO) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/workspace/${dto.projectId}/workflow-integration/${dto.integration}/${dto.integrationId}`
|
||||
`/api/v1/projects/${dto.projectId}/workflow-integration/${dto.integration}/${dto.integrationId}`
|
||||
);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -106,7 +106,7 @@ export type ProjectWorkflowIntegrationConfig =
|
||||
export type TUpdateProjectWorkflowIntegrationConfigDTO =
|
||||
| {
|
||||
integration: WorkflowIntegrationPlatform.SLACK;
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
@@ -115,7 +115,7 @@ export type TUpdateProjectWorkflowIntegrationConfigDTO =
|
||||
}
|
||||
| {
|
||||
integration: WorkflowIntegrationPlatform.MICROSOFT_TEAMS;
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
integrationId: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
|
||||
@@ -25,7 +25,6 @@ export {
|
||||
useGetWorkspaceIdentityMemberships,
|
||||
useGetWorkspaceIndexStatus,
|
||||
useGetWorkspaceIntegrations,
|
||||
useGetWorkspaceSecrets,
|
||||
useGetWorkspaceUserDetails,
|
||||
useGetWorkspaceUsers,
|
||||
useGetWorkspaceWorkflowIntegrationConfig,
|
||||
@@ -41,7 +40,6 @@ export {
|
||||
useListWorkspaceSshCertificateTemplates,
|
||||
useListWorkspaceSshHostGroups,
|
||||
useListWorkspaceSshHosts,
|
||||
useNameWorkspaceSecrets,
|
||||
useSearchProjects,
|
||||
useToggleAutoCapitalization,
|
||||
useUpdateIdentityWorkspaceRole,
|
||||
|
||||
@@ -15,7 +15,6 @@ import { TIntegration } from "../integrations/types";
|
||||
import { TPkiAlert } from "../pkiAlerts/types";
|
||||
import { TPkiCollection } from "../pkiCollections/types";
|
||||
import { TPkiSubscriber } from "../pkiSubscriber/types";
|
||||
import { EncryptedSecret } from "../secrets/types";
|
||||
import { TSshCertificate, TSshCertificateAuthority } from "../sshCa/types";
|
||||
import { TSshCertificateTemplate } from "../sshCertificateTemplates/types";
|
||||
import { TSshHost } from "../sshHost/types";
|
||||
@@ -32,7 +31,6 @@ import {
|
||||
CreateWorkspaceDTO,
|
||||
DeleteEnvironmentDTO,
|
||||
DeleteWorkspaceDTO,
|
||||
NameWorkspaceSecretsDTO,
|
||||
ProjectIdentityOrderBy,
|
||||
ProjectType,
|
||||
TGetUpgradeProjectStatusDTO,
|
||||
@@ -73,14 +71,6 @@ const fetchProjectUpgradeStatus = async (projectId: string) => {
|
||||
return data;
|
||||
};
|
||||
|
||||
export const fetchWorkspaceSecrets = async (projectId: string) => {
|
||||
const {
|
||||
data: { secrets }
|
||||
} = await apiRequest.get<{ secrets: EncryptedSecret[] }>(`/api/v3/projects/${projectId}/secrets`);
|
||||
|
||||
return secrets;
|
||||
};
|
||||
|
||||
export const useUpgradeProject = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
@@ -129,14 +119,6 @@ export const useGetWorkspaceIndexStatus = (projectId: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetWorkspaceSecrets = (projectId: string) => {
|
||||
return useQuery({
|
||||
queryKey: projectKeys.getWorkspaceSecrets(projectId),
|
||||
queryFn: () => fetchWorkspaceSecrets(projectId),
|
||||
enabled: true
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetWorkspaceById = (
|
||||
projectId: string,
|
||||
dto?: { refetchInterval?: number | false }
|
||||
@@ -192,22 +174,6 @@ export const useGetUserWorkspaceMemberships = (orgId: string) =>
|
||||
enabled: Boolean(orgId)
|
||||
});
|
||||
|
||||
export const useNameWorkspaceSecrets = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<object, object, NameWorkspaceSecretsDTO>({
|
||||
mutationFn: async ({ projectId, secretsToUpdate }) =>
|
||||
apiRequest.post(`/api/v3/projects/${projectId}/secrets/names`, {
|
||||
secretsToUpdate
|
||||
}),
|
||||
onSuccess: (_, variables) => {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: projectKeys.getWorkspaceIndexStatus(variables.projectId)
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const fetchWorkspaceAuthorization = async (projectId: string) => {
|
||||
const { data } = await apiRequest.get<{ authorizations: IntegrationAuth[] }>(
|
||||
`/api/v1/projects/${projectId}/authorizations`
|
||||
|
||||
@@ -136,7 +136,7 @@ export const MicrosoftTeamsIntegrationForm = ({ onClose }: Props) => {
|
||||
}
|
||||
|
||||
await updateProjectMicrosoftTeamsConfig({
|
||||
workspaceId: currentWorkspace.id,
|
||||
projectId: currentWorkspace.id,
|
||||
isAccessRequestNotificationEnabled: data.isAccessRequestNotificationEnabled,
|
||||
isSecretRequestNotificationEnabled: data.isSecretRequestNotificationEnabled,
|
||||
...(data.isAccessRequestNotificationEnabled && {
|
||||
|
||||
@@ -83,7 +83,7 @@ export const SlackIntegrationForm = ({ onClose }: Props) => {
|
||||
|
||||
await updateProjectSlackConfig({
|
||||
...data,
|
||||
workspaceId: currentWorkspace.id,
|
||||
projectId: currentWorkspace.id,
|
||||
integration: WorkflowIntegrationPlatform.SLACK,
|
||||
integrationId: data.slackIntegrationId,
|
||||
accessRequestChannels: data.accessRequestChannels.filter(Boolean).join(", "),
|
||||
|
||||
Reference in New Issue
Block a user