Skip to content

Commit

Permalink
Admin UI: fixed a regression in the Create Relationship workflow (#3124)
Browse files Browse the repository at this point in the history
* Admin UI: fixed a regression in the Create Relationship workflow

* Fixup changeset

Co-authored-by: Mike <mike@madebymike.com.au>
  • Loading branch information
Vultraz and MadeByMike committed Jun 6, 2020
1 parent 211009a commit 37f57c3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/lovely-rockets-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@keystonejs/app-admin-ui': patch
---

Fixed a regression in the Create Relationship workflow.
8 changes: 5 additions & 3 deletions packages/app-admin-ui/client/components/CreateItemModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const useEventCallback = callback => {
return cb;
};

const CreateItemModal = ({ prefillData = {}, onClose, onCreate }) => {
const CreateItemModal = ({ prefillData = {}, onClose, onCreate, viewOnSave }) => {
const { list, closeCreateItemModal, isCreateItemModalOpen } = useList();

const [item, setItem] = useState(list.getInitialItemData({ prefill: prefillData }));
Expand Down Expand Up @@ -123,8 +123,10 @@ const CreateItemModal = ({ prefillData = {}, onClose, onCreate }) => {
onCreate(savedData);
}

const newItemID = savedData.data[list.gqlNames.createMutationName].id;
history.push(`${list.fullPath}/${newItemID}`);
if (viewOnSave) {
const newItemID = savedData.data[list.gqlNames.createMutationName].id;
history.push(`${list.fullPath}/${newItemID}`);
}
});

const _onClose = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/pages/Home/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const BoxComponent = ({ focusOrigin, isActive, isHover, isFocus, meta, ...props
<A11yText>Create {singular}</A11yText>
</CreateButton>
</BoxElement>
<CreateItemModal />
<CreateItemModal viewOnSave />
</Fragment>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/pages/Item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ const ItemDetails = ({ list, item: initialData, itemErrors, onUpdate }) => {
/>
</Card>

<CreateItemModal />
<CreateItemModal viewOnSave />
<DeleteItemModal
isOpen={showDeleteModal}
item={initialData}
Expand Down
2 changes: 1 addition & 1 deletion packages/app-admin-ui/client/pages/List/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function ListLayout(props) {
</HeaderInset>
</Container>

<CreateItemModal />
<CreateItemModal viewOnSave />

<Container isFullWidth>
<ListTable
Expand Down

0 comments on commit 37f57c3

Please sign in to comment.