b09ecfbb8c
This PR was created by [GitStart](https://gitstart.com/) to address the requirements from this ticket: [TWNTY-6871](https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6871). --- ### Description Migrate: - Info display component - Status display component - SeparatorLineText display component ### Demo ###### SeparatorLineText In Storybook  Info Component on Storybook  Status Component on Storybook  ###### Fixes twentyhq/private-issues#95 --------- Co-authored-by: gitstart-twenty <gitstart-twenty@users.noreply.github.com> Co-authored-by: Charles Bochet <charles@twenty.com>
52 lines
1.4 KiB
TypeScript
52 lines
1.4 KiB
TypeScript
import { useGetDatabaseConnectionTables } from '@/databases/hooks/useGetDatabaseConnectionTables';
|
|
import { Status } from 'twenty-ui';
|
|
import { RemoteTableStatus } from '~/generated-metadata/graphql';
|
|
import { isDefined } from '~/utils/isDefined';
|
|
|
|
type SettingsIntegrationDatabaseConnectionSyncStatusProps = {
|
|
connectionId: string;
|
|
skip?: boolean;
|
|
shouldFetchPendingSchemaUpdates?: boolean;
|
|
};
|
|
|
|
export const SettingsIntegrationDatabaseConnectionSyncStatus = ({
|
|
connectionId,
|
|
skip,
|
|
shouldFetchPendingSchemaUpdates,
|
|
}: SettingsIntegrationDatabaseConnectionSyncStatusProps) => {
|
|
const { tables, error } = useGetDatabaseConnectionTables({
|
|
connectionId,
|
|
skip,
|
|
shouldFetchPendingSchemaUpdates,
|
|
});
|
|
|
|
if (isDefined(error)) {
|
|
return <Status color="red" text="Connection failed" />;
|
|
}
|
|
|
|
const syncedTables = tables.filter(
|
|
(table) => table.status === RemoteTableStatus.Synced,
|
|
);
|
|
|
|
const updatesAvailable = tables.some(
|
|
(table) =>
|
|
table.schemaPendingUpdates?.length &&
|
|
table.schemaPendingUpdates.length > 0,
|
|
);
|
|
|
|
return (
|
|
<Status
|
|
color={updatesAvailable ? 'yellow' : 'green'}
|
|
text={
|
|
syncedTables.length === 1
|
|
? `1 tracked table${
|
|
updatesAvailable ? ' (with pending schema updates)' : ''
|
|
}`
|
|
: `${syncedTables.length} tracked tables${
|
|
updatesAvailable ? ' (with pending schema updates)' : ''
|
|
}`
|
|
}
|
|
/>
|
|
);
|
|
};
|