remove contentview selector and view description if edit mode is on

This commit is contained in:
cle1000 2017-02-08 21:09:03 +01:00
parent b4bed57d4c
commit fb06c66437
2 changed files with 5 additions and 14 deletions

View File

@ -12,13 +12,13 @@ ContentViewOptions.propTypes = {
function ContentViewOptions({ flow, message, uploadContent, readonly, contentViewDescription }) {
return (
<div className="view-options">
<ViewSelector message={message}/>
{readonly ? <ViewSelector message={message}/> : <span><b>View:</b> edit</span>}
&nbsp;
<DownloadContentButton flow={flow} message={message}/>
&nbsp;
{!readonly && <UploadContentButton uploadContent={uploadContent}/> }
&nbsp;
<span>{contentViewDescription}</span>
{readonly && <span>{contentViewDescription}</span>}
</div>
)
}

View File

@ -1,6 +1,5 @@
import React, { PropTypes, Component } from 'react'
import { connect } from 'react-redux'
import * as ContentViews from './ContentViews'
import { setContentView } from '../../ducks/ui/flow';
import Dropdown from '../common/Dropdown'
@ -8,27 +7,20 @@ import Dropdown from '../common/Dropdown'
ViewSelector.propTypes = {
contentViews: PropTypes.array.isRequired,
activeView: PropTypes.string.isRequired,
isEdit: PropTypes.bool.isRequired,
setContentView: PropTypes.func.isRequired
}
function ViewSelector ({contentViews, activeView, isEdit, setContentView}){
let edit = ContentViews.Edit.displayName
let inner = <span> <b>View:</b> {activeView} <span className="caret"></span> </span>
function ViewSelector ({contentViews, activeView, setContentView}){
let inner = <span> <b>View:</b> {activeView.toLowerCase()} <span className="caret"></span> </span>
return (
<Dropdown dropup className="pull-left" btnClass="btn btn-default btn-xs" text={inner}>
{contentViews.map(name =>
<a href="#" key={name} onClick={e => {e.preventDefault(); setContentView(name)}}>
<a href="#" key={name} onClick={e => {e.preventDefault(); setContentView(name)}}>
{name.toLowerCase().replace('_', ' ')}
</a>
)
}
{isEdit &&
<a href="#" onClick={e => {e.preventDefault(); setContentView(edit)}}>
{edit.toLowerCase()}
</a>
}
</Dropdown>
)
}
@ -37,7 +29,6 @@ export default connect (
state => ({
contentViews: state.settings.contentViews,
activeView: state.ui.flow.contentView,
isEdit: !!state.ui.flow.modifiedFlow,
}), {
setContentView,
}