Skip to content

Commit

Permalink
feat(dashboard): empty state for tree listing.
Browse files Browse the repository at this point in the history
this makes a label "No Data." appear when there's no data in tree
listing.

Closes #173
  • Loading branch information
Lucas Bracher committed Aug 29, 2024
1 parent 6d04489 commit e3d0d14
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
12 changes: 8 additions & 4 deletions dashboard/src/components/Skeleton/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import type { ReactNode } from 'react';
import type { ReactNode, ComponentProps } from 'react';

import { Skeleton as SkeletonComponent } from '@/components/ui/skeleton'; //to avoid name conflict we rename the import

type SkeletonProps = {
import { cn } from '@/lib/utils';

type SkeletonProps = ComponentProps<typeof SkeletonComponent> & {
children: ReactNode;
};

const Skeleton = ({ children }: SkeletonProps): JSX.Element => {
const Skeleton = ({ children, className }: SkeletonProps): JSX.Element => {
return (
<SkeletonComponent className="grid h-[400px] place-items-center">
<SkeletonComponent
className={cn('grid h-[400px] place-items-center', className)}
>
{children}
</SkeletonComponent>
);
Expand Down
6 changes: 5 additions & 1 deletion dashboard/src/components/TreeListingPage/TreeListingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const TreeListingPage = ({ inputFilter }: ITreeListingPage): JSX.Element => {
</Skeleton>
);

return (
return data && data.length > 0 ? (
<div className="flex flex-col gap-6">
<div className="flex flex-col items-end gap-4">
<TableInfo
Expand All @@ -114,6 +114,10 @@ const TreeListingPage = ({ inputFilter }: ITreeListingPage): JSX.Element => {
/>
</div>
</div>
) : (
<div className="grid h-[400px] place-items-center rounded-md bg-slate-100 dark:bg-slate-800">
<FormattedMessage id="global.noData" />
</div>
);
};

Expand Down
4 changes: 4 additions & 0 deletions dashboard/src/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

.remove-animate-pulse.animate-pulse {
animation: none !important;
}
1 change: 1 addition & 0 deletions dashboard/src/locales/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const messages = {
'global.missed': 'Missed',
'global.modules': 'Modules',
'global.name': 'Name',
'global.noData': 'No data.',
'global.noDataAvailable': 'No data available',
'global.noResults': 'No results were found',
'global.none': 'None',
Expand Down

0 comments on commit e3d0d14

Please sign in to comment.