Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(ui): migrate org workflow integrations tab to v3

andrewhuhh13a203c6e30f
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx
index 15acf5c975..496a3a04e2 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/AddWorkflowIntegrationForm.tsx
@@ -1,10 +1,16 @@
import { useState } from "react";
-import { BsMicrosoftTeams } from "react-icons/bs";
-import { faSlack } from "@fortawesome/free-brands-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { AnimatePresence, motion } from "framer-motion";
+import { BsMicrosoftTeams, BsSlack } from "react-icons/bs";
-import { Modal, ModalContent } from "@app/components/v2";
+import {
+ Button,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle
+} from "@app/components/v3";
import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
import { MicrosoftTeamsIntegrationForm } from "./MicrosoftTeamsIntegrationForm";
@@ -15,14 +21,9 @@ type Props = {
onToggle: (isOpen: boolean) => void;
};
-enum WizardSteps {
- SelectPlatform = "select-platform",
- PlatformInputs = "platform-inputs"
-}
-
const PLATFORM_LIST = [
{
- icon: <FontAwesomeIcon icon={faSlack} size="lg" />,
+ icon: <BsSlack className="text-lg" />,
platform: WorkflowIntegrationPlatform.SLACK,
title: "Slack"
},
@@ -33,83 +34,77 @@ const PLATFORM_LIST = [
}
];
+const PLATFORM_TITLES: Record<WorkflowIntegrationPlatform, string> = {
+ [WorkflowIntegrationPlatform.SLACK]: "Slack",
+ [WorkflowIntegrationPlatform.MICROSOFT_TEAMS]: "Microsoft Teams"
+};
+
export const AddWorkflowIntegrationForm = ({ isOpen, onToggle }: Props) => {
- const [wizardStep, setWizardStep] = useState(WizardSteps.SelectPlatform);
- const [selectedPlatform, setSelectedPlatform] = useState<string | null>(null);
+ const [selectedPlatform, setSelectedPlatform] = useState<WorkflowIntegrationPlatform | null>(
+ null
+ );
- const handleFormReset = (state: boolean = false) => {
+ const handleOpenChange = (state: boolean) => {
onToggle(state);
- setWizardStep(WizardSteps.SelectPlatform);
- setSelectedPlatform(null);
+ if (!state) {
+ setSelectedPlatform(null);
+ }
};
return (
- <Modal isOpen={isOpen} onOpenChange={(state) => handleFormReset(state)}>
- <ModalContent
- title={`Add a ${selectedPlatform?.replace("-", " ").replace(/\b\w/g, (char) => char.toUpperCase()) ?? "workflow"} integration`}
- className="my-4"
- >
- <AnimatePresence mode="wait">
- {wizardStep === WizardSteps.SelectPlatform && (
- <motion.div
- key="select-type-step"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <div className="mb-4 text-mineshaft-300">Select a platform</div>
- <div className="flex items-center space-x-4">
- {PLATFORM_LIST.map(({ icon, platform, title }) => (
- <div
- key={platform}
- className="flex h-28 w-32 cursor-pointer flex-col items-center space-y-4 rounded-sm border border-mineshaft-500 bg-bunker-600 p-6 transition-all hover:border-primary/70 hover:bg-primary/10 hover:text-white"
- role="button"
- tabIndex={0}
- onClick={() => {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.PlatformInputs);
- }}
- onKeyDown={(evt) => {
- if (evt.key === "Enter") {
- setSelectedPlatform(platform);
- setWizardStep(WizardSteps.PlatformInputs);
- }
- }}
- >
- <div>{icon}</div>
- <div className="text-center text-sm whitespace-pre-wrap">{title}</div>
- </div>
- ))}
- </div>
- </motion.div>
- )}
- {wizardStep === WizardSteps.PlatformInputs &&
- selectedPlatform === WorkflowIntegrationPlatform.SLACK && (
- <motion.div
- key="slack-platform"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <SlackIntegrationForm onClose={() => onToggle(false)} />
- </motion.div>
- )}
- {wizardStep === WizardSteps.PlatformInputs &&
- selectedPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
- <motion.div
- key="microsoft-teams-platform"
- transition={{ duration: 0.1 }}
- initial={{ opacity: 0, translateX: 30 }}
- animate={{ opacity: 1, translateX: 0 }}
- exit={{ opacity: 0, translateX: -30 }}
- >
- <MicrosoftTeamsIntegrationForm onClose={() => onToggle(false)} />
- </motion.div>
- )}
- </AnimatePresence>
- </ModalContent>
- </Modal>
+ <Dialog open={isOpen} onOpenChange={handleOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>
+ {selectedPlatform
+ ? `Connect ${PLATFORM_TITLES[selectedPlatform]}`
+ : "Add Workflow Integration"}
+ </DialogTitle>
+ <DialogDescription>
+ {selectedPlatform
+ ? `Connect a ${PLATFORM_TITLES[selectedPlatform]} ${
+ selectedPlatform === WorkflowIntegrationPlatform.SLACK ? "workspace" : "tenant"
+ } for your organization's notification and approval workflows.`
+ : "Select a platform to connect for notification and approval workflows."}
+ </DialogDescription>
+ </DialogHeader>
+ {!selectedPlatform && (
+ <>
+ <div className="flex items-center gap-4">
+ {PLATFORM_LIST.map(({ icon, platform, title }) => (
+ <button
+ type="button"
+ key={platform}
+ onClick={() => setSelectedPlatform(platform)}
+ className="flex h-28 w-36 flex-col items-center justify-center gap-3 rounded-md border border-border bg-container transition-colors hover:border-org/70 hover:bg-org/10"
+ >
+ {icon}
+ <span className="text-sm">{title}</span>
+ </button>
+ ))}
+ </div>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button type="button" variant="ghost">
+ Cancel
+ </Button>
+ </DialogClose>
+ </DialogFooter>
+ </>
+ )}
+ {selectedPlatform === WorkflowIntegrationPlatform.SLACK && (
+ <SlackIntegrationForm
+ onClose={() => handleOpenChange(false)}
+ onBack={() => setSelectedPlatform(null)}
+ />
+ )}
+ {selectedPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
+ <MicrosoftTeamsIntegrationForm
+ onClose={() => handleOpenChange(false)}
+ onBack={() => setSelectedPlatform(null)}
+ />
+ )}
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx
index 48cfa22435..40393ff72c 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/IntegrationFormDetails.tsx
@@ -1,4 +1,10 @@
-import { Modal, ModalContent } from "@app/components/v2";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogHeader,
+ DialogTitle
+} from "@app/components/v3";
import { WorkflowIntegrationPlatform } from "@app/hooks/api/workflowIntegrations/types";
import { MicrosoftTeamsIntegrationForm } from "./MicrosoftTeamsIntegrationForm";
@@ -11,20 +17,30 @@ type Props = {
onOpenChange: (state: boolean) => void;
};
+const PLATFORM_TITLES: Record<WorkflowIntegrationPlatform, string> = {
+ [WorkflowIntegrationPlatform.SLACK]: "Slack",
+ [WorkflowIntegrationPlatform.MICROSOFT_TEAMS]: "Microsoft Teams"
+};
+
export const IntegrationFormDetails = ({ isOpen, id, onOpenChange, workflowPlatform }: Props) => {
- const modalTitle =
- workflowPlatform === WorkflowIntegrationPlatform.SLACK ? "Slack integration" : "Integration";
+ const platformTitle = workflowPlatform ? PLATFORM_TITLES[workflowPlatform] : "";
return (
- <Modal isOpen={isOpen} onOpenChange={onOpenChange}>
- <ModalContent title={modalTitle}>
+ <Dialog open={isOpen} onOpenChange={onOpenChange}>
+ <DialogContent className="sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>{platformTitle} Integration</DialogTitle>
+ <DialogDescription>
+ View and update this {platformTitle} integration&apos;s details.
+ </DialogDescription>
+ </DialogHeader>
{workflowPlatform === WorkflowIntegrationPlatform.SLACK && (
<SlackIntegrationForm id={id} onClose={() => onOpenChange(false)} />
)}
{workflowPlatform === WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
<MicrosoftTeamsIntegrationForm id={id} onClose={() => onOpenChange(false)} />
)}
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/MicrosoftTeamsIntegrationForm.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/MicrosoftTeamsIntegrationForm.tsx
index 09e5d6583d..9588e19ce2 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/MicrosoftTeamsIntegrationForm.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/MicrosoftTeamsIntegrationForm.tsx
@@ -3,10 +3,20 @@ import crypto from "crypto";
import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
+import { ChevronLeft } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, FormControl, Input } from "@app/components/v2";
+import {
+ Button,
+ DialogClose,
+ DialogFooter,
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ Input
+} from "@app/components/v3";
import { useOrganization } from "@app/context";
import {
useGetMicrosoftTeamsClientId,
@@ -18,6 +28,7 @@ import { slugSchema } from "@app/lib/schemas";
type Props = {
id?: string;
onClose: () => void;
+ onBack?: () => void;
};
const microsoftTeamsFormSchema = z.object({
@@ -32,7 +43,7 @@ const microsoftTeamsFormSchema = z.object({
type TMicrosoftTeamsFormData = z.infer<typeof microsoftTeamsFormSchema>;
-export const MicrosoftTeamsIntegrationForm = ({ id, onClose }: Props) => {
+export const MicrosoftTeamsIntegrationForm = ({ id, onClose, onBack }: Props) => {
const {
control,
handleSubmit,
@@ -89,7 +100,7 @@ export const MicrosoftTeamsIntegrationForm = ({ id, onClose }: Props) => {
});
createNotification({
- text: "Successfully updated Microsoft Teams integration",
+ text: "Updated Microsoft Teams integration",
type: "success"
});
@@ -122,27 +133,35 @@ export const MicrosoftTeamsIntegrationForm = ({ id, onClose }: Props) => {
};
return (
- <form onSubmit={handleSubmit(handleMicrosoftTeamsFormSubmit)} autoComplete="off">
- <div className="mb-4 text-xs text-mineshaft-200">
+ <form
+ onSubmit={handleSubmit(handleMicrosoftTeamsFormSubmit)}
+ className="flex flex-col gap-4"
+ autoComplete="off"
+ >
+ <p className="text-xs text-muted">
For seamless installations, ensure that the Infisical bot is already installed in your
- Microsoft Teams tenant. For more information, please refer to the{" "}
+ Microsoft Teams tenant. See the{" "}
<a
- className="text-primary-500"
+ className="text-org underline underline-offset-2"
href="https://infisical.com/docs/documentation/platform/workflow-integrations/microsoft-teams-integration"
target="_blank"
rel="noopener noreferrer"
>
- Microsoft Teams Workflow Integration Documentation
- </a>
- , which will guide you through the download and installation process.
- </div>
+ documentation
+ </a>{" "}
+ for the download and installation process.
+ </p>
<Controller
control={control}
name="slug"
render={({ field, fieldState: { error } }) => (
- <FormControl label="Alias" isRequired errorText={error?.message} isError={Boolean(error)}>
- <Input placeholder="" {...field} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="microsoft-teams-integration-alias">
+ Alias <span className="text-danger">*</span>
+ </FieldLabel>
+ <Input id="microsoft-teams-integration-alias" isError={Boolean(error)} {...field} />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
{!microsoftTeamsIntegration && (
@@ -150,14 +169,18 @@ export const MicrosoftTeamsIntegrationForm = ({ id, onClose }: Props) => {
control={control}
name="tenantId"
render={({ field, fieldState: { error } }) => (
- <FormControl
- isRequired
- label="Tenant ID"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <Input placeholder="" {...field} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="microsoft-teams-integration-tenant-id">
+ Tenant ID <span className="text-danger">*</span>
+ </FieldLabel>
+ <Input
+ id="microsoft-teams-integration-tenant-id"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
+ <FieldDescription>The ID of the Microsoft Teams tenant to connect.</FieldDescription>
+ </Field>
)}
/>
)}
@@ -165,28 +188,50 @@ export const MicrosoftTeamsIntegrationForm = ({ id, onClose }: Props) => {
control={control}
name="description"
render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" errorText={error?.message} isError={Boolean(error)}>
- <Input placeholder="" {...field} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="microsoft-teams-integration-description">Description</FieldLabel>
+ <Input
+ id="microsoft-teams-integration-description"
+ isError={Boolean(error)}
+ {...field}
+ />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
{microsoftTeamsIntegration && (
- <FormControl label="Connected Microsoft Teams Tenant">
+ <Field>
+ <FieldLabel htmlFor="microsoft-teams-integration-tenant">
+ Connected Microsoft Teams tenant
+ </FieldLabel>
<Input
+ id="microsoft-teams-integration-tenant"
value={microsoftTeamsIntegration.tenantId}
- isReadOnly
- className="bg-white/[0.07]"
+ readOnly
/>
- </FormControl>
+ </Field>
)}
- <div className="mt-6 flex items-center space-x-4">
- <Button type="submit" isLoading={isSubmitting} isDisabled={!isDirty || isSubmitting}>
- {id && microsoftTeamsIntegration ? "Save" : "Create Microsoft Teams Integration"}
- </Button>
- <Button variant="outline_bg" onClick={onClose}>
- Cancel
+ <DialogFooter>
+ {onBack && (
+ <Button type="button" variant="ghost" className="mr-auto" onClick={onBack}>
+ <ChevronLeft />
+ Back
+ </Button>
+ )}
+ <DialogClose asChild>
+ <Button type="button" variant="ghost">
+ Cancel
+ </Button>
+ </DialogClose>
+ <Button
+ type="submit"
+ variant="org"
+ isPending={isSubmitting}
+ isDisabled={!isDirty || isSubmitting}
+ >
+ {id && microsoftTeamsIntegration ? "Save" : "Connect Microsoft Teams"}
</Button>
- </div>
+ </DialogFooter>
</form>
);
};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx
index 2bf8fd5d30..069e80e035 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/OrgWorkflowIntegrationTab.tsx
@@ -1,29 +1,48 @@
+import { useState } from "react";
import { BsMicrosoftTeams, BsSlack } from "react-icons/bs";
-import { faEllipsis, faGear, faInfoCircle, faPlus } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import axios from "axios";
-import { twMerge } from "tailwind-merge";
+import { Info, MoreHorizontal, Plus, RotateCcw, ShieldCheck, Trash2 } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
import {
+ AlertDialog,
+ AlertDialogCancel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogMedia,
+ AlertDialogTitle,
+ Badge,
Button,
- DeleteActionModal,
+ Card,
+ CardAction,
+ CardContent,
+ CardDescription,
+ CardHeader,
+ CardTitle,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
- EmptyState,
+ Empty,
+ EmptyDescription,
+ EmptyHeader,
+ EmptyTitle,
+ IconButton,
+ Input,
+ Skeleton,
Table,
- TableContainer,
- TableSkeleton,
- TBody,
- Td,
- THead,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
Tooltip,
- Tr
-} from "@app/components/v2";
-import { Badge } from "@app/components/v3";
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
import { withPermission } from "@app/hoc";
import { usePopUp } from "@app/hooks";
@@ -61,6 +80,7 @@ export const OrgWorkflowIntegrationTab = withPermission(
"integrationDetails",
"removeIntegration"
] as const);
+ const [deleteConfirmation, setDeleteConfirmation] = useState("");
const { currentOrg } = useOrganization();
const { data: workflowIntegrations, isPending: isWorkflowIntegrationsLoading } =
@@ -71,12 +91,16 @@ export const OrgWorkflowIntegrationTab = withPermission(
const { mutateAsync: checkMicrosoftTeamsInstallationStatus } =
useCheckMicrosoftTeamsIntegrationInstallationStatus();
+ const removeIntegrationData = popUp.removeIntegration.data as
+ | { id: string; slug: string; platform: WorkflowIntegrationPlatform }
+ | undefined;
+
const handleRemoveIntegration = async () => {
- if (!currentOrg) {
+ if (!currentOrg || !removeIntegrationData) {
return;
}
- const { platform, id } = popUp.removeIntegration.data;
+ const { platform, id, slug } = removeIntegrationData;
if (platform === WorkflowIntegrationPlatform.SLACK) {
await deleteSlackIntegration({
id,
@@ -93,7 +117,7 @@ export const OrgWorkflowIntegrationTab = withPermission(
handlePopUpClose("removeIntegration");
createNotification({
- text: "Successfully deleted integration",
+ text: `Deleted integration "${slug}"`,
type: "success"
});
};
@@ -130,169 +154,182 @@ export const OrgWorkflowIntegrationTab = withPermission(
};
return (
- <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
- <div className="flex justify-between">
- <p className="text-xl font-medium text-mineshaft-100">Workflow Integrations</p>
- <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
- {(isAllowed) => (
- <Button
- onClick={() => {
- handlePopUpOpen("addWorkflowIntegration");
- }}
- isDisabled={!isAllowed}
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- >
- Add
- </Button>
- )}
- </OrgPermissionCan>
- </div>
- <p className="mb-4 text-gray-400">
- Connect Infisical to other platforms for notification and workflow integrations.
- </p>
- <TableContainer>
- <Table>
- <THead>
- <Tr>
- <Td>Provider</Td>
- <Td>Alias</Td>
- <Td>Status</Td>
- </Tr>
- </THead>
- <TBody>
- {isWorkflowIntegrationsLoading && (
- <TableSkeleton columns={2} innerKey="integrations-loading" />
+ <Card>
+ <CardHeader>
+ <CardTitle>Workflow Integrations</CardTitle>
+ <CardDescription>
+ Connect Infisical to other platforms for notification and workflow integrations.
+ </CardDescription>
+ <CardAction>
+ <OrgPermissionCan I={OrgPermissionActions.Create} an={OrgPermissionSubjects.Settings}>
+ {(isAllowed) => (
+ <Button
+ variant="org"
+ size="sm"
+ onClick={() => {
+ handlePopUpOpen("addWorkflowIntegration");
+ }}
+ isDisabled={!isAllowed}
+ >
+ <Plus />
+ Add integration
+ </Button>
)}
- {!isWorkflowIntegrationsLoading &&
- workflowIntegrations &&
- workflowIntegrations.length === 0 && (
- <Tr>
- <Td colSpan={5}>
- <EmptyState title="No workflow integrations found" icon={faGear} />
- </Td>
- </Tr>
- )}
- {workflowIntegrations?.map((workflowIntegration) => (
- <Tr key={workflowIntegration.id}>
- <Td className="flex max-w-xs items-center gap-2 overflow-hidden text-ellipsis hover:overflow-auto hover:break-all">
- {workflowIntegration.integration === WorkflowIntegrationPlatform.SLACK ? (
- <BsSlack />
- ) : (
- <BsMicrosoftTeams />
- )}
- <div className="capitalize">
- {workflowIntegration.integration.replaceAll("-", " ")}
- </div>
- {workflowIntegration.description && (
- <Tooltip content={workflowIntegration.description}>
- <FontAwesomeIcon icon={faInfoCircle} className="text-gray-400" size="sm" />
- </Tooltip>
- )}
- </Td>
- <Td>{workflowIntegration.slug}</Td>
- <Td>{renderStatus(workflowIntegration.status)}</Td>
- <Td>
- <DropdownMenu>
- <DropdownMenuTrigger asChild className="rounded-lg">
- <div className="flex justify-end hover:text-primary-400 data-[state=open]:text-primary-400">
- <FontAwesomeIcon size="sm" icon={faEllipsis} />
+ </OrgPermissionCan>
+ </CardAction>
+ </CardHeader>
+ <CardContent>
+ {!isWorkflowIntegrationsLoading && workflowIntegrations?.length === 0 ? (
+ <Empty className="border">
+ <EmptyHeader>
+ <EmptyTitle>No workflow integrations connected</EmptyTitle>
+ <EmptyDescription>
+ Connect Slack or Microsoft Teams to enable notification and approval workflows.
+ </EmptyDescription>
+ </EmptyHeader>
+ </Empty>
+ ) : (
+ <Table>
+ <TableHeader>
+ <TableRow>
+ <TableHead className="w-1/3">Provider</TableHead>
+ <TableHead>Alias</TableHead>
+ <TableHead>Status</TableHead>
+ <TableHead className="w-px text-right" aria-label="Actions" />
+ </TableRow>
+ </TableHeader>
+ <TableBody>
+ {isWorkflowIntegrationsLoading &&
+ Array.from({ length: 2 }).map((_, idx) => (
+ // eslint-disable-next-line react/no-array-index-key
+ <TableRow key={`workflow-integration-skeleton-${idx}`}>
+ <TableCell colSpan={4}>
+ <Skeleton className="h-5 w-full" />
+ </TableCell>
+ </TableRow>
+ ))}
+ {!isWorkflowIntegrationsLoading &&
+ workflowIntegrations?.map((workflowIntegration) => (
+ <TableRow key={workflowIntegration.id}>
+ <TableCell>
+ <div className="flex items-center gap-2">
+ {workflowIntegration.integration === WorkflowIntegrationPlatform.SLACK ? (
+ <BsSlack />
+ ) : (
+ <BsMicrosoftTeams />
+ )}
+ <span className="capitalize">
+ {workflowIntegration.integration.replaceAll("-", " ")}
+ </span>
+ {workflowIntegration.description && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <span>
+ <Info className="size-3.5 text-muted" />
+ </span>
+ </TooltipTrigger>
+ <TooltipContent>{workflowIntegration.description}</TooltipContent>
+ </Tooltip>
+ )}
</div>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="start" className="p-1">
- <DropdownMenuItem
- onClick={(e) => {
- e.stopPropagation();
-
- handlePopUpOpen("integrationDetails", {
- id: workflowIntegration.id,
- platform: workflowIntegration.integration
- });
- }}
- >
- More details
- </DropdownMenuItem>
-
- {workflowIntegration.integration === WorkflowIntegrationPlatform.SLACK && (
- <OrgPermissionCan
- I={OrgPermissionActions.Create}
- an={OrgPermissionSubjects.Settings}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- disabled={!isAllowed}
- className={twMerge(
- !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
- )}
- onClick={async (e) => {
- e.stopPropagation();
-
- await triggerSlackReinstall(workflowIntegration.id);
- }}
+ </TableCell>
+ <TableCell className="max-w-0">
+ <p className="truncate">{workflowIntegration.slug}</p>
+ </TableCell>
+ <TableCell>{renderStatus(workflowIntegration.status)}</TableCell>
+ <TableCell>
+ <div className="flex items-center justify-end">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label={`Actions for integration ${workflowIntegration.slug}`}
>
- Reinstall
- </DropdownMenuItem>
- )}
- </OrgPermissionCan>
- )}
-
- {workflowIntegration.integration ===
- WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
- <OrgPermissionCan
- I={OrgPermissionActions.Edit}
- an={OrgPermissionSubjects.Settings}
- >
- {(isAllowed) => (
+ <MoreHorizontal />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-56">
<DropdownMenuItem
- disabled={!isAllowed}
- className={twMerge(
- !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
- )}
- onClick={async (e) => {
- e.stopPropagation();
-
- await triggerMicrosoftTeamsInstallationStatusCheck(
- workflowIntegration.id
- );
- }}
+ onClick={() =>
+ handlePopUpOpen("integrationDetails", {
+ id: workflowIntegration.id,
+ platform: workflowIntegration.integration
+ })
+ }
>
- Check Installation Status
+ <Info />
+ View details
</DropdownMenuItem>
- )}
- </OrgPermissionCan>
- )}
-
- <OrgPermissionCan
- I={OrgPermissionActions.Delete}
- an={OrgPermissionSubjects.Settings}
- >
- {(isAllowed) => (
- <DropdownMenuItem
- disabled={!isAllowed}
- className={twMerge(
- !isAllowed && "pointer-events-none cursor-not-allowed opacity-50"
+ {workflowIntegration.integration ===
+ WorkflowIntegrationPlatform.SLACK && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Create}
+ an={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ isDisabled={!isAllowed}
+ onClick={() => triggerSlackReinstall(workflowIntegration.id)}
+ >
+ <RotateCcw />
+ Reinstall
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
)}
- onClick={(e) => {
- e.stopPropagation();
-
- handlePopUpOpen("removeIntegration", {
- id: workflowIntegration.id,
- slug: workflowIntegration.slug,
- platform: workflowIntegration.integration
- });
- }}
- >
- Delete
- </DropdownMenuItem>
- )}
- </OrgPermissionCan>
- </DropdownMenuContent>
- </DropdownMenu>
- </Td>
- </Tr>
- ))}
- </TBody>
- </Table>
- </TableContainer>
+ {workflowIntegration.integration ===
+ WorkflowIntegrationPlatform.MICROSOFT_TEAMS && (
+ <OrgPermissionCan
+ I={OrgPermissionActions.Edit}
+ an={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ isDisabled={!isAllowed}
+ onClick={() =>
+ triggerMicrosoftTeamsInstallationStatusCheck(
+ workflowIntegration.id
+ )
+ }
+ >
+ <ShieldCheck />
+ Check installation status
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ )}
+ <OrgPermissionCan
+ I={OrgPermissionActions.Delete}
+ an={OrgPermissionSubjects.Settings}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ variant="danger"
+ isDisabled={!isAllowed}
+ onClick={() =>
+ handlePopUpOpen("removeIntegration", {
+ id: workflowIntegration.id,
+ slug: workflowIntegration.slug,
+ platform: workflowIntegration.integration
+ })
+ }
+ >
+ <Trash2 />
+ Delete
+ </DropdownMenuItem>
+ )}
+ </OrgPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </TableCell>
+ </TableRow>
+ ))}
+ </TableBody>
+ </Table>
+ )}
+ </CardContent>
<AddWorkflowIntegrationForm
isOpen={popUp.addWorkflowIntegration.isOpen}
onToggle={(state) => handlePopUpToggle("addWorkflowIntegration", state)}
@@ -303,14 +340,53 @@ export const OrgWorkflowIntegrationTab = withPermission(
id={popUp.integrationDetails?.data?.id}
onOpenChange={(state) => handlePopUpToggle("integrationDetails", state)}
/>
- <DeleteActionModal
- isOpen={popUp.removeIntegration.isOpen}
- title={`Are you sure you want to remove ${popUp?.removeIntegration?.data?.slug}?`}
- onChange={(isOpen) => handlePopUpToggle("removeIntegration", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={handleRemoveIntegration}
- />
- </div>
+ <AlertDialog
+ open={popUp.removeIntegration.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("removeIntegration", isOpen);
+ if (!isOpen) setDeleteConfirmation("");
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogMedia>
+ <Trash2 />
+ </AlertDialogMedia>
+ <AlertDialogTitle>
+ Delete integration &quot;{removeIntegrationData?.slug}&quot;?
+ </AlertDialogTitle>
+ <AlertDialogDescription>
+ Projects using this integration will stop sending notifications to it. This cannot
+ be undone.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <div className="w-full">
+ <p className="mb-2 text-sm text-muted">
+ Type {removeIntegrationData?.slug ?? ""} to confirm.
+ </p>
+ <Input
+ value={deleteConfirmation}
+ onChange={(e) => setDeleteConfirmation(e.target.value)}
+ placeholder={removeIntegrationData?.slug ?? ""}
+ aria-label="Confirm integration alias"
+ />
+ </div>
+ <AlertDialogFooter>
+ <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <Button
+ variant="danger"
+ size="sm"
+ onClick={handleRemoveIntegration}
+ isDisabled={
+ !removeIntegrationData?.slug || deleteConfirmation !== removeIntegrationData.slug
+ }
+ >
+ Delete
+ </Button>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
+ </Card>
);
},
{ action: OrgPermissionActions.Read, subject: OrgPermissionSubjects.Settings }
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx
index 5ce8652971..035b8404b6 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgWorkflowIntegrationTab/SlackIntegrationForm.tsx
@@ -2,10 +2,19 @@ import { useEffect } from "react";
import { Controller, useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import axios from "axios";
+import { ChevronLeft } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
-import { Button, FormControl, Input } from "@app/components/v2";
+import {
+ Button,
+ DialogClose,
+ DialogFooter,
+ Field,
+ FieldError,
+ FieldLabel,
+ Input
+} from "@app/components/v3";
import { useOrganization } from "@app/context";
import { useToggle } from "@app/hooks";
import {
@@ -18,6 +27,7 @@ import { slugSchema } from "@app/lib/schemas";
type Props = {
id?: string;
onClose: () => void;
+ onBack?: () => void;
};
const slackFormSchema = z.object({
@@ -27,7 +37,7 @@ const slackFormSchema = z.object({
type TSlackFormData = z.infer<typeof slackFormSchema>;
-export const SlackIntegrationForm = ({ id, onClose }: Props) => {
+export const SlackIntegrationForm = ({ id, onClose, onBack }: Props) => {
const {
control,
handleSubmit,
@@ -86,7 +96,7 @@ export const SlackIntegrationForm = ({ id, onClose }: Props) => {
onClose();
createNotification({
- text: "Successfully updated Slack integration",
+ text: "Updated Slack integration",
type: "success"
});
} else {
@@ -95,42 +105,62 @@ export const SlackIntegrationForm = ({ id, onClose }: Props) => {
};
return (
- <form onSubmit={handleSubmit(handleSlackFormSubmit)} autoComplete="off">
+ <form
+ onSubmit={handleSubmit(handleSlackFormSubmit)}
+ className="flex flex-col gap-4"
+ autoComplete="off"
+ >
<Controller
control={control}
name="slug"
render={({ field, fieldState: { error } }) => (
- <FormControl label="Alias" isRequired errorText={error?.message} isError={Boolean(error)}>
- <Input placeholder="" {...field} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="slack-integration-alias">
+ Alias <span className="text-danger">*</span>
+ </FieldLabel>
+ <Input id="slack-integration-alias" isError={Boolean(error)} {...field} />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
<Controller
control={control}
name="description"
render={({ field, fieldState: { error } }) => (
- <FormControl label="Description" errorText={error?.message} isError={Boolean(error)}>
- <Input placeholder="" {...field} />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="slack-integration-description">Description</FieldLabel>
+ <Input id="slack-integration-description" isError={Boolean(error)} {...field} />
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
{slackIntegration && (
- <FormControl label="Connected Slack workspace">
- <Input value={slackIntegration?.teamName} isReadOnly className="bg-white/[0.07]" />
- </FormControl>
+ <Field>
+ <FieldLabel htmlFor="slack-integration-workspace">Connected Slack workspace</FieldLabel>
+ <Input id="slack-integration-workspace" value={slackIntegration?.teamName} readOnly />
+ </Field>
)}
- <div className="mt-6 flex items-center space-x-4">
+ <DialogFooter>
+ {onBack && (
+ <Button type="button" variant="ghost" className="mr-auto" onClick={onBack}>
+ <ChevronLeft />
+ Back
+ </Button>
+ )}
+ <DialogClose asChild>
+ <Button type="button" variant="ghost">
+ Cancel
+ </Button>
+ </DialogClose>
<Button
type="submit"
- isLoading={isSubmitting || isConnectLoading}
+ variant="org"
+ isPending={isSubmitting || isConnectLoading}
isDisabled={!isDirty || isConnectLoading || isSubmitting}
>
{slackIntegration ? "Save" : "Connect Slack"}
</Button>
- <Button variant="outline_bg" onClick={onClose}>
- Cancel
- </Button>
- </div>
+ </DialogFooter>
</form>
);
};