-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build empty state for remote tables (#5652)
Remote tables could be in an empty state because: - either we do not have data, which is normal - either the connexion is broken (issue with the server, table requires updates...) Apollo throws errors but these will quickly disappear and do not provide any tips to the user on how handle those. This PR adds a new empty state placeholder for remote objects, that will be display when the record list is empty. It will provide a link to the settings page. <img width="1512" alt="Capture d’écran 2024-05-30 à 11 49 33" src="https://github.com/twentyhq/twenty/assets/22936103/fc2dd3cc-e90b-4033-b023-83ac9ff2a70b">
- Loading branch information
Showing
5 changed files
with
105 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
.../twenty-front/src/modules/object-record/record-table/components/RecordTableEmptyState.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { IconPlus, IconSettings } from 'twenty-ui'; | ||
|
||
import { Button } from '@/ui/input/button/components/Button'; | ||
import AnimatedPlaceholder from '@/ui/layout/animated-placeholder/components/AnimatedPlaceholder'; | ||
import { | ||
AnimatedPlaceholderEmptyContainer, | ||
AnimatedPlaceholderEmptySubTitle, | ||
AnimatedPlaceholderEmptyTextContainer, | ||
AnimatedPlaceholderEmptyTitle, | ||
} from '@/ui/layout/animated-placeholder/components/EmptyPlaceholderStyled'; | ||
|
||
type RecordTableEmptyStateProps = { | ||
objectLabel: string; | ||
createRecord: () => void; | ||
isRemote: boolean; | ||
}; | ||
|
||
export const RecordTableEmptyState = ({ | ||
objectLabel, | ||
createRecord, | ||
isRemote, | ||
}: RecordTableEmptyStateProps) => { | ||
const navigate = useNavigate(); | ||
|
||
const [title, subTitle, Icon, onClick, buttonTitle] = isRemote | ||
? [ | ||
'No Data Available for Remote Table', | ||
'If this is unexpected, please verify your settings.', | ||
IconSettings, | ||
() => navigate('/settings/integrations'), | ||
'Go to Settings', | ||
] | ||
: [ | ||
`Add your first ${objectLabel}`, | ||
`Use our API or add your first ${objectLabel} manually`, | ||
IconPlus, | ||
createRecord, | ||
`Add a ${objectLabel}`, | ||
]; | ||
|
||
return ( | ||
<AnimatedPlaceholderEmptyContainer> | ||
<AnimatedPlaceholder type="noRecord" /> | ||
<AnimatedPlaceholderEmptyTextContainer> | ||
<AnimatedPlaceholderEmptyTitle>{title}</AnimatedPlaceholderEmptyTitle> | ||
<AnimatedPlaceholderEmptySubTitle> | ||
{subTitle} | ||
</AnimatedPlaceholderEmptySubTitle> | ||
</AnimatedPlaceholderEmptyTextContainer> | ||
<Button | ||
Icon={Icon} | ||
title={buttonTitle} | ||
variant={'secondary'} | ||
onClick={onClick} | ||
/> | ||
</AnimatedPlaceholderEmptyContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...dules/object-record/record-table/components/__stories__/RecordTableEmptyState.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { RecordTableEmptyState } from '@/object-record/record-table/components/RecordTableEmptyState'; | ||
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator'; | ||
|
||
const meta: Meta = { | ||
title: 'Modules/ObjectRecord/RecordTable/RecordTableEmptyState', | ||
component: RecordTableEmptyState, | ||
decorators: [MemoryRouterDecorator], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof RecordTableEmptyState>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
objectLabel: 'person', | ||
isRemote: false, | ||
createRecord: () => {}, | ||
}, | ||
}; | ||
|
||
export const Remote: Story = { | ||
args: { | ||
objectLabel: 'remote person', | ||
isRemote: true, | ||
createRecord: () => {}, | ||
}, | ||
}; |