feat: frontend changes for connector management

This commit is contained in:
=
2025-02-17 13:53:39 +05:30
parent c6b3b24312
commit a7ca242f5d
10 changed files with 9 additions and 180 deletions

View File

@@ -56,4 +56,3 @@ volumes:
networks: networks:
infisical: infisical:

View File

@@ -1,9 +1,7 @@
export { export {
useAdminDeleteUser, useAdminDeleteUser,
useCreateAdminUser, useCreateAdminUser,
useSetupInstanceGatewayConfig,
useUpdateAdminSlackConfig, useUpdateAdminSlackConfig,
useUpdateInstanceGatewayConfig,
useUpdateServerConfig, useUpdateServerConfig,
useUpdateServerEncryptionStrategy useUpdateServerEncryptionStrategy
} from "./mutation"; } from "./mutation";

View File

@@ -9,7 +9,6 @@ import {
AdminSlackConfig, AdminSlackConfig,
RootKeyEncryptionStrategy, RootKeyEncryptionStrategy,
TCreateAdminUserDTO, TCreateAdminUserDTO,
TDisableInstanceGatewayConfigDTO,
TServerConfig, TServerConfig,
TUpdateAdminSlackConfigDTO TUpdateAdminSlackConfigDTO
} from "./types"; } from "./types";
@@ -99,27 +98,3 @@ export const useUpdateServerEncryptionStrategy = () => {
} }
}); });
}; };
export const useSetupInstanceGatewayConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async () => {
await apiRequest.post("/api/v1/admin/gateway");
},
onSuccess: () => {
queryClient.invalidateQueries(adminQueryKeys.getInstanceGatewayConfig());
}
});
};
export const useUpdateInstanceGatewayConfig = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (dto: TDisableInstanceGatewayConfigDTO) => {
await apiRequest.patch("/api/v1/admin/gateway", dto);
},
onSuccess: () => {
queryClient.invalidateQueries(adminQueryKeys.getInstanceGatewayConfig());
}
});
};

View File

@@ -1,5 +1,4 @@
import { queryOptions, useInfiniteQuery, useQuery, UseQueryOptions } from "@tanstack/react-query"; import { useInfiniteQuery, useQuery, UseQueryOptions } from "@tanstack/react-query";
import { AxiosError } from "axios";
import { apiRequest } from "@app/config/request"; import { apiRequest } from "@app/config/request";
@@ -8,7 +7,6 @@ import {
AdminGetUsersFilters, AdminGetUsersFilters,
AdminSlackConfig, AdminSlackConfig,
TGetServerRootKmsEncryptionDetails, TGetServerRootKmsEncryptionDetails,
TInstanceGatewayConfig,
TServerConfig TServerConfig
} from "./types"; } from "./types";
@@ -20,21 +18,7 @@ export const adminQueryKeys = {
serverConfig: () => ["server-config"] as const, serverConfig: () => ["server-config"] as const,
getUsers: (filters: AdminGetUsersFilters) => [adminStandaloneKeys.getUsers, { filters }] as const, getUsers: (filters: AdminGetUsersFilters) => [adminStandaloneKeys.getUsers, { filters }] as const,
getAdminSlackConfig: () => ["admin-slack-config"] as const, getAdminSlackConfig: () => ["admin-slack-config"] as const,
getServerEncryptionStrategies: () => ["server-encryption-strategies"] as const, getServerEncryptionStrategies: () => ["server-encryption-strategies"] as const
getInstanceGatewayConfig: () =>
queryOptions({
queryKey: ["instance-gateway-config"],
queryFn: async () => {
const { data } = await apiRequest
.get<{ gateway: TInstanceGatewayConfig }>("/api/v1/admin/gateway")
.catch((err: AxiosError) => {
if (err.response?.status === 404) return { data: { gateway: false as const } };
throw err;
});
return data.gateway;
}
})
}; };
export const fetchServerConfig = async () => { export const fetchServerConfig = async () => {

View File

@@ -66,14 +66,3 @@ export enum RootKeyEncryptionStrategy {
Software = "SOFTWARE", Software = "SOFTWARE",
HSM = "HSM" HSM = "HSM"
} }
export type TInstanceGatewayConfig = {
isDisabled: boolean;
infisicalClientCaIssuedAt: string;
infisicalClientCaSerialNumber: string;
caKeyAlgorithm: string;
};
export type TDisableInstanceGatewayConfigDTO = {
isDisabled?: boolean;
};

View File

@@ -1,5 +1,7 @@
import { apiRequest } from "@app/config/request";
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { gatewaysQueryKeys } from "./queries"; import { gatewaysQueryKeys } from "./queries";
export const useDeleteGateway = () => { export const useDeleteGateway = () => {

View File

@@ -1,5 +1,7 @@
import { apiRequest } from "@app/config/request";
import { queryOptions } from "@tanstack/react-query"; import { queryOptions } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import { TGateway } from "./types"; import { TGateway } from "./types";
export const gatewaysQueryKeys = { export const gatewaysQueryKeys = {

View File

@@ -1,114 +0,0 @@
import { useQuery } from "@tanstack/react-query";
import { format } from "date-fns";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
import { Button, EmptyState, Tooltip } from "@app/components/v2";
import { useSubscription } from "@app/context";
import { usePopUp } from "@app/hooks";
import { useSetupInstanceGatewayConfig, useUpdateInstanceGatewayConfig } from "@app/hooks/api";
import { adminQueryKeys } from "@app/hooks/api/admin/queries";
export const GatewayPanel = () => {
const { subscription } = useSubscription();
const { data } = useQuery(adminQueryKeys.getInstanceGatewayConfig());
const { handlePopUpToggle, popUp, handlePopUpOpen } = usePopUp(["upgradePlan"] as const);
const setupInstanceConfig = useSetupInstanceGatewayConfig();
const updateInstanceConfig = useUpdateInstanceGatewayConfig();
const handleSetupInstance = () => {
if (!subscription.gateway) {
handlePopUpOpen("upgradePlan");
return;
}
if (!setupInstanceConfig.isPending) {
setupInstanceConfig.mutate(undefined, {
onSuccess: () => {
createNotification({
type: "success",
text: "Instance gateway setup completed"
});
}
});
}
};
const handleUpdateGatewayStatus = ({ isDisabled }: { isDisabled?: boolean }) => {
if (!updateInstanceConfig.isPending) {
updateInstanceConfig.mutate(
{ isDisabled },
{
onSuccess: () => {
createNotification({
type: "success",
text: "Instance gateway updated"
});
}
}
);
}
};
if (!data) {
return (
<div>
<EmptyState
iconSize="3x"
className="py-12"
title="The gateway, for instance, has not been set up."
>
<Button
className="mt-4"
colorSchema="primary"
size="sm"
onClick={handleSetupInstance}
isLoading={setupInstanceConfig.isPending}
>
Start Gateway
</Button>
</EmptyState>
</div>
);
}
return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<div className="mb-4 flex items-center gap-2">
<div className="text-xl font-semibold text-mineshaft-100">Gateway</div>
{data?.isDisabled && (
<Tooltip content="Gateway is disabled">
<div className="h-2 w-2 rounded-full bg-red" />
</Tooltip>
)}
</div>
<div className="mb-4">
<div className="mb-2 max-w-sm text-sm text-mineshaft-300">
Infisical Client Root CA Issued At
</div>
<div>{format(new Date(data.infisicalClientCaIssuedAt), "yyyy-MM-dd")}</div>
</div>
<div>
<div className="mb-2 max-w-sm text-sm text-mineshaft-300">
Infisical Client Root CA Seriial Number
</div>
<div>{data.infisicalClientCaSerialNumber}</div>
</div>
<Button
className="mt-4"
colorSchema={data.isDisabled ? "primary" : "danger"}
size="sm"
onClick={() => handleUpdateGatewayStatus({ isDisabled: !data?.isDisabled })}
isLoading={updateInstanceConfig.isPending}
>
{data.isDisabled ? "Enable" : "Disable"}
</Button>
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="You can use Gateway if you switch to Infisical's Enterprise plan."
/>
</div>
);
};

View File

@@ -33,7 +33,6 @@ import { EncryptionPanel } from "./components/EncryptionPanel";
import { IntegrationPanel } from "./components/IntegrationPanel"; import { IntegrationPanel } from "./components/IntegrationPanel";
import { RateLimitPanel } from "./components/RateLimitPanel"; import { RateLimitPanel } from "./components/RateLimitPanel";
import { UserPanel } from "./components/UserPanel"; import { UserPanel } from "./components/UserPanel";
import { GatewayPanel } from "./GatewayPanel";
enum TabSections { enum TabSections {
Settings = "settings", Settings = "settings",
@@ -42,8 +41,7 @@ enum TabSections {
RateLimit = "rate-limit", RateLimit = "rate-limit",
Integrations = "integrations", Integrations = "integrations",
Users = "users", Users = "users",
Kmip = "kmip", Kmip = "kmip"
Gateway = "gateway"
} }
enum SignUpModes { enum SignUpModes {
@@ -152,7 +150,6 @@ export const OverviewPage = () => {
<Tab value={TabSections.RateLimit}>Rate Limit</Tab> <Tab value={TabSections.RateLimit}>Rate Limit</Tab>
<Tab value={TabSections.Integrations}>Integrations</Tab> <Tab value={TabSections.Integrations}>Integrations</Tab>
<Tab value={TabSections.Users}>Users</Tab> <Tab value={TabSections.Users}>Users</Tab>
<Tab value={TabSections.Gateway}>Gateway</Tab>
</div> </div>
</TabList> </TabList>
<TabPanel value={TabSections.Settings}> <TabPanel value={TabSections.Settings}>
@@ -351,9 +348,6 @@ export const OverviewPage = () => {
<TabPanel value={TabSections.Users}> <TabPanel value={TabSections.Users}>
<UserPanel /> <UserPanel />
</TabPanel> </TabPanel>
<TabPanel value={TabSections.Gateway}>
<GatewayPanel />
</TabPanel>
</Tabs> </Tabs>
</div> </div>
)} )}

View File