fix(editor): pass back link to editor toolbar (#4000)
This commit is contained in:
parent
100b0645a1
commit
c3a680ff52
@ -368,6 +368,7 @@ export class Editor extends React.Component {
|
|||||||
draftKey,
|
draftKey,
|
||||||
slug,
|
slug,
|
||||||
t,
|
t,
|
||||||
|
editorBackLink,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const isPublished = !newEntry && !unpublishedEntry;
|
const isPublished = !newEntry && !unpublishedEntry;
|
||||||
@ -416,6 +417,7 @@ export class Editor extends React.Component {
|
|||||||
onLogoutClick={logoutUser}
|
onLogoutClick={logoutUser}
|
||||||
deployPreview={deployPreview}
|
deployPreview={deployPreview}
|
||||||
loadDeployPreview={opts => loadDeployPreview(collection, slug, entry, isPublished, opts)}
|
loadDeployPreview={opts => loadDeployPreview(collection, slug, entry, isPublished, opts)}
|
||||||
|
editorBackLink={editorBackLink}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -442,6 +444,13 @@ function mapStateToProps(state, ownProps) {
|
|||||||
const deployPreview = selectDeployPreview(state, collectionName, slug);
|
const deployPreview = selectDeployPreview(state, collectionName, slug);
|
||||||
const localBackup = entryDraft.get('localBackup');
|
const localBackup = entryDraft.get('localBackup');
|
||||||
const draftKey = entryDraft.get('key');
|
const draftKey = entryDraft.get('key');
|
||||||
|
let editorBackLink = `/collections/${collectionName}`;
|
||||||
|
if (collection.has('nested') && slug) {
|
||||||
|
const pathParts = slug.split('/');
|
||||||
|
if (pathParts.length > 2) {
|
||||||
|
editorBackLink = `${editorBackLink}/filter/${pathParts.slice(0, -2).join('/')}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
collection,
|
collection,
|
||||||
@ -464,6 +473,7 @@ function mapStateToProps(state, ownProps) {
|
|||||||
draftKey,
|
draftKey,
|
||||||
publishedEntry,
|
publishedEntry,
|
||||||
unPublishedEntry,
|
unPublishedEntry,
|
||||||
|
editorBackLink,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,6 +185,7 @@ class EditorInterface extends Component {
|
|||||||
loadDeployPreview,
|
loadDeployPreview,
|
||||||
deployPreview,
|
deployPreview,
|
||||||
draftKey,
|
draftKey,
|
||||||
|
editorBackLink,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const { previewVisible, scrollSyncEnabled, showEventBlocker } = this.state;
|
const { previewVisible, scrollSyncEnabled, showEventBlocker } = this.state;
|
||||||
@ -263,6 +264,7 @@ class EditorInterface extends Component {
|
|||||||
onLogoutClick={onLogoutClick}
|
onLogoutClick={onLogoutClick}
|
||||||
loadDeployPreview={loadDeployPreview}
|
loadDeployPreview={loadDeployPreview}
|
||||||
deployPreview={deployPreview}
|
deployPreview={deployPreview}
|
||||||
|
editorBackLink={editorBackLink}
|
||||||
/>
|
/>
|
||||||
<Editor key={draftKey}>
|
<Editor key={draftKey}>
|
||||||
<ViewControls>
|
<ViewControls>
|
||||||
|
@ -5,7 +5,7 @@ import { css } from '@emotion/core';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import { translate } from 'react-polyglot';
|
import { translate } from 'react-polyglot';
|
||||||
import { Map } from 'immutable';
|
import { Map } from 'immutable';
|
||||||
import history from 'Routing/history';
|
import { Link } from 'react-router-dom';
|
||||||
import {
|
import {
|
||||||
Icon,
|
Icon,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
@ -80,7 +80,7 @@ const ToolbarSubSectionLast = styled(ToolbarSubSectionFirst)`
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ToolbarSectionBackLink = styled.a`
|
const ToolbarSectionBackLink = styled(Link)`
|
||||||
${styles.toolbarSection};
|
${styles.toolbarSection};
|
||||||
border-right-width: 1px;
|
border-right-width: 1px;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@ -247,6 +247,7 @@ class EditorToolbar extends React.Component {
|
|||||||
deployPreview: ImmutablePropTypes.map,
|
deployPreview: ImmutablePropTypes.map,
|
||||||
loadDeployPreview: PropTypes.func.isRequired,
|
loadDeployPreview: PropTypes.func.isRequired,
|
||||||
t: PropTypes.func.isRequired,
|
t: PropTypes.func.isRequired,
|
||||||
|
editorBackLink: PropTypes.string.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -564,19 +565,20 @@ class EditorToolbar extends React.Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { user, hasChanged, displayUrl, collection, hasWorkflow, onLogoutClick, t } = this.props;
|
const {
|
||||||
|
user,
|
||||||
|
hasChanged,
|
||||||
|
displayUrl,
|
||||||
|
collection,
|
||||||
|
hasWorkflow,
|
||||||
|
onLogoutClick,
|
||||||
|
t,
|
||||||
|
editorBackLink,
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ToolbarContainer>
|
<ToolbarContainer>
|
||||||
<ToolbarSectionBackLink
|
<ToolbarSectionBackLink to={editorBackLink}>
|
||||||
onClick={() => {
|
|
||||||
if (history.length > 2) {
|
|
||||||
history.goBack();
|
|
||||||
} else {
|
|
||||||
history.push(`/collections/${collection.get('name')}`);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<BackArrow>←</BackArrow>
|
<BackArrow>←</BackArrow>
|
||||||
<div>
|
<div>
|
||||||
<BackCollection>
|
<BackCollection>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user