1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

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)
This commit is contained in:
Nuno Góis 2024-03-05 08:16:44 +00:00 committed by GitHub
parent 095b6eca84
commit de5a0f2825
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 72 additions and 29 deletions

View File

@ -101,7 +101,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
condition={isEnterprise() && signalsEnabled} condition={isEnterprise() && signalsEnabled}
show={ show={
<IntegrationCard <IntegrationCard
icon='webhook' icon='signals'
title='Signals' title='Signals'
description='Signal endpoints allow third-party services to send signals to Unleash.' description='Signal endpoints allow third-party services to send signals to Unleash.'
link='/integrations/signals' link='/integrations/signals'

View File

@ -82,7 +82,7 @@ export const ConfiguredIntegrations: VFC<ConfiguredIntegrationsProps> = ({
show={ show={
<IntegrationCard <IntegrationCard
variant='stacked' variant='stacked'
icon='webhook' icon='signals'
title='Signals' title='Signals'
description={`${ description={`${
signalEndpoints.length signalEndpoints.length

View File

@ -1,8 +1,8 @@
import { Avatar, styled } from '@mui/material'; import { ReactNode } from 'react';
import { Avatar, Icon, styled } from '@mui/material';
import { DeviceHub } from '@mui/icons-material'; import { DeviceHub } from '@mui/icons-material';
import { formatAssetPath } from 'utils/formatPath'; import { formatAssetPath } from 'utils/formatPath';
import { capitalizeFirst } from 'utils/capitalizeFirst'; import { capitalizeFirst } from 'utils/capitalizeFirst';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
import slackIcon from 'assets/icons/slack.svg'; import slackIcon from 'assets/icons/slack.svg';
import jiraCommentIcon from 'assets/icons/jira-comment.svg'; import jiraCommentIcon from 'assets/icons/jira-comment.svg';
@ -37,12 +37,32 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({
overflow: 'hidden', overflow: 'hidden',
width: theme.spacing(4), width: theme.spacing(4),
height: 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 = <StyledSignalsIcon>sensors</StyledSignalsIcon>;
export const SignalsIcon = () => signalsIcon;
const integrations: Record< const integrations: Record<
string, string,
{ {
icon: string; icon: string | ReactNode;
title: string; title: string;
} }
> = { > = {
@ -67,24 +87,41 @@ const integrations: Record<
react: { title: 'React', icon: react }, react: { title: 'React', icon: react },
ruby: { title: 'Ruby', icon: ruby }, ruby: { title: 'Ruby', icon: ruby },
rust: { title: 'Rust', icon: rust }, rust: { title: 'Rust', icon: rust },
signals: {
title: 'Signals',
icon: signalsIcon,
},
svelte: { title: 'Svelte', icon: svelte }, svelte: { title: 'Svelte', icon: svelte },
vue: { title: 'Vue', icon: vue }, vue: { title: 'Vue', icon: vue },
}; };
export const IntegrationIcon = ({ name }: IIntegrationIconProps) => ( export const IntegrationIcon = ({ name }: IIntegrationIconProps) => {
<ConditionallyRender const integration = integrations[name];
condition={Object.keys(integrations).includes(name)}
show={() => ( if (!integration) {
<StyledAvatar return (
src={formatAssetPath(integrations[name].icon)}
alt={`${capitalizeFirst(integrations[name].title)} icon`}
variant='rounded'
/>
)}
elseShow={() => (
<StyledAvatar variant='rounded'> <StyledAvatar variant='rounded'>
<DeviceHub /> <DeviceHub />
</StyledAvatar> </StyledAvatar>
)} );
/> }
);
if (typeof integration.icon === 'string') {
return (
<StyledAvatar
src={formatAssetPath(integration.icon)}
alt={`${capitalizeFirst(integration.title)} icon`}
variant='rounded'
/>
);
}
return (
<StyledAvatar
alt={`${capitalizeFirst(integration.title)} icon`}
variant='rounded'
>
{integration.icon}
</StyledAvatar>
);
};

View File

@ -2,11 +2,11 @@ import { Avatar, Box, Link, styled } from '@mui/material';
import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell';
import { IActionSet } from 'interfaces/action'; import { IActionSet } from 'interfaces/action';
import { ISignalEndpoint } from 'interfaces/signal'; import { ISignalEndpoint } from 'interfaces/signal';
import webhooksIcon from 'assets/icons/webhooks.svg';
import { Link as RouterLink } from 'react-router-dom'; import { Link as RouterLink } from 'react-router-dom';
import { ComponentType } from 'react'; import { ComponentType } from 'react';
import { wrapperStyles } from 'component/common/Table/cells/LinkCell/LinkCell.styles'; 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)({ const StyledCell = styled(Box)({
display: 'flex', display: 'flex',
@ -18,6 +18,7 @@ const StyledIcon = styled(Avatar)(({ theme }) => ({
overflow: 'hidden', overflow: 'hidden',
width: theme.spacing(3), width: theme.spacing(3),
height: theme.spacing(3), height: theme.spacing(3),
fontSize: theme.fontSizes.mainHeader,
})); }));
const StyledLink = styled(Link)<{ const StyledLink = styled(Link)<{
@ -39,21 +40,26 @@ export const ProjectActionsTriggerCell = ({
action, action,
signalEndpoints, signalEndpoints,
}: IProjectActionsTriggerCellProps) => { }: IProjectActionsTriggerCellProps) => {
const { sourceId } = action.match; const { sourceId, source } = action.match;
const trigger = signalEndpoints.find(({ id }) => id === sourceId); const trigger = signalEndpoints.find(({ id }) => id === sourceId);
if (!trigger) { if (!trigger) {
return <TextCell>No trigger</TextCell>; return <TextCell>No trigger</TextCell>;
} }
const sourceIcon =
source === 'signal-endpoint' ? (
<HtmlTooltip title='Signal endpoint' arrow>
<StyledIcon alt='Signal endpoint' variant='rounded'>
<SignalsIcon />
</StyledIcon>
</HtmlTooltip>
) : null;
return ( return (
<TextCell> <TextCell>
<StyledCell> <StyledCell>
<StyledIcon {sourceIcon}
src={formatAssetPath(webhooksIcon)}
alt='Signal endpoint'
variant='rounded'
/>
<StyledLink <StyledLink
component={RouterLink} component={RouterLink}
to='/integrations/signals' to='/integrations/signals'

View File

@ -121,7 +121,7 @@ export const SignalEndpointsSignalsModal = ({
columns={[ columns={[
{ {
header: 'Date', header: 'Date',
maxWidth: 180, maxWidth: 220,
cell: ({ createdAt }) => cell: ({ createdAt }) =>
formatDateYMDHMS( formatDateYMDHMS(
createdAt, createdAt,
@ -130,7 +130,7 @@ export const SignalEndpointsSignalsModal = ({
}, },
{ {
header: 'Token', header: 'Token',
maxWidth: 350, maxWidth: 300,
cell: ({ tokenName }) => tokenName, cell: ({ tokenName }) => tokenName,
}, },
]} ]}