diff --git a/app/components/IntegrationCard.tsx b/app/components/IntegrationCard.tsx new file mode 100644 index 0000000000..53eddf9102 --- /dev/null +++ b/app/components/IntegrationCard.tsx @@ -0,0 +1,122 @@ +import * as React from "react"; +import styled, { useTheme } from "styled-components"; +import Icon from "@shared/components/Icon"; +import Squircle from "@shared/components/Squircle"; +import { s, hover, ellipsis } from "@shared/styles"; +import Button from "~/components/ActionButton"; + +export type Integration = { + id: string; + name: string; + icon?: string; + description: string; + isActive: boolean; +}; + +type Props = { + integration: Integration; + onInstall: (id: string) => void; + onConfigure: (id: string) => void; +}; + +const IntegrationCard: React.FC = ({ + integration, + onInstall, + onConfigure, +}) => { + const theme = useTheme(); + + return ( + + + {integration.icon ? ( + + + + ) : ( + + + + )} + + + {integration.name} + {integration.description} + +
+ + {integration.isActive ? "isActive" : "Not isActive"} + + {integration.isActive ? ( + onConfigure(integration.id)}> + Configure + + ) : ( + onInstall(integration.id)}> + Install + + )} +
+
+ ); +}; + +export default IntegrationCard; + +const Card = styled.div` + display: flex; + flex-direction: column; + padding: 12px; + width: 200px; + height: 220px; + background: ${s("background")}; + border: 1px solid ${s("inputBorder")}; + border-radius: 8px; + transition: box-shadow 200ms ease; + cursor: pointer; + + &: ${hover} { + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + } +`; + +const IconWrapper = styled.div` + margin-bottom: 12px; +`; + +const Content = styled.div` + flex: 1; + min-width: 0; +`; + +const Name = styled.h3` + margin: 0; + font-size: 16px; + color: ${s("text")}; + ${ellipsis()} +`; + +const Description = styled.p` + margin: 4px 0 0; + font-size: 14px; + color: ${s("textTertiary")}; + ${ellipsis()} +`; + +const Footer = styled.div` + display: flex; + align-items: center; + justify-content: space-between; + margin-top: 16px; +`; + +const Status = styled.span<{ isActive: boolean }>` + font-size: 12px; + color: ${(props) => + props.isActive ? props.theme.success : props.theme.danger}; +`; + +const ActionButton = styled(Button)` + padding: 4px 8px; + font-size: 14px; +`; diff --git a/app/hooks/useSettingsConfig.ts b/app/hooks/useSettingsConfig.ts index e564103dc7..99cf67f35a 100644 --- a/app/hooks/useSettingsConfig.ts +++ b/app/hooks/useSettingsConfig.ts @@ -17,6 +17,7 @@ import { import React, { ComponentProps } from "react"; import { useTranslation } from "react-i18next"; import { integrationSettingsPath } from "@shared/utils/routeHelpers"; +import { Integrations } from "~/scenes/Settings/Integrations"; import ZapierIcon from "~/components/Icons/ZapierIcon"; import { Hook, PluginManager } from "~/utils/PluginManager"; import isCloudHosted from "~/utils/isCloudHosted"; @@ -26,6 +27,7 @@ import { useComputed } from "./useComputed"; import useCurrentTeam from "./useCurrentTeam"; import useCurrentUser from "./useCurrentUser"; import usePolicy from "./usePolicy"; +import useStores from "./useStores"; const ApiKeys = lazy(() => import("~/scenes/Settings/ApiKeys")); const PersonalApiKeys = lazy(() => import("~/scenes/Settings/PersonalApiKeys")); @@ -50,14 +52,20 @@ export type ConfigItem = { component: React.ComponentType; enabled: boolean; group: string; + isActive?: boolean; }; const useSettingsConfig = () => { + const { integrations } = useStores(); const user = useCurrentUser(); const team = useCurrentTeam(); const can = usePolicy(team); const { t } = useTranslation(); + React.useEffect(() => { + void integrations.fetchAll(); + }, [integrations]); + const config = useComputed(() => { const items: ConfigItem[] = [ // Account @@ -183,6 +191,15 @@ const useSettingsConfig = () => { group: t("Integrations"), icon: ZapierIcon, }, + { + name: "All Integrations", + path: integrationSettingsPath("all"), + component: Integrations, + enabled: true, + group: t("Integrations"), + icon: ZapierIcon, + isActive: true, + }, ]; // Plugins @@ -203,13 +220,20 @@ const useSettingsConfig = () => { ? plugin.value.enabled(team, user) : can.update, icon: plugin.value.icon, + isActive: integrations.orderedData.some( + (integration) => + integration.service.toLowerCase() === plugin.name.toLowerCase() + ), } as ConfigItem); }); return items; }, [t, can.createApiKey, can.update, can.createImport, can.createExport]); - return config.filter((item) => item.enabled); + return config.filter( + (item) => + item.enabled && (item.group === "Integrations" ? item.isActive : true) + ); }; export default useSettingsConfig; diff --git a/app/scenes/Settings/Integrations.tsx b/app/scenes/Settings/Integrations.tsx new file mode 100644 index 0000000000..8903f0e76c --- /dev/null +++ b/app/scenes/Settings/Integrations.tsx @@ -0,0 +1,10 @@ +import React from "react"; + +export function Integrations() { + return ( +
+

Integrations

+

Integrations settings will be available here.

+
+ ); +}