Skip to content

Commit 5eb2bf7

Browse files
committed
fix: connection badges and triggers copy buttons display
1 parent 5881a65 commit 5eb2bf7

File tree

6 files changed

+46
-40
lines changed

6 files changed

+46
-40
lines changed

src/components/molecules/connectionTableStatus.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import { ConnectionStatusType } from "@type/models";
99
export const ConnectionTableStatus = ({ status }: { status: ConnectionStatusType }) => {
1010
const { t } = useTranslation("tabs");
1111
const connectionTableStatusClass = {
12-
[ConnectionStatus.error]: "text-red",
13-
[ConnectionStatus.ok]: "text-green-800",
14-
[ConnectionStatus.unspecified]: "text-blue-500",
15-
[ConnectionStatus.warning]: "text-yellow-500",
12+
[ConnectionStatus.error]: "text-red hover:bg-red/10",
13+
[ConnectionStatus.ok]: "text-green-800 hover:bg-green-800/10",
14+
[ConnectionStatus.unspecified]: "text-blue-500 hover:bg-blue-500/10",
15+
[ConnectionStatus.warning]: "text-yellow-500 hover:bg-yellow-500/10",
1616
};
17-
const baseClass = cn("inline", connectionTableStatusClass[ConnectionStatus[status]]);
17+
const baseClass = cn(
18+
"flex w-[6.8rem] items-center justify-center rounded-md border border-gray-800 px-2 py-0.5 text-xs text-white",
19+
connectionTableStatusClass[ConnectionStatus[status]]
20+
);
1821
const statusName = t(`connections.table.statuses.${status}`);
1922

2023
return (

src/components/molecules/copyButton.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ export const CopyButton = forwardRef<
2020
{
2121
ariaLabel?: string;
2222
buttonText?: string;
23+
buttonTextClassName?: string;
2324
className?: string;
2425
dataTestId?: string;
2526
iconClassName?: string;
27+
id?: string;
2628
size?: Extract<SystemSizes, "xs" | "sm" | "md">;
2729
successMessage?: string;
2830
tabIndex?: number;
@@ -42,6 +44,8 @@ export const CopyButton = forwardRef<
4244
text,
4345
title,
4446
buttonText,
47+
buttonTextClassName,
48+
id,
4549
},
4650
ref
4751
) => {
@@ -87,11 +91,13 @@ export const CopyButton = forwardRef<
8791

8892
const ariaLabelText = ariaLabel || t("copyButtonText", { text: ariaLabel }) || "";
8993
const titleText = t("copyButtonTextTitle", { text: title }) || ariaLabelText;
94+
const buttonTextClass = cn("text-white", buttonTextClassName);
9095
return (
9196
<Button
9297
ariaLabel={ariaLabelText}
9398
className={copyButtonStyle}
9499
data-testid={dataTestId}
100+
id={id}
95101
onClick={(event) => {
96102
event.stopPropagation();
97103
copyTextToClipboard(text);
@@ -103,7 +109,7 @@ export const CopyButton = forwardRef<
103109
valueText={text}
104110
>
105111
<CopyIcon className={copyButtonIconStyle} />
106-
{buttonText ? <div className="text-white">{buttonText}</div> : null}
112+
{buttonText ? <div className={buttonTextClass}>{buttonText}</div> : null}
107113
</Button>
108114
);
109115
}

src/components/organisms/configuration/connections/connections.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ export const Connections = ({ isLoading }: ConnectionsProps) => {
169169
const items: ConnectionItem[] = (connections || []).map((connection) => ({
170170
id: connection.connectionId,
171171
name: connection.name || connection.integrationId || "",
172-
errorMessage: connection.status === "ok" ? undefined : connection.statusInfoMessage,
172+
statusInfoMessage: connection.statusInfoMessage,
173+
status: connection.status,
173174
icon: connection.logo,
174175
integration: connection.integrationUniqueName as (typeof Integrations)[keyof typeof Integrations],
175176
}));

src/components/organisms/configuration/connectionsSectionList.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ConnectionsSectionListProps } from "@interfaces/components";
66
import { cn, generateItemIds } from "@src/utilities";
77

88
import { Button, IconSvg } from "@components/atoms";
9-
import { Accordion, AddButton } from "@components/molecules";
9+
import { Accordion, AddButton, ConnectionTableStatus } from "@components/molecules";
1010
import { PopoverContent, PopoverTrigger, PopoverWrapper } from "@components/molecules/popover";
1111

1212
import { ChevronDownIcon, ChevronUpIcon, TrashIcon } from "@assets/image/icons";
@@ -48,8 +48,8 @@ export const ConnectionsSectionList = ({
4848
{isLoading ? (
4949
<SkeletonLoader />
5050
) : items && items.length > 0 ? (
51-
items.map(({ id, icon, name, errorMessage, integration }) => {
52-
const hasError = !!errorMessage;
51+
items.map(({ id, icon, name, statusInfoMessage, status, integration }) => {
52+
const shouldShowTooltip = status !== "ok" && statusInfoMessage;
5353
const configureButtonClass = cn(
5454
"group my-0.5 mr-1 size-5 border-none p-0 hover:bg-transparent"
5555
);
@@ -85,38 +85,33 @@ export const ConnectionsSectionList = ({
8585
className="ml-2.5 flex w-2/5 text-white sm:w-1/4 xl:w-1/2 2xl:w-[65%]"
8686
id={connectionDisplayId}
8787
>
88-
<ConnectionItemDisplay item={{ id, icon, name, integration }} />
88+
<ConnectionItemDisplay item={{ id, icon, name, status, integration }} />
8989
</div>
9090

9191
<div className="flex-1" />
9292

93-
{hasError ? (
93+
{shouldShowTooltip ? (
9494
<PopoverWrapper interactionType="hover" placement="top">
9595
<PopoverTrigger>
9696
<div className="flex w-fit items-center gap-0">
97-
<Button
98-
ariaLabel={`Fix connection error: ${errorMessage}`}
99-
className="w-[6.8rem] justify-center rounded-md border border-gray-800 bg-transparent px-2 py-0.5 text-xs text-error hover:brightness-90"
100-
onClick={() => actions.configure.onClick(id)}
101-
title={`Fix connection error: ${errorMessage}`}
102-
>
103-
Init
104-
</Button>
97+
<ConnectionTableStatus status={status} />
10598
</div>
10699
</PopoverTrigger>
107100
<PopoverContent className="h-6 max-w-md break-all border border-gray-700 bg-gray-900 p-1 text-xs text-white">
108-
Initialize connection
101+
{statusInfoMessage}
109102
</PopoverContent>
110103
</PopoverWrapper>
111-
) : null}
104+
) : (
105+
<ConnectionTableStatus status={status} />
106+
)}
112107
<div className="relative z-10 flex items-center gap-1" id={actionsContainerId}>
113108
{actions.showEvents ? (
114109
<PopoverWrapper interactionType="hover" placement="top">
115110
<PopoverTrigger>
116111
<Button
117112
ariaLabel={actions.showEvents.ariaLabel}
118113
className="group mx-1 size-6 border-none p-1 hover:bg-transparent"
119-
disabled={hasError}
114+
disabled={status !== "ok"}
120115
id={showEventsButtonId}
121116
onClick={(e) => {
122117
e.stopPropagation();

src/components/organisms/configuration/triggersSectionList.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export const TriggersSectionList = ({
2525
accordionKey,
2626
isLoading,
2727
}: TriggersSectionListProps) => {
28+
const copyButtonClassName =
29+
"group flex h-6 w-[6.8rem] items-center justify-center rounded-md border border-gray-800 bg-transparent stroke-white px-2 py-0.5 hover:bg-transparent hover:stroke-green-800";
30+
const copyButtonTextClassName = "text-xs text-white group-hover:text-green-800";
2831
return (
2932
<Accordion
3033
accordionKey={accordionKey}
@@ -95,22 +98,18 @@ export const TriggersSectionList = ({
9598
<PopoverWrapper interactionType="hover" placement="top">
9699
<PopoverTrigger>
97100
<div className="flex items-center gap-0">
98-
<span
99-
className="flex h-6 w-[6.8rem] items-center justify-center rounded-md border border-gray-800 bg-transparent px-2 py-0.5 text-xs text-white hover:brightness-90"
100-
id={webhookUrlButtonId}
101-
title={webhookUrl}
102-
>
103-
<CopyButton
104-
ariaLabel={`Copy ${name} webhook URL`}
105-
className="stroke-white hover:bg-transparent hover:stroke-green-800"
106-
dataTestId={`copy-${name}-webhook-url`}
107-
iconClassName="stroke-[0.5]"
108-
size="xs"
109-
text={webhookUrl}
110-
title={`Copy ${name} webhook URL`}
111-
/>
112-
URL
113-
</span>
101+
<CopyButton
102+
ariaLabel={`Copy ${name} webhook URL`}
103+
buttonText="URL"
104+
buttonTextClassName={copyButtonTextClassName}
105+
className={copyButtonClassName}
106+
dataTestId={`copy-${name}-webhook-url`}
107+
iconClassName="stroke-[0.5]"
108+
id={webhookUrlButtonId! as string}
109+
size="xs"
110+
text={webhookUrl}
111+
title={`Copy ${name} webhook URL`}
112+
/>
114113
</div>
115114
</PopoverTrigger>
116115
<PopoverContent className="max-w-md break-all border border-gray-700 bg-gray-900 p-1 text-xs text-white">

src/interfaces/components/configurationSection.interface.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from "react";
33
import { FrontendProjectValidationProps } from ".";
44
import { Integrations } from "@src/enums/components";
55
import { ProjectValidationLevel } from "@src/types";
6+
import { ConnectionStatusType } from "@src/types/models";
67

78
export interface VariableItem {
89
description?: string;
@@ -15,7 +16,8 @@ export interface VariableItem {
1516
export interface ConnectionItem {
1617
id: string;
1718
name: string;
18-
errorMessage?: string;
19+
statusInfoMessage?: string;
20+
status: ConnectionStatusType;
1921
icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
2022
integration: (typeof Integrations)[keyof typeof Integrations];
2123
}

0 commit comments

Comments
 (0)