Skip to content

The open alternative to Salesforce, designed for AI.

Show a skeleton in the apps table status column while statuses load (#29447)

nitindbcf205d320e
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyCalendarChannels.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyCalendarChannels.ts
index 81ae12a4be7..c3ee0b65827 100644
--- a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyCalendarChannels.ts
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyCalendarChannels.ts
@@ -1,6 +1,7 @@
import { type CalendarChannel } from '@/accounts/types/CalendarChannel';
import { GET_MY_CALENDAR_CHANNELS } from '@/settings/accounts/graphql/queries/getMyCalendarChannels';
import { useApolloClient, useQuery } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
export const useMyCalendarChannels = () => {
const apolloClient = useApolloClient();
@@ -14,5 +15,6 @@ export const useMyCalendarChannels = () => {
return {
channels: data?.myCalendarChannels ?? [],
loading,
+ hasLoaded: isDefined(data),
};
};
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts
index aa86c4d2137..25981d284fd 100644
--- a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts
@@ -5,6 +5,7 @@ import { useMyMessageChannels } from '@/settings/accounts/hooks/useMyMessageChan
import { useApolloClient, useQuery } from '@apollo/client/react';
import { useMemo } from 'react';
import { ConnectedAccountProvider } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
type CoreConnectedAccount = Omit<
ConnectedAccount,
@@ -40,10 +41,16 @@ export const useMyConnectedAccounts = ({
client: apolloClient,
});
- const { channels: messageChannels, loading: messageChannelsLoading } =
- useMyMessageChannels();
- const { channels: calendarChannels, loading: calendarChannelsLoading } =
- useMyCalendarChannels();
+ const {
+ channels: messageChannels,
+ loading: messageChannelsLoading,
+ hasLoaded: hasLoadedMessageChannels,
+ } = useMyMessageChannels();
+ const {
+ channels: calendarChannels,
+ loading: calendarChannelsLoading,
+ hasLoaded: hasLoadedCalendarChannels,
+ } = useMyCalendarChannels();
const accounts = useMemo<ConnectedAccount[]>(() => {
if (!data?.myConnectedAccounts) {
@@ -67,6 +74,8 @@ export const useMyConnectedAccounts = ({
accounts,
loading:
accountsLoading || messageChannelsLoading || calendarChannelsLoading,
+ hasLoaded:
+ isDefined(data) && hasLoadedMessageChannels && hasLoadedCalendarChannels,
error,
refetch,
};
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyMessageChannels.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyMessageChannels.ts
index dbf7b7601f3..50971c8cdc5 100644
--- a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyMessageChannels.ts
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyMessageChannels.ts
@@ -1,6 +1,7 @@
import { type MessageChannel } from '@/accounts/types/MessageChannel';
import { GET_MY_MESSAGE_CHANNELS } from '@/settings/accounts/graphql/queries/getMyMessageChannels';
import { useApolloClient, useQuery } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
export const useMyMessageChannels = (connectedAccountId?: string) => {
const apolloClient = useApolloClient();
@@ -15,5 +16,6 @@ export const useMyMessageChannels = (connectedAccountId?: string) => {
return {
channels: data?.myMessageChannels ?? [],
loading,
+ hasLoaded: isDefined(data),
};
};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
index 4b03bdd1df2..4d38490e72f 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
@@ -26,14 +26,16 @@ export const SettingsAppPreferencesAppsSection = () => {
const {
groups,
loading: accountGroupsLoading,
+ hasLoaded: hasLoadedAccountGroups,
error: accountGroupsError,
refetch: refetchAccountGroups,
} = useMyAccountGroups();
const isLoadingApplications =
loading && !hasLoadedApplicationsWithPreferences;
+ const isLoadingStatuses = accountGroupsLoading && !hasLoadedAccountGroups;
const hasAccountGroupsLoadError = isDefined(accountGroupsError);
const statusesById =
- accountGroupsLoading || hasAccountGroupsLoadError
+ isLoadingStatuses || hasAccountGroupsLoadError
? {}
: getAppPreferencesAppStatusesById({
groups,
@@ -71,6 +73,7 @@ export const SettingsAppPreferencesAppsSection = () => {
middleColumn="status"
statusesById={statusesById}
isLoading={isLoadingApplications}
+ isLoadingStatuses={isLoadingStatuses}
/>
);
};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
index 9d601f9dcb8..74865436463 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
@@ -10,13 +10,15 @@ const ACCOUNT_GROUP_PROVIDERS: ReadonlySet<ConnectedAccountProvider> = new Set([
]);
export const useMyAccountGroups = () => {
- const { accounts, loading, error, refetch } = useMyPersonalConnectedAccounts({
- providers: ACCOUNT_GROUP_PROVIDERS,
- });
+ const { accounts, loading, hasLoaded, error, refetch } =
+ useMyPersonalConnectedAccounts({
+ providers: ACCOUNT_GROUP_PROVIDERS,
+ });
return {
groups: groupConnectedAccountsByBuiltInAccount(accounts),
loading,
+ hasLoaded,
error,
refetch,
};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts
index c41a515ac75..3e521e83842 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts
+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts
@@ -11,9 +11,10 @@ export const useMyPersonalConnectedAccounts = ({
providers: ReadonlySet<ConnectedAccountProvider>;
}) => {
const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);
- const { accounts, loading, error, refetch } = useMyConnectedAccounts({
- providers,
- });
+ const { accounts, loading, hasLoaded, error, refetch } =
+ useMyConnectedAccounts({
+ providers,
+ });
const userWorkspaceId = currentWorkspaceMember?.userWorkspaceId;
@@ -23,5 +24,5 @@ export const useMyPersonalConnectedAccounts = ({
)
: [];
- return { accounts: personalAccounts, loading, error, refetch };
+ return { accounts: personalAccounts, loading, hasLoaded, error, refetch };
};
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationStatusCellSkeleton.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationStatusCellSkeleton.tsx
new file mode 100644
index 00000000000..62dcd31e12e
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationStatusCellSkeleton.tsx
@@ -0,0 +1,12 @@
+import { SkeletonLine } from '@/ui/feedback/skeleton/components/SkeletonLine';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const STATUS_SKELETON_WIDTH = 88;
+
+export const SettingsApplicationStatusCellSkeleton = () => (
+ <SkeletonLine
+ width={STATUS_SKELETON_WIDTH}
+ height={themeCssVariables.spacing[5]}
+ borderRadius={themeCssVariables.border.radius.pill}
+ />
+);
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsInstalledAppsSection.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsInstalledAppsSection.tsx
index 5e388c67f74..ea5f478366f 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsInstalledAppsSection.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsInstalledAppsSection.tsx
@@ -23,6 +23,7 @@ export const SettingsApplicationsInstalledAppsSection = () => {
);
const {
statusesById,
+ isLoading: isLoadingStatuses,
error: statusError,
refetch: refetchStatuses,
} = useWorkspaceApplicationStatusesById({
@@ -54,6 +55,7 @@ export const SettingsApplicationsInstalledAppsSection = () => {
linkTarget="applicationDetail"
middleColumn={isAppPreferencesEnabled ? 'typeOrStatus' : 'type'}
statusesById={statusesById}
+ isLoadingStatuses={isLoadingStatuses}
/>
);
};
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
index b2e7c05eebc..14b9038bade 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
@@ -39,6 +39,7 @@ type SettingsApplicationsTableProps = {
builtInAccountApps: BuiltInAccountApp[];
middleColumn: SettingsApplicationTableRowMiddleColumn;
isLoading?: boolean;
+ isLoadingStatuses?: boolean;
toolbar?: ReactNode;
} & (
| {
@@ -66,6 +67,7 @@ export const SettingsApplicationsTable = ({
middleColumn,
statusesById,
isLoading = false,
+ isLoadingStatuses = false,
toolbar,
}: SettingsApplicationsTableProps) => {
const { t } = useLingui();
@@ -121,6 +123,7 @@ export const SettingsApplicationsTable = ({
})}
middleColumn={middleColumn}
statuses={statusesById?.[rowItem.id]}
+ isLoadingStatuses={isLoadingStatuses}
/>
))}
</StyledTableRowsContainer>
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTableApplicationRow.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTableApplicationRow.tsx
index c4a3dc2d0c1..c76642fb98b 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTableApplicationRow.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTableApplicationRow.tsx
@@ -2,6 +2,7 @@ import { ApplicationDisplay } from '@/applications/components/ApplicationDisplay
import { useResolvedApplicationDescription } from '@/applications/hooks/useResolvedApplicationDescription';
import { type ApplicationDisplayData } from '@/applications/types/ApplicationDisplayData';
import { SettingsApplicationStatusCell } from '@/settings/applications/components/SettingsApplicationStatusCell';
+import { SettingsApplicationStatusCellSkeleton } from '@/settings/applications/components/SettingsApplicationStatusCellSkeleton';
import { SettingsApplicationTableRow } from '@/settings/applications/components/SettingsApplicationTableRow';
import { SettingsApplicationTableRowChevronIcon } from '@/settings/applications/components/SettingsApplicationTableRowChevronIcon';
import { SettingsApplicationTypeOrStatusCell } from '@/settings/applications/components/SettingsApplicationTypeOrStatusCell';
@@ -37,6 +38,7 @@ type SettingsApplicationsTableApplicationRowProps = {
link: string;
middleColumn?: SettingsApplicationTableRowMiddleColumn;
statuses?: SettingsApplicationStatus[];
+ isLoadingStatuses?: boolean;
};
export const SettingsApplicationsTableApplicationRow = ({
@@ -44,6 +46,7 @@ export const SettingsApplicationsTableApplicationRow = ({
link,
middleColumn = 'type',
statuses = [],
+ isLoadingStatuses = false,
}: SettingsApplicationsTableApplicationRowProps) => {
const resolvedDescription = useResolvedApplicationDescription(application);
const sourceTypeLabel = getSourceTypeLabel(application.sourceType);
@@ -51,17 +54,22 @@ export const SettingsApplicationsTableApplicationRow = ({
middleColumn === 'type' &&
statuses.some((status) => status.type === 'updateAvailable');
+ const statusOrSkeleton = (statusCell: ReactNode) =>
+ isLoadingStatuses ? <SettingsApplicationStatusCellSkeleton /> : statusCell;
+
const middleByColumn: Record<
SettingsApplicationTableRowMiddleColumn,
ReactNode
> = {
type: sourceTypeLabel,
- status: <SettingsApplicationStatusCell statuses={statuses} />,
- typeOrStatus: (
+ status: statusOrSkeleton(
+ <SettingsApplicationStatusCell statuses={statuses} />,
+ ),
+ typeOrStatus: statusOrSkeleton(
<SettingsApplicationTypeOrStatusCell
typeLabel={sourceTypeLabel}
statuses={statuses}
- />
+ />,
),
};
diff --git a/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
index b8894b4517f..c775dc00224 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
@@ -254,6 +254,27 @@ export const LoadingHidesSearchAndRows: Story = {
},
};
+export const LoadingStatusesShowsASkeletonInTheStatusColumn: Story = {
+ args: {
+ applications: [NPM_APPLICATION],
+ builtInAccountApps: [],
+ middleColumn: 'typeOrStatus',
+ statusesById: {
+ [NPM_APPLICATION.id]: [{ type: 'missingConfiguration' }],
+ },
+ isLoadingStatuses: true,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ const acmeRow = await canvas.findByRole('link', { name: /Acme Sync/ });
+
+ expect(acmeRow.querySelector('[aria-busy="true"]')).toBeInTheDocument();
+ expect(acmeRow).not.toHaveTextContent('Setup incomplete');
+ expect(acmeRow).not.toHaveTextContent('NPM');
+ },
+};
+
export const HidesTheDescriptionOnMobile: Story = {
parameters: {
viewport: { defaultViewport: 'mobile1' },
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/useWorkspaceApplicationStatusesById.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useWorkspaceApplicationStatusesById.ts
index c79d0a14ed7..2ee09d87ead 100644
--- a/packages/twenty-front/src/modules/settings/applications/hooks/useWorkspaceApplicationStatusesById.ts
+++ b/packages/twenty-front/src/modules/settings/applications/hooks/useWorkspaceApplicationStatusesById.ts
@@ -1,5 +1,6 @@
import { getWorkspaceApplicationStatusesById } from '@/settings/applications/utils/getWorkspaceApplicationStatusesById';
import { useQuery } from '@apollo/client/react';
+import { isDefined } from 'twenty-shared/utils';
import { FindManyApplicationsForStatusDocument } from '~/generated-metadata/graphql';
type UseWorkspaceApplicationStatusesByIdArgs = {
@@ -13,7 +14,7 @@ export const useWorkspaceApplicationStatusesById = ({
applications,
shouldSkip,
}: UseWorkspaceApplicationStatusesByIdArgs) => {
- const { data, error, refetch } = useQuery(
+ const { data, loading, error, refetch } = useQuery(
FindManyApplicationsForStatusDocument,
{
skip: shouldSkip,
@@ -26,6 +27,7 @@ export const useWorkspaceApplicationStatusesById = ({
applications,
applicationsWithVariables: data?.findManyApplications,
}),
+ isLoading: loading && !isDefined(data),
error,
refetch,
};