Skip to content

Commit

Permalink
DataViews: adds two new stories for edge cases (#64975)
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal authored Sep 2, 2024
1 parent 844790e commit 9ff171f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/dataviews/src/components/dataviews/stories/index.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,46 @@ export const Default = ( props ) => {
/>
);
};

export const Empty = ( props ) => {
const [ view, setView ] = useState( DEFAULT_VIEW );

return (
<DataViews
{ ...props }
paginationInfo={ { totalItems: 0, totalPages: 0 } }
data={ [] }
view={ view }
fields={ fields }
onChangeView={ setView }
/>
);
};

export const FieldsNoSortableNoHidable = ( props ) => {
const [ view, setView ] = useState( DEFAULT_VIEW );
const { data: shownData, paginationInfo } = useMemo( () => {
return filterSortAndPaginate( data, view, fields );
}, [ view ] );

const _fields = fields.map( ( field ) => ( {
...field,
enableSorting: false,
enableHiding: false,
} ) );

return (
<DataViews
{ ...props }
paginationInfo={ paginationInfo }
data={ shownData }
view={ view }
fields={ _fields }
onChangeView={ setView }
/>
);
};

Default.args = {
actions,
defaultLayouts: {
Expand Down

0 comments on commit 9ff171f

Please sign in to comment.