Skip to content

The open alternative to Salesforce, designed for AI.

Make app preferences skeleton loaders match what they replace (#28225)

nitina18edec8a690
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
index 3517fdcf932..bdb8f902776 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
@@ -5,7 +5,7 @@ import { SETTINGS_NATIVE_ACCOUNT_APP_ACCOUNT_GROUP_TABLE_GRID_TEMPLATE_COLUMNS }
import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
import { type NativeAccountApp } from '@/settings/app-preferences/types/NativeAccountApp';
import { getNativeAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getNativeAccountAppsUsingAccount';
-import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
+import { SettingsTableRowsSkeletonLoader } from '@/settings/components/SettingsTableRowsSkeletonLoader';
import { Table } from '@/ui/layout/table/components/Table';
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
import { TableRow } from '@/ui/layout/table/components/TableRow';
@@ -54,9 +54,17 @@ export const SettingsAccountGroupsSection = ({
? SETTINGS_NATIVE_ACCOUNT_APP_ACCOUNT_GROUP_TABLE_GRID_TEMPLATE_COLUMNS
: SETTINGS_ACCOUNT_GROUP_TABLE_GRID_TEMPLATE_COLUMNS;
- if (loading) {
- return <SettingsSectionSkeletonLoader />;
- }
+ const tableHeaderRow = (
+ <TableRow gridTemplateColumns={gridTemplateColumns}>
+ <TableHeader>{t`Account`}</TableHeader>
+ {isDefined(nativeAccountApp) ? (
+ <TableHeader>{t`Permissions`}</TableHeader>
+ ) : (
+ <TableHeader align="right">{t`Used by`}</TableHeader>
+ )}
+ <TableHeader />
+ </TableRow>
+ );
return (
<Section.Root>
@@ -64,22 +72,28 @@ export const SettingsAccountGroupsSection = ({
title={t`Accounts`}
description={t`Shared accounts between apps`}
/>
- {groups.length === 0 ? (
+ {loading ? (
+ <Table>
+ {tableHeaderRow}
+ <SettingsTableRowsSkeletonLoader
+ gridTemplateColumns={gridTemplateColumns}
+ columns={[
+ {},
+ isDefined(nativeAccountApp)
+ ? { width: 140 }
+ : { align: 'right', width: 48 },
+ {},
+ ]}
+ />
+ </Table>
+ ) : groups.length === 0 ? (
<SettingsAppPreferencesListEmptyStateCard
provider={nativeAccountApp?.provider}
/>
) : (
<>
<Table>
- <TableRow gridTemplateColumns={gridTemplateColumns}>
- <TableHeader>{t`Account`}</TableHeader>
- {isDefined(nativeAccountApp) ? (
- <TableHeader>{t`Permissions`}</TableHeader>
- ) : (
- <TableHeader align="right">{t`Used by`}</TableHeader>
- )}
- <TableHeader />
- </TableRow>
+ {tableHeaderRow}
<StyledTableRows>
{groups.map((group) => (
<SettingsAccountGroupTableRow
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsTableRowsSkeletonLoader.tsx b/packages/twenty-front/src/modules/settings/components/SettingsTableRowsSkeletonLoader.tsx
new file mode 100644
index 00000000000..51cf3a8760c
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/components/SettingsTableRowsSkeletonLoader.tsx
@@ -0,0 +1,73 @@
+import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
+import { TableCell } from '@/ui/layout/table/components/TableCell';
+import { TableRow } from '@/ui/layout/table/components/TableRow';
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { SKELETON_HEIGHT_SIZES } from 'twenty-ui/primitives/feedback';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const SKELETON_ROW_LABEL_WIDTHS = [144, 104, 128];
+
+const ICON_SIZE = 16;
+
+const StyledRows = styled.div`
+ padding-bottom: ${themeCssVariables.spacing[2]};
+ padding-top: ${themeCssVariables.spacing[2]};
+`;
+
+type SettingsTableRowsSkeletonLoaderColumn = {
+ align?: 'left' | 'right';
+ width?: number;
+};
+
+type SettingsTableRowsSkeletonLoaderProps = {
+ columns: SettingsTableRowsSkeletonLoaderColumn[];
+ gridTemplateColumns: string;
+};
+
+const renderSkeletonCellContent = (
+ column: SettingsTableRowsSkeletonLoaderColumn,
+ isFirstColumn: boolean,
+ labelWidth: number,
+): ReactNode => {
+ if (isFirstColumn) {
+ return (
+ <>
+ <SkeletonLine width={ICON_SIZE} height={ICON_SIZE} />
+ <SkeletonLine width={labelWidth} height={SKELETON_HEIGHT_SIZES.xs} />
+ </>
+ );
+ }
+
+ if (isDefined(column.width)) {
+ return (
+ <SkeletonLine width={column.width} height={SKELETON_HEIGHT_SIZES.xs} />
+ );
+ }
+
+ return null;
+};
+
+export const SettingsTableRowsSkeletonLoader = ({
+ columns,
+ gridTemplateColumns,
+}: SettingsTableRowsSkeletonLoaderProps) => (
+ <StyledRows>
+ {SKELETON_ROW_LABEL_WIDTHS.map((labelWidth) => (
+ <TableRow key={labelWidth} gridTemplateColumns={gridTemplateColumns}>
+ {columns.map((column, columnIndex) => (
+ <TableCell
+ key={columnIndex}
+ align={column.align}
+ gap={themeCssVariables.spacing[2]}
+ minWidth="0"
+ overflow="hidden"
+ >
+ {renderSkeletonCellContent(column, columnIndex === 0, labelWidth)}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ </StyledRows>
+);
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
index 64ba693a60a..b17541f53d5 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
@@ -5,6 +5,7 @@ import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccoun
import { getConnectedAccountSettingsChannels } from '@/settings/app-preferences/utils/getConnectedAccountSettingsChannels';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
+import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
import { SettingsTabBar } from '@/settings/components/layout/SettingsTabBar';
import { useSettingsActiveTabId } from '@/settings/components/layout/useSettingsActiveTabId';
@@ -52,9 +53,11 @@ export const SettingsAccountDetail = () => {
return <Navigate to={getSettingsPath(SettingsPath.Accounts)} replace />;
}
- const ProviderIcon = isDefined(nativeAccount)
- ? SettingsConnectedAccountIcon({ account: nativeAccount })
- : undefined;
+ if (!isDefined(nativeAccount)) {
+ return <SettingsSkeletonLoader />;
+ }
+
+ const ProviderIcon = SettingsConnectedAccountIcon({ account: nativeAccount });
const renderContent = () => {
if (activeTabId === 'emails' && isDefined(messageChannel)) {
@@ -78,12 +81,8 @@ export const SettingsAccountDetail = () => {
return (
<SettingsPageLayout
- title={nativeAccount?.handle}
- icon={
- isDefined(ProviderIcon) ? (
- <ProviderIcon size={theme.icon.size.md} />
- ) : undefined
- }
+ title={nativeAccount.handle}
+ icon={<ProviderIcon size={theme.icon.size.md} />}
links={[
{
children: t`User`,
@@ -93,7 +92,7 @@ export const SettingsAccountDetail = () => {
children: t`App preferences`,
href: getSettingsPath(SettingsPath.Accounts),
},
- { children: nativeAccount?.handle },
+ { children: nativeAccount.handle },
]}
secondaryBar={
tabs.length > 0 ? (
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
index e965a4e5c6d..899ea0c07b7 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
@@ -1,5 +1,6 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, userEvent, within } from 'storybook/test';
+import { delay, graphql } from 'msw';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import {
PageDecorator,
@@ -51,6 +52,30 @@ export const EmailsAndCalendarTabs: Story = {
},
};
+export const TitleStaysWhileLoading: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ graphql.query('MyConnectedAccounts', async () => {
+ await delay('infinite');
+ }),
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await waitFor(() =>
+ expect(canvasElement.querySelector('[aria-busy="true"]')).not.toBeNull(),
+ );
+ expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();
+ expect(
+ canvas.queryByText('Navigated to /settings/accounts'),
+ ).not.toBeInTheDocument();
+ },
+};
+
export const AccountWithoutSettingsGoesBackToAccounts: Story = {
args: {
routeParams: { ':connectedAccountId': FATHOM_ONLY_ACCOUNT_ID },
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx
index b8594edc01c..f5623ea18a2 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx
@@ -1,5 +1,5 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { HttpResponse, graphql } from 'msw';
+import { HttpResponse, delay, graphql } from 'msw';
import { expect, userEvent, waitFor, within } from 'storybook/test';
import { isDefined } from 'twenty-shared/utils';
@@ -80,7 +80,7 @@ export const AccountsGroupedByEmail: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- await canvas.findByText('Used by', undefined, { timeout: 3000 });
+ await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
expect(canvas.getAllByText('App preferences').length).toBeGreaterThan(0);
expect(canvas.queryByText('Connected accounts')).not.toBeInTheDocument();
@@ -122,6 +122,38 @@ export const AccountsGroupedByEmail: Story = {
},
};
+export const AccountsHeaderStaysWhileLoading: Story = {
+ ...accountGroupsStory,
+ parameters: {
+ msw: {
+ handlers: [
+ graphql.query('MyConnectedAccounts', async () => {
+ await delay('infinite');
+ }),
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByText('Shared accounts between apps', undefined, {
+ timeout: 3000,
+ }),
+ ).toBeVisible();
+ expect(canvas.getByText('Accounts')).toBeVisible();
+ expect(
+ canvas.getByText(
+ 'Choose your preferences for the apps installed on your workspace by the admin',
+ ),
+ ).toBeVisible();
+ expect(canvas.getByText('Used by')).toBeVisible();
+ expect(canvasElement.querySelector('[aria-busy="true"]')).not.toBeNull();
+ expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();
+ },
+};
+
export const AppPreferencesListEnabledApps: Story = {
...accountGroupsStory,
args: {
@@ -157,7 +189,7 @@ export const RowOpensAccountPage: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- await canvas.findByText('Used by', undefined, { timeout: 3000 });
+ await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
await userEvent.click(
getTableRow(canvasElement, '[email protected]').getByRole('img', {
name: 'Gmail and Calendar',
@@ -178,7 +210,7 @@ export const DeleteKeepsAppConnections: Story = {
const canvas = within(canvasElement);
const body = within(canvasElement.ownerDocument.body);
- await canvas.findByText('Used by', undefined, { timeout: 3000 });
+ await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
const openDeleteDialog = async () => {
await userEvent.click(