Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable list header actions hook #3048

Merged
merged 9 commits into from
May 27, 2020
6 changes: 2 additions & 4 deletions packages/app-admin-ui/client/pages/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { Fragment, useEffect, Suspense } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { useList } from '../../providers/List';

import { IconButton } from '@arch-ui/button';
import { PlusIcon } from '@arch-ui/icons';
import { Container, FlexGroup } from '@arch-ui/layout';
import { colors, gridSize } from '@arch-ui/theme';
import { PageTitle } from '@arch-ui/typography';
Expand Down Expand Up @@ -38,7 +36,7 @@ import CreateItem from './CreateItem';
export function ListLayout(props) {
const { items, itemCount, queryErrors, query } = props;

const { list, openCreateItemModal } = useList();
const { list } = useList();
const {
urlState: { currentPage, fields, pageSize, search },
} = useListUrlState(list);
Expand Down Expand Up @@ -70,7 +68,7 @@ export function ListLayout(props) {
<HeaderInset>
<FlexGroup align="center" justify="space-between">
<PageTitle>{list.plural}</PageTitle>
{list.access.create ? listHeaderActions ? listHeaderActions() : <CreateItem /> : null}
{listHeaderActions ? listHeaderActions() : <CreateItem />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not want to remove all the header items which dev may have created, list create access check is moved to <CreateItem/> which will not render itself if there is no access for create.

we can leave this to hook author to decide whether they need action for create access or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call to move it to create item.

</FlexGroup>
<ListDescription text={list.adminDoc} />
<div
Expand Down