Use react-toolbox buttons. Added Cancel button for the entry editor.
This commit is contained in:
parent
6fa02bf79b
commit
190aa05d68
@ -1,8 +1,16 @@
|
|||||||
|
import history from '../routing/history';
|
||||||
|
|
||||||
export const SWITCH_VISUAL_MODE = 'SWITCH_VISUAL_MODE';
|
export const SWITCH_VISUAL_MODE = 'SWITCH_VISUAL_MODE';
|
||||||
|
|
||||||
export function switchVisualMode(useVisualMode) {
|
export function switchVisualMode(useVisualMode) {
|
||||||
return {
|
return {
|
||||||
type: SWITCH_VISUAL_MODE,
|
type: SWITCH_VISUAL_MODE,
|
||||||
payload: useVisualMode
|
payload: useVisualMode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cancelEdit() {
|
||||||
|
return () => {
|
||||||
|
history.goBack();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
:root {
|
||||||
|
--defaultColorLight: #eee;
|
||||||
|
--backgroundColor: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
.root {
|
.root {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 64px;
|
top: 64px;
|
||||||
@ -5,23 +10,27 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
flex: 0;
|
flex: 0;
|
||||||
background: #fff;
|
|
||||||
height: 45px;
|
|
||||||
border-top: 1px solid #e8eae8;
|
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
|
border-top: 1px solid var(--defaultColorLight);
|
||||||
|
background: var(--backgroundColor);
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controlPane {
|
.controlPane {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
border-right: 1px solid #e8eae8;
|
border-right: 1px solid var(--defaultColorLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
.previewPane {
|
.previewPane {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
|
import { Button } from 'react-toolbox/lib/button';
|
||||||
import { ScrollSync, ScrollSyncPane } from '../ScrollSync';
|
import { ScrollSync, ScrollSyncPane } from '../ScrollSync';
|
||||||
import ControlPane from '../ControlPanel/ControlPane';
|
import ControlPane from '../ControlPanel/ControlPane';
|
||||||
import PreviewPane from '../PreviewPane/PreviewPane';
|
import PreviewPane from '../PreviewPane/PreviewPane';
|
||||||
@ -7,7 +8,14 @@ import styles from './EntryEditor.css';
|
|||||||
|
|
||||||
export default function EntryEditor(
|
export default function EntryEditor(
|
||||||
{
|
{
|
||||||
collection, entry, getMedia, onChange, onAddMedia, onRemoveMedia, onPersist
|
collection,
|
||||||
|
entry,
|
||||||
|
getMedia,
|
||||||
|
onChange,
|
||||||
|
onAddMedia,
|
||||||
|
onRemoveMedia,
|
||||||
|
onPersist,
|
||||||
|
onCancelEdit,
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<div className={styles.root}>
|
<div className={styles.root}>
|
||||||
@ -35,7 +43,17 @@ export default function EntryEditor(
|
|||||||
</div>
|
</div>
|
||||||
</ScrollSync>
|
</ScrollSync>
|
||||||
<div className={styles.footer}>
|
<div className={styles.footer}>
|
||||||
<button onClick={onPersist}>Save</button>
|
<Button
|
||||||
|
primary
|
||||||
|
raised
|
||||||
|
onClick={onPersist}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
{' '}
|
||||||
|
<Button onClick={onCancelEdit}>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -49,4 +67,5 @@ EntryEditor.propTypes = {
|
|||||||
onChange: PropTypes.func.isRequired,
|
onChange: PropTypes.func.isRequired,
|
||||||
onPersist: PropTypes.func.isRequired,
|
onPersist: PropTypes.func.isRequired,
|
||||||
onRemoveMedia: PropTypes.func.isRequired,
|
onRemoveMedia: PropTypes.func.isRequired,
|
||||||
|
onCancelEdit: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
@ -7,12 +7,13 @@ import {
|
|||||||
createEmptyDraft,
|
createEmptyDraft,
|
||||||
discardDraft,
|
discardDraft,
|
||||||
changeDraft,
|
changeDraft,
|
||||||
persistEntry
|
persistEntry,
|
||||||
} from '../actions/entries';
|
} from '../actions/entries';
|
||||||
|
import { cancelEdit } from '../actions/editor';
|
||||||
import { addMedia, removeMedia } from '../actions/media';
|
import { addMedia, removeMedia } from '../actions/media';
|
||||||
import { selectEntry, getMedia } from '../reducers';
|
import { selectEntry, getMedia } from '../reducers';
|
||||||
import EntryEditor from '../components/EntryEditor/EntryEditor';
|
import EntryEditor from '../components/EntryEditor/EntryEditor';
|
||||||
import EntryPageHOC from './editorialWorkflow/EntryPageHOC';
|
import entryPageHOC from './editorialWorkflow/EntryPageHOC';
|
||||||
|
|
||||||
class EntryPage extends React.Component {
|
class EntryPage extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@ -28,6 +29,7 @@ class EntryPage extends React.Component {
|
|||||||
loadEntry: PropTypes.func.isRequired,
|
loadEntry: PropTypes.func.isRequired,
|
||||||
persistEntry: PropTypes.func.isRequired,
|
persistEntry: PropTypes.func.isRequired,
|
||||||
removeMedia: PropTypes.func.isRequired,
|
removeMedia: PropTypes.func.isRequired,
|
||||||
|
cancelEdit: PropTypes.func.isRequired,
|
||||||
slug: PropTypes.string,
|
slug: PropTypes.string,
|
||||||
newEntry: PropTypes.bool.isRequired,
|
newEntry: PropTypes.bool.isRequired,
|
||||||
};
|
};
|
||||||
@ -56,7 +58,7 @@ class EntryPage extends React.Component {
|
|||||||
this.props.discardDraft();
|
this.props.discardDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
createDraft = entry => {
|
createDraft = (entry) => {
|
||||||
if (entry) this.props.createDraftFromEntry(entry);
|
if (entry) this.props.createDraftFromEntry(entry);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,10 +68,19 @@ class EntryPage extends React.Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
entry, entryDraft, boundGetMedia, collection, changeDraft, addMedia, removeMedia
|
entry,
|
||||||
|
entryDraft,
|
||||||
|
boundGetMedia,
|
||||||
|
collection,
|
||||||
|
changeDraft,
|
||||||
|
addMedia,
|
||||||
|
removeMedia,
|
||||||
|
cancelEdit,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
if (entryDraft == null || entryDraft.get('entry') == undefined || entry && entry.get('isFetching')) {
|
if (entryDraft == null
|
||||||
|
|| entryDraft.get('entry') === undefined
|
||||||
|
|| (entry && entry.get('isFetching'))) {
|
||||||
return <div>Loading...</div>;
|
return <div>Loading...</div>;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
@ -81,18 +92,12 @@ class EntryPage extends React.Component {
|
|||||||
onAddMedia={addMedia}
|
onAddMedia={addMedia}
|
||||||
onRemoveMedia={removeMedia}
|
onRemoveMedia={removeMedia}
|
||||||
onPersist={this.handlePersistEntry}
|
onPersist={this.handlePersistEntry}
|
||||||
|
onCancelEdit={cancelEdit}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Instead of checking the publish mode everywhere to dispatch & render the additional editorial workflow stuff,
|
|
||||||
* We delegate it to a Higher Order Component
|
|
||||||
*/
|
|
||||||
EntryPage = EntryPageHOC(EntryPage);
|
|
||||||
|
|
||||||
function mapStateToProps(state, ownProps) {
|
function mapStateToProps(state, ownProps) {
|
||||||
const { collections, entryDraft } = state;
|
const { collections, entryDraft } = state;
|
||||||
const collection = collections.get(ownProps.params.name);
|
const collection = collections.get(ownProps.params.name);
|
||||||
@ -113,6 +118,7 @@ export default connect(
|
|||||||
createDraftFromEntry,
|
createDraftFromEntry,
|
||||||
createEmptyDraft,
|
createEmptyDraft,
|
||||||
discardDraft,
|
discardDraft,
|
||||||
persistEntry
|
persistEntry,
|
||||||
|
cancelEdit,
|
||||||
}
|
}
|
||||||
)(EntryPage);
|
)(entryPageHOC(EntryPage));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user