Skip to content

Commit

Permalink
Export components from admin-ui and fix Relationship field use of Cre…
Browse files Browse the repository at this point in the history
…ateItemModel (keystonejs#1880)

* export some components for consuming in custom pages
provide every field with createItemModal prop which can be used for rendering CreateItemModel by all field (custom fields)
fixes keystonejs#1719

* update export  format

* Update .changeset/big-bugs-kick.md

changelevel set to minor instead of patch

Co-Authored-By: Jess Telford <[email protected]>

* fix case for CreateItemModal prop

* chane changeset level

* more exports

pass List/ListLayout props to ListTable

* format changeset
  • Loading branch information
gautamsi authored and jesstelford committed Nov 8, 2019
1 parent 15e8d58 commit 1a723a5
Show file tree
Hide file tree
Showing 8 changed files with 404 additions and 587 deletions.
25 changes: 25 additions & 0 deletions .changeset/big-bugs-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
'@keystonejs/app-admin-ui': minor
'@keystonejs/fields': minor
---

Replaced `RelationShip` field's implementation of `CreateItemModel` with a prop provided by `admin-ui`

Exported following components from `admin-ui` which can be used outside of `admin-ui` to have same look and feel when working with Lists. One simple use is in custom pages where this can be customized differently than core list pages

* `List`
* `ListData`
* `ListLayout`
* `ListManage`
* `FieldSelect`
* `Search`
* `ActiveFilters`
* `Pagination`
* `CreateItemModal`
* `DeleteItemModal`
* `DeleteManyItemsModal`
* `ListTable`
* `PageLoading`
* `ToastContainer`
* `UpdateManyItemsModal`
* `Popout`
14 changes: 14 additions & 0 deletions packages/app-admin-ui/client.js
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
export { default as ListData, List, ListLayout } from './client/pages/List/index';
export { default as ListManage } from './client/pages/List/Management';
export { default as FieldSelect } from './client/pages/List/FieldSelect';
export { default as Search } from './client/pages/List/Search';
export { default as ActiveFilters } from './client/pages/List/Filters/ActiveFilters';
export { default as Pagination, getPaginationLabel } from './client/pages/List/Pagination';
export { default as ListTable } from './client/components/ListTable';
export { default as CreateItemModal } from './client/components/CreateItemModal';
export { default as DeleteItemModal } from './client/components/DeleteItemModal';
export { default as DeleteManyItemsModal } from './client/components/DeleteManyItemsModal';
export { default as PageLoading } from './client/components/PageLoading';
export { default as ToastContainer } from './client/components/ToastContainer';
export { default as UpdateManyItemsModal } from './client/components/UpdateManyItemsModal';
export { Popout } from './client/components/Popout';
export { useAdminMeta } from './client/providers/AdminMeta';
3 changes: 2 additions & 1 deletion packages/app-admin-ui/client/components/CreateItemModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ let Render = ({ children }) => children();
class CreateItemModal extends Component {
constructor(props) {
super(props);
const { list, prefillData } = props;
const { list, prefillData = {} } = props;
const item = list.getInitialItemData({ prefill: prefillData });
const validationErrors = {};
const validationWarnings = {};
Expand Down Expand Up @@ -168,6 +168,7 @@ class CreateItemModal extends Component {
/* TODO: Permission query results */
errors={validationErrors[field.path] || []}
warnings={validationWarnings[field.path] || []}
CreateItemModal={CreateItemModalWithMutation}
onChange={onChange}
renderContext="dialog"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { omit, arrayToObject, countArrays } from '@keystonejs/utils';
import { LoadingIndicator } from '@arch-ui/loading';

import { validateFields } from '../util';
import CreateItemModal from './CreateItemModal';

let Render = ({ children }) => children();

Expand Down Expand Up @@ -178,6 +179,7 @@ class UpdateManyModal extends Component {
warnings={validationWarnings[field.path] || []}
onChange={onChange}
renderContext="dialog"
CreateItemModal={CreateItemModal}
/>
),
[
Expand Down
1 change: 1 addition & 0 deletions packages/app-admin-ui/client/pages/Item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ const ItemDetails = withRouter(
savedValue={savedData[field.path]}
onChange={onChange}
renderContext="page"
CreateItemModal={CreateItemModal}
/>
),
[
Expand Down
Loading

0 comments on commit 1a723a5

Please sign in to comment.