From ac072b282ebc0d6fae7120f8645839889fa07b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tha=C3=AFs=20Guigon?= Date: Wed, 20 Mar 2024 18:05:27 +0100 Subject: [PATCH 1/3] feat: add Active and Add integration card displays Closes #4541 --- .../SettingsIntegrationComponent.tsx | 53 +++++++++++++----- .../components/SettingsIntegrationGroup.tsx | 54 ++++++++++--------- .../constants/MockRemoteDatabases.ts | 10 ++++ .../constants/SettingsIntegrationRequest.ts | 2 +- .../constants/SettingsIntegrationWindmill.ts | 2 +- .../constants/SettingsIntegrationZapier.ts | 2 +- .../hooks/useSettingsIntegrationCategories.ts | 35 ++++++++++++ .../integrations/types/SettingsIntegration.ts | 7 ++- .../types/SettingsIntegrationCategory.ts | 2 +- .../utils/getSettingsIntegrationAll.ts | 44 +++++++++++++++ .../SettingsIntegrationDetail.tsx | 30 +++++------ .../integrations/SettingsIntegrations.tsx | 10 ++-- .../constants/SettingsIntegrationAll.ts | 26 --------- .../SettingsIntegrationCategories.ts | 12 ----- 14 files changed, 187 insertions(+), 102 deletions(-) create mode 100644 packages/twenty-front/src/modules/settings/integrations/constants/MockRemoteDatabases.ts rename packages/twenty-front/src/{pages => modules}/settings/integrations/constants/SettingsIntegrationRequest.ts (82%) rename packages/twenty-front/src/{pages => modules}/settings/integrations/constants/SettingsIntegrationWindmill.ts (81%) rename packages/twenty-front/src/{pages => modules}/settings/integrations/constants/SettingsIntegrationZapier.ts (93%) create mode 100644 packages/twenty-front/src/modules/settings/integrations/hooks/useSettingsIntegrationCategories.ts rename packages/twenty-front/src/{pages => modules}/settings/integrations/types/SettingsIntegration.ts (69%) rename packages/twenty-front/src/{pages => modules}/settings/integrations/types/SettingsIntegrationCategory.ts (64%) create mode 100644 packages/twenty-front/src/modules/settings/integrations/utils/getSettingsIntegrationAll.ts delete mode 100644 packages/twenty-front/src/pages/settings/integrations/constants/SettingsIntegrationAll.ts delete mode 100644 packages/twenty-front/src/pages/settings/integrations/constants/SettingsIntegrationCategories.ts diff --git a/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationComponent.tsx b/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationComponent.tsx index be6596f6d100..333ebef11e08 100644 --- a/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationComponent.tsx +++ b/packages/twenty-front/src/modules/settings/integrations/components/SettingsIntegrationComponent.tsx @@ -1,9 +1,13 @@ +import { useNavigate } from 'react-router-dom'; +import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { Pill } from 'twenty-ui'; -import { IconArrowUpRight, IconBolt } from '@/ui/display/icon'; +import { SettingsIntegration } from '@/settings/integrations/types/SettingsIntegration'; +import { IconArrowUpRight, IconBolt, IconPlus } from '@/ui/display/icon'; +import { Status } from '@/ui/display/status/components/Status'; import { Button } from '@/ui/input/button/components/Button'; -import { SettingsIntegration } from '~/pages/settings/integrations/types/SettingsIntegration'; +import { isDefined } from '~/utils/isDefined'; interface SettingsIntegrationComponentProps { integration: SettingsIntegration; @@ -19,6 +23,12 @@ const StyledContainer = styled.div` flex-direction: row; justify-content: space-between; padding: ${({ theme }) => theme.spacing(3)}; + + ${({ onClick }) => + isDefined(onClick) && + css` + cursor: pointer; + `} `; const StyledSection = styled.div` @@ -48,33 +58,52 @@ const StyledLogo = styled.img` export const SettingsIntegrationComponent = ({ integration, }: SettingsIntegrationComponentProps) => { - const openLinkInTab = (link: string) => { - window.open(link); - }; + const navigate = useNavigate(); + + const navigateToIntegrationPage = () => navigate(integration.link); + const openExternalLink = () => window.open(integration.link); return ( - + - {integration.to ? ( + {isDefined(integration.to) && ( <>
- ) : ( - <> )}
{integration.text}
{integration.type === 'Soon' ? ( + ) : integration.type === 'Active' ? ( + + ) : integration.type === 'Add' ? ( +