mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-14 23:52:09 +00:00
64 lines
2.6 KiB
TypeScript
64 lines
2.6 KiB
TypeScript
import { ReactNode } from "react";
|
|
import { faEdit } from "@fortawesome/free-solid-svg-icons";
|
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
|
|
import { ProjectPermissionCan } from "@app/components/permissions";
|
|
import { SecretSyncLabel } from "@app/components/secret-syncs";
|
|
import { IconButton } from "@app/components/v2";
|
|
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
|
|
import { APP_CONNECTION_MAP } from "@app/helpers/appConnections";
|
|
import { SecretSync, TSecretSync } from "@app/hooks/api/secretSyncs";
|
|
import { AwsParameterStoreSyncDestinationSection } from "@app/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/AwsParameterStoreSyncDestinationSection";
|
|
import { GitHubSyncDestinationSection } from "@app/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/GitHubSyncDestinationSection";
|
|
|
|
type Props = {
|
|
secretSync: TSecretSync;
|
|
onEditDestination: VoidFunction;
|
|
};
|
|
|
|
export const SecretSyncDestinationSection = ({ secretSync, onEditDestination }: Props) => {
|
|
const { destination, connection } = secretSync;
|
|
|
|
const app = APP_CONNECTION_MAP[connection.app].name;
|
|
|
|
let DestinationComponents: ReactNode;
|
|
switch (secretSync.destination) {
|
|
case SecretSync.AWSParameterStore:
|
|
DestinationComponents = <AwsParameterStoreSyncDestinationSection secretSync={secretSync} />;
|
|
break;
|
|
case SecretSync.GitHub:
|
|
DestinationComponents = <GitHubSyncDestinationSection secretSync={secretSync} />;
|
|
break;
|
|
default:
|
|
throw new Error(`Unhandled Destination Section components: ${destination}`);
|
|
}
|
|
|
|
return (
|
|
<div className="flex w-full flex-col gap-3 rounded-lg border border-mineshaft-600 bg-mineshaft-900 px-4 py-3">
|
|
<div className="flex items-center justify-between border-b border-mineshaft-400 pb-2">
|
|
<h3 className="font-semibold text-mineshaft-100">Destination Configuration</h3>
|
|
<ProjectPermissionCan
|
|
I={ProjectPermissionActions.Edit}
|
|
a={ProjectPermissionSub.SecretSyncs}
|
|
>
|
|
{(isAllowed) => (
|
|
<IconButton
|
|
variant="plain"
|
|
colorSchema="secondary"
|
|
isDisabled={!isAllowed}
|
|
ariaLabel="Edit sync destination"
|
|
onClick={onEditDestination}
|
|
>
|
|
<FontAwesomeIcon icon={faEdit} />
|
|
</IconButton>
|
|
)}
|
|
</ProjectPermissionCan>
|
|
</div>
|
|
<div className="flex w-full flex-wrap gap-8">
|
|
<SecretSyncLabel label={`${app} Connection`}>{connection.name}</SecretSyncLabel>
|
|
{DestinationComponents}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|