Skip to content

Commit

Permalink
update ui fr singleton list
Browse files Browse the repository at this point in the history
  • Loading branch information
gautamsi committed May 21, 2020
1 parent 0aa0e15 commit 15a6eb5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
7 changes: 5 additions & 2 deletions packages/app-admin-ui/client/pages/Item/AddNewItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { useList } from '../../providers/List';

const AddNewItem = () => {
let {
list: { access },
list: {
access,
adminConfig: { singleton = false },
},
openCreateItemModal,
} = useList();
if (!access.create) return null;
if (!access.create || singleton) return null;
const cypressId = 'item-page-create-button';
return (
<Tooltip content="Create" hideOnMouseDown hideOnKeyDown>
Expand Down
26 changes: 15 additions & 11 deletions packages/app-admin-ui/client/pages/Item/ItemTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,21 @@ export const ItemTitle = memo(function ItemTitle({ titleText }) {
<PageTitle>{titleText}</PageTitle>
<ListDescription text={list.adminDoc} />
<FlexGroup align="center" justify="space-between" css={{ marginBottom: '0.9rem' }}>
<div>
<IconButton
variant="subtle"
icon={ChevronLeftIcon}
to={list.getFullPersistentPath()}
css={{ marginLeft: -12 }}
>
{list.label}
</IconButton>
<Search list={list} />
</div>
{!list.adminConfig.singleton ? (
<div>
<IconButton
variant="subtle"
icon={ChevronLeftIcon}
to={list.getFullPersistentPath()}
css={{ marginLeft: -12 }}
>
{list.label}
</IconButton>
<Search list={list} />
</div>
) : (
<div />
)}
{itemHeaderActions ? (
itemHeaderActions()
) : (
Expand Down
7 changes: 6 additions & 1 deletion packages/app-admin-ui/client/pages/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Search from './Search';
import Management, { ManageToolbar } from './Management';
import { useListFilter, useListSelect, useListSort, useListUrlState } from './dataHooks';
import { captureSuspensePromises } from '@keystonejs/utils';
import { useAdminMeta } from '../../providers/AdminMeta';

export function ListLayout(props) {
const { items, itemCount, queryErrors, query } = props;
Expand Down Expand Up @@ -225,7 +226,7 @@ const ListPage = props => {
queryErrorsParsed,
query,
} = useList();

const { adminPath } = useAdminMeta();
const history = useHistory();
const location = useLocation();

Expand Down Expand Up @@ -278,6 +279,10 @@ const ListPage = props => {
);
}

if (list.adminConfig.singleton && itemCount > 0) {
history.push(`${adminPath}/${list.path}/${items[0].id}`);
}

// Success
// ------------------------------
return (
Expand Down

0 comments on commit 15a6eb5

Please sign in to comment.