mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-15 20:25:43 +00:00
feat: added handling of using same connection with different projects
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export { useDuplicateIntegrationAuth } from "./mutations";
|
||||
export {
|
||||
useAuthorizeIntegration,
|
||||
useDeleteIntegrationAuth,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
|
||||
import { apiRequest } from "@app/config/request";
|
||||
|
||||
import { IntegrationAuth, TDuplicateIntegrationAuthDTO } from "./types";
|
||||
|
||||
// For now, this should only be used in the Github app integration flow.
|
||||
export const useDuplicateIntegrationAuth = () => {
|
||||
return useMutation<IntegrationAuth, {}, TDuplicateIntegrationAuthDTO>({
|
||||
mutationFn: async (body) => {
|
||||
const { data } = await apiRequest.post<{ integrationAuth: IntegrationAuth }>(
|
||||
`/api/v1/integration-auth/${body.integrationAuthId}/duplicate`,
|
||||
body
|
||||
);
|
||||
|
||||
return data.integrationAuth;
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -11,6 +11,7 @@ export type IntegrationAuth = {
|
||||
teamId?: string;
|
||||
metadata: {
|
||||
installationName?: string;
|
||||
installationId?: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -87,3 +88,8 @@ export type TeamCityBuildConfig = {
|
||||
name: string;
|
||||
buildConfigId: string;
|
||||
};
|
||||
|
||||
export type TDuplicateIntegrationAuthDTO = {
|
||||
integrationAuthId: string;
|
||||
projectId: string;
|
||||
};
|
||||
|
||||
@@ -8,8 +8,9 @@ export {
|
||||
useDeleteOrgTaxId,
|
||||
useGetIdentityMembershipOrgs,
|
||||
useGetOrganizationGroups,
|
||||
useGetOrganizations,
|
||||
useGetOrganizations,
|
||||
useGetOrgBillingDetails,
|
||||
useGetOrgIntegrationAuths,
|
||||
useGetOrgInvoices,
|
||||
useGetOrgLicenses,
|
||||
useGetOrgPlanBillingInfo,
|
||||
@@ -20,4 +21,4 @@ export {
|
||||
useGetOrgTrialUrl,
|
||||
useUpdateOrg,
|
||||
useUpdateOrgBillingDetails
|
||||
} from "./queries";
|
||||
} from "./queries";
|
||||
|
||||
@@ -4,6 +4,7 @@ import { apiRequest } from "@app/config/request";
|
||||
import { OrderByDirection } from "@app/hooks/api/generic/types";
|
||||
|
||||
import { TGroupOrgMembership } from "../groups/types";
|
||||
import { IntegrationAuth } from "../types";
|
||||
import {
|
||||
BillingDetails,
|
||||
Invoice,
|
||||
@@ -39,7 +40,8 @@ export const organizationKeys = {
|
||||
...params
|
||||
}: TListOrgIdentitiesDTO) =>
|
||||
[...organizationKeys.getOrgIdentityMemberships(orgId), params] as const,
|
||||
getOrgGroups: (orgId: string) => [{ orgId }, "organization-groups"] as const
|
||||
getOrgGroups: (orgId: string) => [{ orgId }, "organization-groups"] as const,
|
||||
getOrgIntegrationAuths: (orgId: string) => [{ orgId }, "integration-auths"] as const
|
||||
};
|
||||
|
||||
export const fetchOrganizations = async () => {
|
||||
@@ -463,3 +465,21 @@ export const useGetOrganizationGroups = (organizationId: string) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export const useGetOrgIntegrationAuths = <TData = IntegrationAuth[],>(
|
||||
organizationId: string,
|
||||
select?: (data: IntegrationAuth[]) => TData
|
||||
) => {
|
||||
return useQuery({
|
||||
queryKey: organizationKeys.getOrgIntegrationAuths(organizationId),
|
||||
queryFn: async () => {
|
||||
const { data } = await apiRequest.get<{ authorizations: IntegrationAuth[] }>(
|
||||
`/api/v1/organization/${organizationId}/integration-authorizations`
|
||||
);
|
||||
|
||||
return data.authorizations;
|
||||
},
|
||||
enabled: Boolean(organizationId),
|
||||
select
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user