From 30fc08b515e4f8851fd2583a265a813c683bf604 Mon Sep 17 00:00:00 2001 From: Mitchell Hamilton Date: Tue, 12 Oct 2021 17:09:01 +1000 Subject: [PATCH] Fix `ui.hideCreate` not being respected on the home page (#6777) --- .changeset/kind-islands-repeat.md | 5 +++ .../admin-ui/pages/HomePage/index.tsx | 36 ++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 .changeset/kind-islands-repeat.md diff --git a/.changeset/kind-islands-repeat.md b/.changeset/kind-islands-repeat.md new file mode 100644 index 00000000000..bdf1b619982 --- /dev/null +++ b/.changeset/kind-islands-repeat.md @@ -0,0 +1,5 @@ +--- +'@keystone-next/keystone': patch +--- + +Fixed the home page of the Admin UI not respecting `ui.hideCreate` diff --git a/packages/keystone/src/___internal-do-not-use-will-break-in-patch/admin-ui/pages/HomePage/index.tsx b/packages/keystone/src/___internal-do-not-use-will-break-in-patch/admin-ui/pages/HomePage/index.tsx index dcec66cd964..9fc65cf4b2c 100644 --- a/packages/keystone/src/___internal-do-not-use-will-break-in-patch/admin-ui/pages/HomePage/index.tsx +++ b/packages/keystone/src/___internal-do-not-use-will-break-in-patch/admin-ui/pages/HomePage/index.tsx @@ -17,6 +17,7 @@ import { useRouter, Link } from '../../../../admin-ui/router'; type ListCardProps = { listKey: string; + hideCreate: boolean; count: | { type: 'success'; count: number } | { type: 'no-access' } @@ -24,7 +25,7 @@ type ListCardProps = { | { type: 'loading' }; }; -const ListCard = ({ listKey, count }: ListCardProps) => { +const ListCard = ({ listKey, count, hideCreate }: ListCardProps) => { const { colors, palette, radii, spacing } = useTheme(); const list = useList(listKey); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); @@ -65,16 +66,18 @@ const ListCard = ({ listKey, count }: ListCardProps) => { 'No access' )} - { - setIsCreateModalOpen(true); - }} - > - - Create {list.singular} - + {hideCreate === false && ( + { + setIsCreateModalOpen(true); + }} + > + + Create {list.singular} + + )} { adminMeta { lists { key - fields { - path - createView { - fieldMode - } - } + hideCreate } } } @@ -191,6 +189,10 @@ export const HomePage = () => { : { type: 'success', count: data[key] } : { type: 'loading' } } + hideCreate={ + data?.keystone.adminMeta.lists.find((list: any) => list.key === key) + ?.hideCreate ?? false + } key={key} listKey={key} />