From a5f593d68dee1ec971fb9248cae317365cebfcfe Mon Sep 17 00:00:00 2001 From: Mahmoud Mohammed Ali Date: Thu, 24 Apr 2025 19:58:28 +0100 Subject: [PATCH] Integration page skeleton --- app/components/IntegrationCard.tsx | 116 +++++++++------------ app/components/Sidebar/Settings.tsx | 5 +- app/hooks/useSettingsConfig.ts | 5 +- app/scenes/Settings/Integrations.tsx | 67 +++++++++++- shared/i18n/locales/en_US/translation.json | 2 + 5 files changed, 118 insertions(+), 77 deletions(-) diff --git a/app/components/IntegrationCard.tsx b/app/components/IntegrationCard.tsx index 53eddf9102..f41c53f98f 100644 --- a/app/components/IntegrationCard.tsx +++ b/app/components/IntegrationCard.tsx @@ -1,87 +1,62 @@ 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; -}; +import { Link } from "react-router-dom"; +import styled from "styled-components"; +import { s, ellipsis } from "@shared/styles"; +import { ConfigItem } from "~/hooks/useSettingsConfig"; +import Flex from "./Flex"; type Props = { - integration: Integration; - onInstall: (id: string) => void; - onConfigure: (id: string) => void; + integration: ConfigItem; }; -const IntegrationCard: React.FC = ({ - integration, - onInstall, - onConfigure, -}) => { - const theme = useTheme(); - +function IntegrationCard({ integration }: Props) { + const actionText = integration.isActive ? "Configure" : "Install"; return ( - - - {integration.icon ? ( - - - - ) : ( - - - - )} - - + + + {integration.name} - {integration.description} + + + + {/* {integration.description} */} +
- - {integration.isActive ? "isActive" : "Not isActive"} + + {integration.isActive ? "Active" : "Not Active"} - {integration.isActive ? ( - onConfigure(integration.id)}> - Configure - - ) : ( - onInstall(integration.id)}> - Install - - )} + { + if (!integration.isActive) { + e.preventDefault(); + } + // Otherwise let the navigate to the configure route + }} + > + {actionText} +
); -}; +} export default IntegrationCard; +// — styled-components — // + const Card = styled.div` display: flex; flex-direction: column; padding: 12px; - width: 200px; - height: 220px; + width: 100%; + height: auto; 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; + cursor: default; `; const Content = styled.div` @@ -96,12 +71,12 @@ const Name = styled.h3` ${ellipsis()} `; -const Description = styled.p` - margin: 4px 0 0; - font-size: 14px; - color: ${s("textTertiary")}; - ${ellipsis()} -`; +// const Description = styled.p` +// margin: 4px 0 0; +// font-size: 14px; +// color: ${s("textTertiary")}; +// ${ellipsis()} +// `; const Footer = styled.div` display: flex; @@ -116,7 +91,14 @@ const Status = styled.span<{ isActive: boolean }>` props.isActive ? props.theme.success : props.theme.danger}; `; -const ActionButton = styled(Button)` +const ActionLink = styled(Link)` + display: inline-block; padding: 4px 8px; font-size: 14px; + background: ${s("brand")}; + color: ${s("white")}; + border-radius: 4px; + text-decoration: none; + text-align: center; + transition: background 150ms ease; `; diff --git a/app/components/Sidebar/Settings.tsx b/app/components/Sidebar/Settings.tsx index 1161c54ed9..d4f22f6eb8 100644 --- a/app/components/Sidebar/Settings.tsx +++ b/app/components/Sidebar/Settings.tsx @@ -27,7 +27,10 @@ function SettingsSidebar() { const { t } = useTranslation(); const history = useHistory(); const location = useLocation(); - const configs = useSettingsConfig(); + let configs = useSettingsConfig(); + configs = configs.filter((item) => + item.group === "Integrations" ? item.isActive : true + ); const groupedConfig = groupBy(configs, "group"); const returnToApp = React.useCallback(() => { diff --git a/app/hooks/useSettingsConfig.ts b/app/hooks/useSettingsConfig.ts index 99cf67f35a..53dbead7a3 100644 --- a/app/hooks/useSettingsConfig.ts +++ b/app/hooks/useSettingsConfig.ts @@ -230,10 +230,7 @@ const useSettingsConfig = () => { return items; }, [t, can.createApiKey, can.update, can.createImport, can.createExport]); - return config.filter( - (item) => - item.enabled && (item.group === "Integrations" ? item.isActive : true) - ); + return config.filter((item) => item.enabled); }; export default useSettingsConfig; diff --git a/app/scenes/Settings/Integrations.tsx b/app/scenes/Settings/Integrations.tsx index 8903f0e76c..dde3a6a407 100644 --- a/app/scenes/Settings/Integrations.tsx +++ b/app/scenes/Settings/Integrations.tsx @@ -1,10 +1,67 @@ -import React from "react"; +// app/scenes/Settings/Integrations.tsx + +import * as React from "react"; +import { Trans, useTranslation } from "react-i18next"; +import styled from "styled-components"; +import Icon from "@shared/components/Icon"; + +import Heading from "~/components/Heading"; + +import IntegrationCard from "~/components/IntegrationCard"; +import Scene from "~/components/Scene"; +import Text from "~/components/Text"; +import useSettingsConfig from "~/hooks/useSettingsConfig"; + +export type ConfigItem = { + name: string; + path: string; + icon: React.FC>; // not used directly here + component: React.ComponentType; + enabled: boolean; + group: string; + isActive?: boolean; +}; + +// six dummy integrations export function Integrations() { + const { t } = useTranslation(); + // const history = useHistory(); + let items = useSettingsConfig(); + items = items.filter((item) => item.group === "Integrations" && item.enabled); return ( -
-

Integrations

-

Integrations settings will be available here.

-
+ + {t("Integrations")} + + + Enable and configure third-party integrations to extend Outline’s + functionality. + + + + + {items.map((item) => ( + + ))} + + ); } + +const Grid = styled.div` + margin-top: 24px; + display: grid; + grid-template-columns: repeat(auto-fill); + gap: 20px; +`; diff --git a/shared/i18n/locales/en_US/translation.json b/shared/i18n/locales/en_US/translation.json index 69080e8369..5d06efb056 100644 --- a/shared/i18n/locales/en_US/translation.json +++ b/shared/i18n/locales/en_US/translation.json @@ -965,6 +965,8 @@ "Enterprise": "Enterprise", "Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.": "Quickly transfer your existing documents, pages, and files from other tools and services into {{appName}}. You can also drag and drop any HTML, Markdown, and text documents directly into Collections in the app.", "Recent imports": "Recent imports", + "Enable and configure third-party integrations to extend Outline’s functionality.": "Enable and configure third-party integrations to extend Outline’s functionality.", + "Connect your {{ name }} account": "Connect your {{ name }} account", "Could not load members": "Could not load members", "Everyone that has signed into {{appName}} is listed here. It’s possible that there are other users who have access through {{signinMethods}} but haven’t signed in yet.": "Everyone that has signed into {{appName}} is listed here. It’s possible that there are other users who have access through {{signinMethods}} but haven’t signed in yet.", "Receive a notification whenever a new document is published": "Receive a notification whenever a new document is published",