Skip to content

Commit

Permalink
feat: create Integrations/IntegrationDetail page
Browse files Browse the repository at this point in the history
Closes #4546
  • Loading branch information
thaisguigon committed Mar 19, 2024
1 parent e579554 commit 37f3181
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 2 deletions.
5 changes: 5 additions & 0 deletions packages/twenty-front/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { SettingsDevelopersApiKeysNew } from '~/pages/settings/developers/api-ke
import { SettingsDevelopers } from '~/pages/settings/developers/SettingsDevelopers';
import { SettingsDevelopersWebhooksDetail } from '~/pages/settings/developers/webhooks/SettingsDevelopersWebhookDetail';
import { SettingsDevelopersWebhooksNew } from '~/pages/settings/developers/webhooks/SettingsDevelopersWebhooksNew';
import { SettingsIntegrationDetail } from '~/pages/settings/integrations/SettingsIntegrationDetail';
import { SettingsIntegrations } from '~/pages/settings/integrations/SettingsIntegrations';
import { SettingsAppearance } from '~/pages/settings/SettingsAppearance';
import { SettingsBilling } from '~/pages/settings/SettingsBilling.tsx';
Expand Down Expand Up @@ -171,6 +172,10 @@ export const App = () => {
path={SettingsPath.Integrations}
element={<SettingsIntegrations />}
/>
<Route
path={SettingsPath.IntegrationDetail}
element={<SettingsIntegrationDetail />}
/>
<Route
path={SettingsPath.ObjectNewFieldStep1}
element={<SettingsObjectNewFieldStep1 />}
Expand Down
1 change: 1 addition & 0 deletions packages/twenty-front/src/modules/types/SettingsPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum SettingsPath {
DevelopersNewApiKey = 'api-keys/new',
DevelopersApiKeyDetail = 'api-keys/:apiKeyId',
Integrations = 'integrations',
IntegrationDetail = 'integrations/:integrationSlug',
DevelopersNewWebhook = 'webhooks/new',
DevelopersNewWebhookDetail = 'webhooks/:webhookId',
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type FeatureFlagKey =
| 'IS_BLOCKLIST_ENABLED'
| 'IS_CALENDAR_ENABLED'
| 'IS_QUICK_ACTIONS_ENABLED';
| 'IS_QUICK_ACTIONS_ENABLED'
| 'IS_AIRTABLE_INTEGRATION_ENABLED'
| 'IS_POSTGRESQL_INTEGRATION_ENABLED';
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { useEffect } from 'react';
import { useNavigate, useParams } from 'react-router-dom';

import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { AppPath } from '@/types/AppPath';
import { IconSettings } from '@/ui/display/icon';
import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer';
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { SETTINGS_INTEGRATION_LABEL_BY_SLUG } from '~/pages/settings/integrations/constants/SettingsIntegrationLabelBySlug';

export const SettingsIntegrationDetail = () => {
const { integrationSlug = '' } = useParams();
const navigate = useNavigate();
const integrationLabel = SETTINGS_INTEGRATION_LABEL_BY_SLUG[integrationSlug];

const isAirtableIntegrationEnabled = useIsFeatureEnabled(
'IS_AIRTABLE_INTEGRATION_ENABLED',
);
const isPostgresqlIntegrationEnabled = useIsFeatureEnabled(
'IS_POSTGRESQL_INTEGRATION_ENABLED',
);
const isIntegrationAvailable =
(integrationSlug === 'airtable' && isAirtableIntegrationEnabled) ||
(integrationSlug === 'postgresql' && isPostgresqlIntegrationEnabled);

useEffect(() => {
if (!integrationLabel || !isIntegrationAvailable) {
return navigate(AppPath.NotFound);
}
}, [
integrationLabel,
integrationSlug,
isAirtableIntegrationEnabled,
isIntegrationAvailable,
isPostgresqlIntegrationEnabled,
navigate,
]);

if (!integrationLabel || !isIntegrationAvailable) return null;

return (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer>
<Breadcrumb
links={[
{ children: 'Integrations', href: '/settings/integrations' },
{ children: integrationLabel },
]}
/>
</SettingsPageContainer>
</SubMenuTopBarContainer>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const SETTINGS_INTEGRATION_LABEL_BY_SLUG: Record<string, string> = {
airtable: 'Airtable',
postgresql: 'PostgreSQL',
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,23 @@ export const seedFeatureFlags = async (
.into(`${schemaName}.${tableName}`, ['key', 'workspaceId', 'value'])
.orIgnore()
.values([
{
key: FeatureFlagKeys.IsBlocklistEnabled,
workspaceId: workspaceId,
value: true,
},
{
key: FeatureFlagKeys.IsCalendarEnabled,
workspaceId: workspaceId,
value: true,
},
{
key: FeatureFlagKeys.IsBlocklistEnabled,
key: FeatureFlagKeys.IsAirtableIntegrationEnabled,
workspaceId: workspaceId,
value: true,
},
{
key: FeatureFlagKeys.IsPostgreSQLIntegrationEnabled,
workspaceId: workspaceId,
value: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { Workspace } from 'src/engine/modules/workspace/workspace.entity';
export enum FeatureFlagKeys {
IsBlocklistEnabled = 'IS_BLOCKLIST_ENABLED',
IsCalendarEnabled = 'IS_CALENDAR_ENABLED',
IsAirtableIntegrationEnabled = 'IS_AIRTABLE_INTEGRATION_ENABLED',
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
}

@Entity({ name: 'featureFlag', schema: 'core' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class AddStandardIdCommand extends CommandRunner {
{
IS_BLOCKLIST_ENABLED: true,
IS_CALENDAR_ENABLED: true,
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
},
);
const standardFieldMetadataCollection = this.standardFieldFactory.create(
Expand All @@ -61,6 +63,8 @@ export class AddStandardIdCommand extends CommandRunner {
{
IS_BLOCKLIST_ENABLED: true,
IS_CALENDAR_ENABLED: true,
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
},
);

Expand Down

0 comments on commit 37f3181

Please sign in to comment.