Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add new signals icon instead of webhook icon #6427

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const AvailableIntegrations: VFC<IAvailableIntegrationsProps> = ({
condition={isEnterprise() && signalsEnabled}
show={
<IntegrationCard
icon='webhook'
icon='signals'
title='Signals'
description='Signal endpoints allow third-party services to send signals to Unleash.'
link='/integrations/signals'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const ConfiguredIntegrations: VFC<ConfiguredIntegrationsProps> = ({
show={
<IntegrationCard
variant='stacked'
icon='webhook'
icon='signals'
title='Signals'
description={`${
signalEndpoints.length
Expand Down
Original file line number Diff line number Diff line change
@@ -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 { formatAssetPath } from 'utils/formatPath';
import { capitalizeFirst } from 'utils/capitalizeFirst';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

import slackIcon from 'assets/icons/slack.svg';
import jiraCommentIcon from 'assets/icons/jira-comment.svg';
Expand Down Expand Up @@ -37,12 +37,32 @@ const StyledAvatar = styled(Avatar)(({ theme }) => ({
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 = <StyledSignalsIcon>sensors</StyledSignalsIcon>;
export const SignalsIcon = () => signalsIcon;

const integrations: Record<
string,
{
icon: string;
icon: string | ReactNode;
title: string;
}
> = {
Expand All @@ -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) => (
<ConditionallyRender
condition={Object.keys(integrations).includes(name)}
show={() => (
<StyledAvatar
src={formatAssetPath(integrations[name].icon)}
alt={`${capitalizeFirst(integrations[name].title)} icon`}
variant='rounded'
/>
)}
elseShow={() => (
export const IntegrationIcon = ({ name }: IIntegrationIconProps) => {
const integration = integrations[name];

if (!integration) {
return (
<StyledAvatar variant='rounded'>
<DeviceHub />
</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>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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)<{
Expand All @@ -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 <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 (
<TextCell>
<StyledCell>
<StyledIcon
src={formatAssetPath(webhooksIcon)}
alt='Signal endpoint'
variant='rounded'
/>
{sourceIcon}
<StyledLink
component={RouterLink}
to='/integrations/signals'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const SignalEndpointsSignalsModal = ({
columns={[
{
header: 'Date',
maxWidth: 180,
maxWidth: 220,
cell: ({ createdAt }) =>
formatDateYMDHMS(
createdAt,
Expand All @@ -130,7 +130,7 @@ export const SignalEndpointsSignalsModal = ({
},
{
header: 'Token',
maxWidth: 350,
maxWidth: 300,
cell: ({ tokenName }) => tokenName,
},
]}
Expand Down
Loading