Skip to content

Commit

Permalink
Merge pull request #386 from PathwayCommons/editor-selector
Browse files Browse the repository at this point in the history
add editor selector button to the factoid menu
  • Loading branch information
maxkfranz committed Nov 16, 2018
2 parents 88b887d + 02a74a1 commit 9865f7c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 41 deletions.
47 changes: 13 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/client/components/editor/index.js
Expand Up @@ -352,7 +352,7 @@ class Editor extends DataComponent {
])
]),
h('div.editor-main-menu', [
h(MainMenu, { bus, document, history })
h(MainMenu, { bus, document, history, networkEditor: true })
]),
h('div.editor-submit', [
h(Popover, { tippy: { html: h(TaskView, { document, bus } ) } }, [
Expand Down
20 changes: 16 additions & 4 deletions src/client/components/main-menu.js
Expand Up @@ -38,7 +38,7 @@ class MenuContent extends Component {
}

render(){
const { bus, document, history, emitter } = this.props;
const { bus, document, history, emitter, networkEditor } = this.props;
const { selectedLinkouts, selectedMyFactoids } = this.state;

const set = (props, children) => h('div.main-menu-set', props, children);
Expand All @@ -55,6 +55,17 @@ class MenuContent extends Component {
h('span', label)
]);

let editorSwitcher = ( document, networkEditor) => {
if( document == null ){ return null; }

let id = document.id();
let secret = document.secret();
let label = networkEditor ? 'Form Editor' : 'Network Editor';
let url = `/${networkEditor ? 'form' : 'document'}/${id}/${secret}`;

return item({ label, action: () => history.push(url) });
};

let content;

if( selectedLinkouts ){
Expand All @@ -77,7 +88,8 @@ class MenuContent extends Component {
]) : null,
set({ key: 'nav' }, [
item({ label: 'New factoid', action: () => history.push('/new') }),
item({ label: 'My factoids', action: () => this.selectMyFactoids(), actionCloses: false })
item({ label: 'My factoids', action: () => this.selectMyFactoids(), actionCloses: false }),
editorSwitcher( document, networkEditor )
])
]);
}
Expand All @@ -95,7 +107,7 @@ class MainMenu extends Component {

render(){
let { emitter } = this;
let { bus, document, history, title } = this.props;
let { bus, document, history, title, networkEditor } = this.props;

return h('div.main-menu', [
h(Popover, {
Expand All @@ -104,7 +116,7 @@ class MainMenu extends Component {
onHide: () => emitter.emit('hide'),
onShow: () => emitter.emit('show'),
placement: 'bottom',
html: h(MenuContent, { bus, document, history, emitter })
html: h(MenuContent, { bus, document, history, emitter, networkEditor })
}
}, [
h(Tooltip, { description: 'Menu', tippy: { placement: 'bottom' } }, [
Expand Down
6 changes: 4 additions & 2 deletions src/client/router.js
Expand Up @@ -81,8 +81,9 @@ let routes = [
path: '/form/:id',
render: props => {
let { id } = props.match.params;
let { history } = props;

return h( FormEditor, { id } );
return h( FormEditor, { id, history } );
}
},
{
Expand All @@ -98,8 +99,9 @@ let routes = [
path: '/document/:id',
render: props => {
let { id } = props.match.params;
let { history } = props;

return h( Editor, { id } );
return h( Editor, { id, history } );
}
},
{
Expand Down

0 comments on commit 9865f7c

Please sign in to comment.