From 05cf4ab8a2b25cfb402b288557728d9e0b79643a Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sat, 2 May 2020 17:28:00 +1100 Subject: [PATCH] Stop passing the CreateItemModal component to field views --- .changeset/three-coins-suffer.md | 5 +++-- packages/app-admin-ui/client/components/CreateItemModal.js | 1 - .../app-admin-ui/client/components/UpdateManyItemsModal.js | 2 -- packages/app-admin-ui/client/pages/Item/index.js | 1 - packages/fields/src/types/Relationship/views/Field.js | 6 ++---- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.changeset/three-coins-suffer.md b/.changeset/three-coins-suffer.md index 259e6651455..beaf1dd6973 100644 --- a/.changeset/three-coins-suffer.md +++ b/.changeset/three-coins-suffer.md @@ -1,5 +1,6 @@ --- -'@keystonejs/app-admin-ui': patch +'@keystonejs/app-admin-ui': minor +'@keystonejs/fields': minor --- -Cleaned up CreateItemModal implementation. +Cleaned up CreateItemModal implementation. The component is no longer passed to field views and should be imported from the @keystonejs/app-admin-ui package instead. diff --git a/packages/app-admin-ui/client/components/CreateItemModal.js b/packages/app-admin-ui/client/components/CreateItemModal.js index 4d84f0cb615..46955405581 100644 --- a/packages/app-admin-ui/client/components/CreateItemModal.js +++ b/packages/app-admin-ui/client/components/CreateItemModal.js @@ -212,7 +212,6 @@ const CreateItemModal = ({ prefillData = {}, onClose, onCreate }) => { /* TODO: Permission query results */ errors={validationErrors[field.path] || []} warnings={validationWarnings[field.path] || []} - CreateItemModal={CreateItemModal} onChange={onChange} renderContext="dialog" /> diff --git a/packages/app-admin-ui/client/components/UpdateManyItemsModal.js b/packages/app-admin-ui/client/components/UpdateManyItemsModal.js index 590e7638759..37a8c730cb5 100644 --- a/packages/app-admin-ui/client/components/UpdateManyItemsModal.js +++ b/packages/app-admin-ui/client/components/UpdateManyItemsModal.js @@ -12,7 +12,6 @@ import { LoadingIndicator } from '@arch-ui/loading'; import Select from '@arch-ui/select'; import { validateFields, handleCreateUpdateMutationError } from '../util'; -import CreateItemModal from './CreateItemModal'; const Render = ({ children }) => children(); @@ -177,7 +176,6 @@ const UpdateManyModal = ({ list, items, isOpen, onUpdate, onClose }) => { warnings={validationWarnings[field.path] || []} onChange={onChange} renderContext="dialog" - CreateItemModal={CreateItemModal} /> ), [ diff --git a/packages/app-admin-ui/client/pages/Item/index.js b/packages/app-admin-ui/client/pages/Item/index.js index 7fba23e1f4f..6e8932b848e 100644 --- a/packages/app-admin-ui/client/pages/Item/index.js +++ b/packages/app-admin-ui/client/pages/Item/index.js @@ -300,7 +300,6 @@ const ItemDetails = ({ savedValue={initialData[field.path]} onChange={onChange} renderContext="page" - CreateItemModal={CreateItemModal} /> ), [ diff --git a/packages/fields/src/types/Relationship/views/Field.js b/packages/fields/src/types/Relationship/views/Field.js index 112f24cc799..db253faa90e 100644 --- a/packages/fields/src/types/Relationship/views/Field.js +++ b/packages/fields/src/types/Relationship/views/Field.js @@ -12,7 +12,7 @@ import { IconButton } from '@arch-ui/button'; import Tooltip from '@arch-ui/tooltip'; import RelationshipSelect from './RelationshipSelect'; -import { ListProvider, useList } from '@keystonejs/app-admin-ui/components'; +import { CreateItemModal, ListProvider, useList } from '@keystonejs/app-admin-ui/components'; const MAX_IDS_IN_FILTER = 100; @@ -103,7 +103,7 @@ function LinkToRelatedItems({ field, value }) { ); } -function CreateAndAddItem({ field, item, onCreate, CreateItemModal }) { +function CreateAndAddItem({ field, item, onCreate }) { const { list, openCreateItemModal } = useList(); let relatedList = field.adminMeta.getListByKey(field.config.ref); @@ -167,7 +167,6 @@ const RelationshipField = ({ onChange, item, list, - CreateItemModal, }) => { const handleChange = option => { const { many } = field.config; @@ -209,7 +208,6 @@ const RelationshipField = ({ field={field} item={item} list={list} - CreateItemModal={CreateItemModal} /> {authStrategy && ref === authStrategy.listKey && (