From de5a0f282534f9c1090844627e1fa6ac0dbea171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Tue, 5 Mar 2024 08:16:44 +0000 Subject: [PATCH] chore: add new signals icon instead of webhook icon (#6427) https://linear.app/unleash/issue/2-2002/add-new-signals-icon-instead-of-using-the-webhooks-icon Adds a new icon for signals, instead of using the same icon as webhooks. Includes some slight refactoring. ![image](https://github.com/Unleash/unleash/assets/14320932/51402a4b-99c5-4a09-9c6c-01f87ca4651c) ![image](https://github.com/Unleash/unleash/assets/14320932/c80e308b-a1f2-4a4a-bfc4-2ed2cbb59563) --- .../AvailableIntegrations.tsx | 2 +- .../ConfiguredIntegrations.tsx | 2 +- .../IntegrationIcon/IntegrationIcon.tsx | 71 ++++++++++++++----- .../ProjectActionsTriggerCell.tsx | 22 +++--- .../SignalEndpointsSignalsModal.tsx | 4 +- 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/frontend/src/component/integrations/IntegrationList/AvailableIntegrations/AvailableIntegrations.tsx b/frontend/src/component/integrations/IntegrationList/AvailableIntegrations/AvailableIntegrations.tsx index d7f44be1517a..1447804febce 100644 --- a/frontend/src/component/integrations/IntegrationList/AvailableIntegrations/AvailableIntegrations.tsx +++ b/frontend/src/component/integrations/IntegrationList/AvailableIntegrations/AvailableIntegrations.tsx @@ -101,7 +101,7 @@ export const AvailableIntegrations: VFC = ({ condition={isEnterprise() && signalsEnabled} show={ = ({ show={ ({ overflow: 'hidden', width: theme.spacing(4), height: theme.spacing(4), + fontSize: '28px', })); +const StyledCustomIcon = styled(Icon)({ + '&&&': { + display: 'flex', + height: '100%', + width: '100%', + justifyContent: 'center', + alignItems: 'center', + fontSize: 'inherit', + }, +}); + +const StyledSignalsIcon = styled(StyledCustomIcon)(({ theme }) => ({ + background: theme.palette.primary.main, + color: theme.palette.primary.contrastText, +})); + +const signalsIcon = sensors; +export const SignalsIcon = () => signalsIcon; + const integrations: Record< string, { - icon: string; + icon: string | ReactNode; title: string; } > = { @@ -67,24 +87,41 @@ const integrations: Record< react: { title: 'React', icon: react }, ruby: { title: 'Ruby', icon: ruby }, rust: { title: 'Rust', icon: rust }, + signals: { + title: 'Signals', + icon: signalsIcon, + }, svelte: { title: 'Svelte', icon: svelte }, vue: { title: 'Vue', icon: vue }, }; -export const IntegrationIcon = ({ name }: IIntegrationIconProps) => ( - ( - - )} - elseShow={() => ( +export const IntegrationIcon = ({ name }: IIntegrationIconProps) => { + const integration = integrations[name]; + + if (!integration) { + return ( - )} - /> -); + ); + } + + if (typeof integration.icon === 'string') { + return ( + + ); + } + + return ( + + {integration.icon} + + ); +}; diff --git a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsTriggerCell.tsx b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsTriggerCell.tsx index 9c0fdd134a46..6a54cd1c7767 100644 --- a/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsTriggerCell.tsx +++ b/frontend/src/component/project/Project/ProjectSettings/ProjectActions/ProjectActionsTable/ProjectActionsTriggerCell.tsx @@ -2,11 +2,11 @@ import { Avatar, Box, Link, styled } from '@mui/material'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import { IActionSet } from 'interfaces/action'; import { ISignalEndpoint } from 'interfaces/signal'; -import webhooksIcon from 'assets/icons/webhooks.svg'; import { Link as RouterLink } from 'react-router-dom'; import { ComponentType } from 'react'; import { wrapperStyles } from 'component/common/Table/cells/LinkCell/LinkCell.styles'; -import { formatAssetPath } from 'utils/formatPath'; +import { SignalsIcon } from 'component/integrations/IntegrationList/IntegrationIcon/IntegrationIcon'; +import { HtmlTooltip } from 'component/common/HtmlTooltip/HtmlTooltip'; const StyledCell = styled(Box)({ display: 'flex', @@ -18,6 +18,7 @@ const StyledIcon = styled(Avatar)(({ theme }) => ({ overflow: 'hidden', width: theme.spacing(3), height: theme.spacing(3), + fontSize: theme.fontSizes.mainHeader, })); const StyledLink = styled(Link)<{ @@ -39,21 +40,26 @@ export const ProjectActionsTriggerCell = ({ action, signalEndpoints, }: IProjectActionsTriggerCellProps) => { - const { sourceId } = action.match; + const { sourceId, source } = action.match; const trigger = signalEndpoints.find(({ id }) => id === sourceId); if (!trigger) { return No trigger; } + const sourceIcon = + source === 'signal-endpoint' ? ( + + + + + + ) : null; + return ( - + {sourceIcon} formatDateYMDHMS( createdAt, @@ -130,7 +130,7 @@ export const SignalEndpointsSignalsModal = ({ }, { header: 'Token', - maxWidth: 350, + maxWidth: 300, cell: ({ tokenName }) => tokenName, }, ]}