mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 16:52:38 +00:00
feat: finished slack integration update
This commit is contained in:
@@ -38,6 +38,7 @@ export * from "./secretSharing";
|
||||
export * from "./secretSnapshots";
|
||||
export * from "./serverDetails";
|
||||
export * from "./serviceTokens";
|
||||
export * from "./slack";
|
||||
export * from "./ssoConfig";
|
||||
export * from "./subscriptions";
|
||||
export * from "./tags";
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
export { useUpdateSlackIntegration } from "./mutation";
|
||||
export { fetchSlackInstallUrl, useGetSlackIntegrationByProject } from "./queries";
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { slackKeys } from "./queries";
|
||||
import { TUpdateSlackIntegrationDTO } from "./types";
|
||||
|
||||
export const useUpdateSlackIntegration = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation<{}, {}, TUpdateSlackIntegrationDTO>({
|
||||
mutationFn: async (dto) => {
|
||||
const { data } = await apiRequest.patch(`/api/v1/slack/${dto.id}`, dto);
|
||||
|
||||
return data;
|
||||
},
|
||||
onSuccess: (_, { workspaceId }) => {
|
||||
queryClient.invalidateQueries(slackKeys.getSlackIntegrationByProject(workspaceId));
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,16 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { ProjectSlackIntegration } from "./types";
|
||||
|
||||
export const slackKeys = {
|
||||
getSlackIntegrationByProject: (workspaceId?: string) => [
|
||||
{ workspaceId },
|
||||
"slack-integration-by-project"
|
||||
]
|
||||
};
|
||||
|
||||
export const fetchSlackInstallUrl = async (workspaceId?: string) => {
|
||||
const { data } = await apiRequest.get<string>("/api/v1/slack/install", {
|
||||
params: {
|
||||
@@ -9,3 +20,20 @@ export const fetchSlackInstallUrl = async (workspaceId?: string) => {
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const fetchSlackIntegrationByProject = async (workspaceId?: string) => {
|
||||
const { data } = await apiRequest.get<ProjectSlackIntegration>("/api/v1/slack", {
|
||||
params: {
|
||||
projectId: workspaceId
|
||||
}
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export const useGetSlackIntegrationByProject = (workspaceId?: string) =>
|
||||
useQuery({
|
||||
queryKey: slackKeys.getSlackIntegrationByProject(workspaceId),
|
||||
queryFn: () => fetchSlackIntegrationByProject(workspaceId),
|
||||
enabled: Boolean(workspaceId)
|
||||
});
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
export type ProjectSlackIntegration = {
|
||||
id: string;
|
||||
teamName: string;
|
||||
isAccessRequestNotificationEnabled: boolean;
|
||||
accessRequestChannels: string;
|
||||
isSecretRequestNotificationEnabled: boolean;
|
||||
secretRequestChannels: string;
|
||||
};
|
||||
|
||||
export type TUpdateSlackIntegrationDTO = {
|
||||
id: string;
|
||||
workspaceId: string;
|
||||
isAccessRequestNotificationEnabled?: boolean;
|
||||
accessRequestChannels?: string;
|
||||
isSecretRequestNotificationEnabled?: boolean;
|
||||
secretRequestChannels?: string;
|
||||
};
|
||||
Reference in New Issue
Block a user