feat: create Integrations/IntegrationDetail page (#4574)
* feat: create Integrations/IntegrationDetail page Closes #4546 * docs: add Settings/Integrations/Integration Detail page stories * docs: add Settings/Billing page stories * refactor: move some Settings components to @/settings * refactor: move some Settings integrations components to @/settings/integrations
This commit is contained in:
@ -0,0 +1,19 @@
|
||||
import { Loader } from '@/ui/feedback/loader/components/Loader';
|
||||
import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder';
|
||||
import {
|
||||
AnimatedPlaceholderEmptyContainer,
|
||||
AnimatedPlaceholderEmptyTextContainer,
|
||||
AnimatedPlaceholderEmptyTitle,
|
||||
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled';
|
||||
|
||||
export const SettingsAccountLoader = () => (
|
||||
<AnimatedPlaceholderEmptyContainer>
|
||||
<AnimatedPlaceholder type="loadingAccounts" />
|
||||
<AnimatedPlaceholderEmptyTextContainer>
|
||||
<AnimatedPlaceholderEmptyTitle>
|
||||
Loading account(s)
|
||||
</AnimatedPlaceholderEmptyTitle>
|
||||
<Loader />
|
||||
</AnimatedPlaceholderEmptyTextContainer>
|
||||
</AnimatedPlaceholderEmptyContainer>
|
||||
);
|
||||
@ -0,0 +1,53 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { SettingsApiKeysFieldItemTableRow } from '@/settings/developers/components/SettingsApiKeysFieldItemTableRow';
|
||||
import { ApiFieldItem } from '@/settings/developers/types/api-key/ApiFieldItem';
|
||||
import { ApiKey } from '@/settings/developers/types/api-key/ApiKey';
|
||||
import { formatExpirations } from '@/settings/developers/utils/format-expiration';
|
||||
import { Table } from '@/spreadsheet-import/components/Table';
|
||||
import { TableBody } from '@/ui/layout/table/components/TableBody';
|
||||
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
||||
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
||||
|
||||
const StyledTableBody = styled(TableBody)`
|
||||
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
|
||||
`;
|
||||
|
||||
const StyledTableRow = styled(TableRow)`
|
||||
grid-template-columns: 312px 132px 68px;
|
||||
`;
|
||||
|
||||
export const SettingsApiKeysTable = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { records: apiKeys } = useFindManyRecords<ApiKey>({
|
||||
objectNameSingular: CoreObjectNameSingular.ApiKey,
|
||||
filter: { revokedAt: { is: 'NULL' } },
|
||||
});
|
||||
|
||||
return (
|
||||
<Table>
|
||||
<StyledTableRow>
|
||||
<TableHeader>Name</TableHeader>
|
||||
<TableHeader>Expiration</TableHeader>
|
||||
<TableHeader></TableHeader>
|
||||
</StyledTableRow>
|
||||
{!!apiKeys.length && (
|
||||
<StyledTableBody>
|
||||
{formatExpirations(apiKeys).map((fieldItem) => (
|
||||
<SettingsApiKeysFieldItemTableRow
|
||||
key={fieldItem.id}
|
||||
fieldItem={fieldItem as ApiFieldItem}
|
||||
onClick={() => {
|
||||
navigate(`/settings/developers/api-keys/${fieldItem.id}`);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</StyledTableBody>
|
||||
)}
|
||||
</Table>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,17 @@
|
||||
import { IconBook2 } from '@/ui/display/icon';
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
|
||||
export const SettingsReadDocumentationButton = () => {
|
||||
return (
|
||||
<Button
|
||||
title="Read documentation"
|
||||
variant="primary"
|
||||
accent="default"
|
||||
size="small"
|
||||
Icon={IconBook2}
|
||||
onClick={() => {
|
||||
window.open('https://docs.twenty.com');
|
||||
}}
|
||||
></Button>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,51 @@
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
||||
import { SettingsDevelopersWebhookTableRow } from '@/settings/developers/components/SettingsDevelopersWebhookTableRow';
|
||||
import { WebhookFieldItem } from '@/settings/developers/types/webhook/WebhookFieldItem';
|
||||
import { Table } from '@/ui/layout/table/components/Table';
|
||||
import { TableBody } from '@/ui/layout/table/components/TableBody';
|
||||
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
|
||||
import { TableRow } from '@/ui/layout/table/components/TableRow';
|
||||
|
||||
const StyledTableBody = styled(TableBody)`
|
||||
border-bottom: 1px solid ${({ theme }) => theme.border.color.light};
|
||||
`;
|
||||
|
||||
const StyledTableRow = styled(TableRow)`
|
||||
grid-template-columns: 444px 68px;
|
||||
`;
|
||||
|
||||
export const SettingsWebhooksTable = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { records: webhooks } = useFindManyRecords<WebhookFieldItem>({
|
||||
objectNameSingular: CoreObjectNameSingular.Webhook,
|
||||
});
|
||||
|
||||
return (
|
||||
<Table>
|
||||
<StyledTableRow>
|
||||
<TableHeader>Url</TableHeader>
|
||||
<TableHeader></TableHeader>
|
||||
</StyledTableRow>
|
||||
{!!webhooks.length && (
|
||||
<StyledTableBody>
|
||||
{webhooks.map((webhookFieldItem) => (
|
||||
<SettingsDevelopersWebhookTableRow
|
||||
key={webhookFieldItem.id}
|
||||
fieldItem={webhookFieldItem}
|
||||
onClick={() => {
|
||||
navigate(
|
||||
`/settings/developers/webhooks/${webhookFieldItem.id}`,
|
||||
);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</StyledTableBody>
|
||||
)}
|
||||
</Table>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,83 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { Pill } from 'twenty-ui';
|
||||
|
||||
import { IconArrowUpRight, IconBolt } from '@/ui/display/icon';
|
||||
import { Button } from '@/ui/input/button/components/Button';
|
||||
import { SettingsIntegration } from '~/pages/settings/integrations/types/SettingsIntegration';
|
||||
|
||||
interface SettingsIntegrationComponentProps {
|
||||
integration: SettingsIntegration;
|
||||
}
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
align-items: center;
|
||||
background: ${({ theme }) => theme.background.secondary};
|
||||
border: 1px solid ${({ theme }) => theme.border.color.medium};
|
||||
border-radius: ${({ theme }) => theme.border.radius.md};
|
||||
font-size: ${({ theme }) => theme.font.size.md};
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
padding: ${({ theme }) => theme.spacing(3)};
|
||||
`;
|
||||
|
||||
const StyledSection = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: ${({ theme }) => theme.spacing(3)};
|
||||
`;
|
||||
|
||||
const StyledIntegrationLogo = styled.div`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
color: ${({ theme }) => theme.border.color.strong};
|
||||
`;
|
||||
|
||||
const StyledSoonPill = styled(Pill)`
|
||||
padding: ${({ theme }) => theme.spacing(1)} ${({ theme }) => theme.spacing(2)};
|
||||
`;
|
||||
|
||||
const StyledLogo = styled.img`
|
||||
height: 24px;
|
||||
width: 24px;
|
||||
`;
|
||||
|
||||
export const SettingsIntegrationComponent = ({
|
||||
integration,
|
||||
}: SettingsIntegrationComponentProps) => {
|
||||
const openLinkInTab = (link: string) => {
|
||||
window.open(link);
|
||||
};
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledSection>
|
||||
<StyledIntegrationLogo>
|
||||
<StyledLogo src={integration.from.image} alt={integration.from.key} />
|
||||
{integration.to ? (
|
||||
<>
|
||||
<div>→</div>
|
||||
<StyledLogo src={integration.to.image} alt={integration.to.key} />
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</StyledIntegrationLogo>
|
||||
{integration.text}
|
||||
</StyledSection>
|
||||
{integration.type === 'Soon' ? (
|
||||
<StyledSoonPill label="Soon" />
|
||||
) : (
|
||||
<Button
|
||||
onClick={() => openLinkInTab(integration.link)}
|
||||
Icon={integration.type === 'Goto' ? IconArrowUpRight : IconBolt}
|
||||
title={integration.type === 'Goto' ? integration.linkText : 'Use'}
|
||||
size="small"
|
||||
/>
|
||||
)}
|
||||
</StyledContainer>
|
||||
);
|
||||
};
|
||||
@ -0,0 +1,60 @@
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { SettingsIntegrationComponent } from '@/settings/integrations/components/SettingsIntegrationComponent';
|
||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||
import { Section } from '@/ui/layout/section/components/Section';
|
||||
import { SettingsIntegrationCategory } from '~/pages/settings/integrations/types/SettingsIntegrationCategory';
|
||||
|
||||
interface SettingsIntegrationGroupProps {
|
||||
integrationGroup: SettingsIntegrationCategory;
|
||||
}
|
||||
|
||||
const StyledIntegrationGroupHeader = styled.div`
|
||||
align-items: start;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
`;
|
||||
|
||||
const StyledGroupLink = styled.div`
|
||||
align-items: start;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
font-size: ${({ theme }) => theme.font.size.md};
|
||||
gap: ${({ theme }) => theme.spacing(1)};
|
||||
cursor: pointer;
|
||||
`;
|
||||
|
||||
const StyledIntegrationsSection = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: ${({ theme }) => theme.spacing(4)};
|
||||
`;
|
||||
|
||||
export const SettingsIntegrationGroup = ({
|
||||
integrationGroup,
|
||||
}: SettingsIntegrationGroupProps) => {
|
||||
const openLinkInTab = (link: string) => {
|
||||
window.open(link);
|
||||
};
|
||||
return (
|
||||
<Section>
|
||||
<StyledIntegrationGroupHeader>
|
||||
<H2Title title={integrationGroup.title} />
|
||||
{integrationGroup.hyperlink && (
|
||||
<StyledGroupLink
|
||||
onClick={() => openLinkInTab(integrationGroup.hyperlink ?? '')}
|
||||
>
|
||||
<div>{integrationGroup.hyperlinkText}</div>
|
||||
<div>→</div>
|
||||
</StyledGroupLink>
|
||||
)}
|
||||
</StyledIntegrationGroupHeader>
|
||||
<StyledIntegrationsSection>
|
||||
{integrationGroup.integrations.map((integration) => {
|
||||
return <SettingsIntegrationComponent integration={integration} />;
|
||||
})}
|
||||
</StyledIntegrationsSection>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
@ -21,6 +21,7 @@ export enum SettingsPath {
|
||||
DevelopersNewApiKey = 'api-keys/new',
|
||||
DevelopersApiKeyDetail = 'api-keys/:apiKeyId',
|
||||
Integrations = 'integrations',
|
||||
IntegrationDetail = 'integrations/:integrationKey',
|
||||
DevelopersNewWebhook = 'webhooks/new',
|
||||
DevelopersNewWebhookDetail = 'webhooks/:webhookId',
|
||||
}
|
||||
|
||||
@ -2,4 +2,6 @@ export type FeatureFlagKey =
|
||||
| 'IS_BLOCKLIST_ENABLED'
|
||||
| 'IS_CALENDAR_ENABLED'
|
||||
| 'IS_QUICK_ACTIONS_ENABLED'
|
||||
| 'IS_EVENT_OBJECT_ENABLED';
|
||||
| 'IS_EVENT_OBJECT_ENABLED'
|
||||
| 'IS_AIRTABLE_INTEGRATION_ENABLED'
|
||||
| 'IS_POSTGRESQL_INTEGRATION_ENABLED';
|
||||
|
||||
Reference in New Issue
Block a user