mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
feat: moved trusted ips anmd assume privilege to new /projects
This commit is contained in:
@@ -8,7 +8,7 @@ export const useAssumeProjectPrivileges = () =>
|
||||
useMutation({
|
||||
mutationFn: async ({ projectId, actorId, actorType }: TProjectAssumePrivilegesDTO) => {
|
||||
const { data } = await apiRequest.post<{ message: string }>(
|
||||
`/api/v1/workspace/${projectId}/assume-privileges`,
|
||||
`/api/v1/projects/${projectId}/assume-privileges`,
|
||||
{ actorId, actorType }
|
||||
);
|
||||
|
||||
@@ -20,7 +20,7 @@ export const useRemoveAssumeProjectPrivilege = () =>
|
||||
useMutation({
|
||||
mutationFn: async ({ projectId }: { projectId: string }) => {
|
||||
const { data } = await apiRequest.delete<{ message: string }>(
|
||||
`/api/v1/workspace/${projectId}/assume-privileges`
|
||||
`/api/v1/projects/${projectId}/assume-privileges`
|
||||
);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -5,15 +5,15 @@ import { apiRequest } from "@app/config/request";
|
||||
import { TrustedIp } from "./types";
|
||||
|
||||
const trustedIps = {
|
||||
getTrustedIps: (workspaceId: string) => [{ workspaceId }, "trusted-ips"] as const
|
||||
getTrustedIps: (projectId: string) => [{ projectId }, "trusted-ips"] as const
|
||||
};
|
||||
|
||||
export const useGetTrustedIps = (workspaceId: string) => {
|
||||
export const useGetTrustedIps = (projectId: string) => {
|
||||
return useQuery({
|
||||
queryKey: trustedIps.getTrustedIps(workspaceId),
|
||||
queryKey: trustedIps.getTrustedIps(projectId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ trustedIps: TrustedIp[] }>(
|
||||
`/api/v1/workspace/${workspaceId}/trusted-ips`
|
||||
`/api/v1/projects/${projectId}/trusted-ips`
|
||||
);
|
||||
|
||||
return data.trustedIps;
|
||||
@@ -25,17 +25,17 @@ export const useAddTrustedIp = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
ipAddress,
|
||||
comment,
|
||||
isActive
|
||||
}: {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
ipAddress: string;
|
||||
comment?: string;
|
||||
isActive: boolean;
|
||||
}) => {
|
||||
const { data } = await apiRequest.post(`/api/v1/workspace/${workspaceId}/trusted-ips`, {
|
||||
const { data } = await apiRequest.post(`/api/v1/projects/${projectId}/trusted-ips`, {
|
||||
ipAddress,
|
||||
...(comment ? { comment } : {}),
|
||||
isActive
|
||||
@@ -44,7 +44,7 @@ export const useAddTrustedIp = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -53,20 +53,20 @@ export const useUpdateTrustedIp = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
workspaceId,
|
||||
projectId,
|
||||
trustedIpId,
|
||||
ipAddress,
|
||||
comment,
|
||||
isActive
|
||||
}: {
|
||||
workspaceId: string;
|
||||
projectId: string;
|
||||
trustedIpId: string;
|
||||
ipAddress: string;
|
||||
comment?: string;
|
||||
isActive: boolean;
|
||||
}) => {
|
||||
const { data } = await apiRequest.patch(
|
||||
`/api/v1/workspace/${workspaceId}/trusted-ips/${trustedIpId}`,
|
||||
`/api/v1/projects/${projectId}/trusted-ips/${trustedIpId}`,
|
||||
{
|
||||
ipAddress,
|
||||
...(comment ? { comment } : {}),
|
||||
@@ -77,7 +77,7 @@ export const useUpdateTrustedIp = () => {
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -85,21 +85,15 @@ export const useUpdateTrustedIp = () => {
|
||||
export const useDeleteTrustedIp = () => {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
workspaceId,
|
||||
trustedIpId
|
||||
}: {
|
||||
workspaceId: string;
|
||||
trustedIpId: string;
|
||||
}) => {
|
||||
mutationFn: async ({ projectId, trustedIpId }: { projectId: string; trustedIpId: string }) => {
|
||||
const { data } = await apiRequest.delete(
|
||||
`/api/v1/workspace/${workspaceId}/trusted-ips/${trustedIpId}`
|
||||
`/api/v1/projects/${projectId}/trusted-ips/${trustedIpId}`
|
||||
);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess(_, dto) {
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.workspaceId) });
|
||||
queryClient.invalidateQueries({ queryKey: trustedIps.getTrustedIps(dto.projectId) });
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user