back button path

This commit is contained in:
Virginie Ky 2019-07-04 13:58:38 +02:00
parent c37f9e54df
commit b74d080c1b
6 changed files with 36 additions and 7 deletions

View File

@ -3,6 +3,7 @@ const colors = {
black: '#3b3b3b',
brightGrey: '#f0f3f8',
green: '#27b70f',
grey: '#f7f8f8',
greyOpacity: 'rgba(14, 22, 34, 0.02)',
lightGrey: '#fafafa',

View File

@ -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%;
}

View File

@ -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};
}
`;

View File

@ -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({

View File

@ -136,6 +136,17 @@ describe('CTB <GroupPage />', () => {
expect(getFeatureName()).toEqual('tests');
});
});
describe('HandleGoBack', () => {
it("should return the model's name field", () => {
const { handleGoBack } = shallow(<GroupPage {...props} />).instance();
handleGoBack();
expect(props.history.push).toHaveBeenCalledWith(
'/plugins/content-type-builder/groups'
);
});
});
});
describe('CTB <GroupPage />, mapDispatchToProps', () => {

View File

@ -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 {