From b74d080c1b9c3071939baa111d9d27be906caae2 Mon Sep 17 00:00:00 2001 From: Virginie Ky Date: Thu, 4 Jul 2019 13:58:38 +0200 Subject: [PATCH] back button path --- .../lib/src/assets/styles/colors.js | 1 + .../lib/src/components/ListWrapper/index.js | 2 +- .../admin/src/components/ListRow/StyledListRow.js | 10 ++++++---- .../admin/src/containers/GroupPage/index.js | 10 +++++++++- .../src/containers/GroupPage/tests/index.test.js | 11 +++++++++++ .../admin/src/containers/ModelPage/index.js | 9 ++++++++- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/packages/strapi-helper-plugin/lib/src/assets/styles/colors.js b/packages/strapi-helper-plugin/lib/src/assets/styles/colors.js index 1c342c4a41..3d7bab26bc 100644 --- a/packages/strapi-helper-plugin/lib/src/assets/styles/colors.js +++ b/packages/strapi-helper-plugin/lib/src/assets/styles/colors.js @@ -3,6 +3,7 @@ const colors = { black: '#3b3b3b', brightGrey: '#f0f3f8', green: '#27b70f', + grey: '#f7f8f8', greyOpacity: 'rgba(14, 22, 34, 0.02)', lightGrey: '#fafafa', diff --git a/packages/strapi-helper-plugin/lib/src/components/ListWrapper/index.js b/packages/strapi-helper-plugin/lib/src/components/ListWrapper/index.js index 0d78297ae9..93b585049d 100644 --- a/packages/strapi-helper-plugin/lib/src/components/ListWrapper/index.js +++ b/packages/strapi-helper-plugin/lib/src/components/ListWrapper/index.js @@ -13,7 +13,7 @@ const ListWrapper = styled.div` overflow-x: scroll; } .list-button { - padding: 10px 30px 25px 30px; + padding: 1rem 3rem 2.5rem 3rem; button { width: 100%; } diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/ListRow/StyledListRow.js b/packages/strapi-plugin-content-type-builder/admin/src/components/ListRow/StyledListRow.js index ab1cb499d9..97160abc22 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/ListRow/StyledListRow.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/ListRow/StyledListRow.js @@ -6,6 +6,8 @@ import styled from 'styled-components'; +import { colors } from 'strapi-helper-plugin'; + const StyedListRow = styled.tr` background-color: transparent; cursor: pointer; @@ -15,8 +17,8 @@ const StyedListRow = styled.tr` img { width: 35px; } - &:hover { - background-color: #f7f8f8; + button { + cursor: pointer; } td:first-of-type { padding-left: 3rem; @@ -31,8 +33,8 @@ const StyedListRow = styled.tr` td:last-child { text-align: right; } - button { - cursor: pointer; + &:hover { + background-color: ${colors.grey}; } `; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js index f87aa5a73b..80fdd85a82 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/index.js @@ -108,7 +108,14 @@ export class GroupPage extends React.Component { deleteGroupAttribute(keys); }; - handleGoBack = () => this.props.history.goBack(); + handleGoBack = () => { + const { + location: { pathname }, + } = this.props; + const backPathname = pathname.substr(0, pathname.lastIndexOf('/')); + + this.props.history.push(backPathname); + }; isUpdatingTempFeature = () => { const { groups } = this.props; @@ -203,6 +210,7 @@ GroupPage.propTypes = { }), location: PropTypes.shape({ search: PropTypes.string.isRequired, + pathname: PropTypes.string.isRequired, }), match: PropTypes.shape({ params: PropTypes.shape({ diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/tests/index.test.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/tests/index.test.js index 65f014ba66..f8b67c452a 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/tests/index.test.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/GroupPage/tests/index.test.js @@ -136,6 +136,17 @@ describe('CTB ', () => { expect(getFeatureName()).toEqual('tests'); }); }); + + describe('HandleGoBack', () => { + it("should return the model's name field", () => { + const { handleGoBack } = shallow().instance(); + handleGoBack(); + + expect(props.history.push).toHaveBeenCalledWith( + '/plugins/content-type-builder/groups' + ); + }); + }); }); describe('CTB , mapDispatchToProps', () => { diff --git a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js index b9317ac93e..dc8c2a649c 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/containers/ModelPage/index.js @@ -373,7 +373,14 @@ export class ModelPage extends React.Component { this.setState({ attrToDelete: null, showWarning: false }); }; - handleGoBack = () => this.props.history.goBack(); + handleGoBack = () => { + const { + location: { pathname }, + } = this.props; + const backPathname = pathname.substr(0, pathname.lastIndexOf('/')); + + this.props.history.push(backPathname); + }; handleSubmit = (shouldContinue = false) => { const {