diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/System/Options/Edit.js | 8 | ||||
| -rw-r--r-- | src/web/src/components/System/Options/View.js | 12 | ||||
| -rw-r--r-- | src/web/src/components/System/Options/index.js | 16 | ||||
| -rw-r--r-- | src/web/src/components/System/System.js | 6 |
4 files changed, 30 insertions, 12 deletions
diff --git a/src/web/src/components/System/Options/Edit.js b/src/web/src/components/System/Options/Edit.js index 78ad3c80..6623e034 100644 --- a/src/web/src/components/System/Options/Edit.js +++ b/src/web/src/components/System/Options/Edit.js @@ -6,7 +6,7 @@ import CodeEditor from '@uiw/react-textarea-code-editor'; import { getYaml, validateYaml, updateYaml } from '../../../lib/options'; import PlaceholderSegment from '../../Shared/PlaceholderSegment'; -const Edit = ({ options }) => { +const Edit = ({ cancelAction }) => { const [{ loading, error }, setLoading] = useState({ loading: true, error: false }); const [{ yaml, isDirty }, setYaml] = useState({ yaml: undefined, isDirty: false }); const [yamlError, setYamlError] = useState(); @@ -42,12 +42,10 @@ const Edit = ({ options }) => { if (!yamlError) { await updateYaml({ yaml }); - await get(); + cancelAction(); } } - const cancel = () => get(); - if (loading) { return <PlaceholderSegment loading={true}/> } @@ -60,7 +58,7 @@ const Edit = ({ options }) => { <> <div style={{textAlign: 'right'}}> <Button primary disabled={!isDirty} onClick={() => save(yaml)}><Icon name='save'/>Save</Button> - {isDirty && <Button onClick={cancel}><Icon name='close'/>Cancel</Button>} + <Button onClick={() => cancelAction()}><Icon name='close'/>Cancel</Button> </div> {yamlError && <Message icon='x' negative>{yamlError}</Message>} <CodeEditor diff --git a/src/web/src/components/System/Options/View.js b/src/web/src/components/System/Options/View.js index ba7cf426..f232c61d 100644 --- a/src/web/src/components/System/Options/View.js +++ b/src/web/src/components/System/Options/View.js @@ -1,10 +1,16 @@ import React from 'react'; +import { Button, Table } from 'semantic-ui-react'; + +const View = ({ options, editAction }) => { + const { remoteConfiguration } = options; -const View = ({ options }) => { return ( - <div> + <> + {remoteConfiguration && <div style={{textAlign: 'right'}}> + <Button primary disabled={!remoteConfiguration} onClick={() => editAction()}>Edit</Button> + </div>} <pre>{JSON.stringify(options, null, 2)}</pre> - </div> + </> ); } diff --git a/src/web/src/components/System/Options/index.js b/src/web/src/components/System/Options/index.js new file mode 100644 index 00000000..9e92b423 --- /dev/null +++ b/src/web/src/components/System/Options/index.js @@ -0,0 +1,16 @@ +import React, { useState } from 'react'; + +import Edit from './Edit'; +import View from './View'; + +const Index = ({ options }) => { + const [mode, setMode] = useState('view'); + + if (mode === 'edit') { + return <Edit cancelAction={() => setMode('view')}/> + } + + return <View options={options} editAction={() => setMode('edit')}/> +} + +export default Index;
\ No newline at end of file diff --git a/src/web/src/components/System/System.js b/src/web/src/components/System/System.js index 037e6ea3..bbba292d 100644 --- a/src/web/src/components/System/System.js +++ b/src/web/src/components/System/System.js @@ -3,8 +3,7 @@ import { Segment, Tab } from 'semantic-ui-react'; import './System.css'; import Info from './Info'; import Logs from './Logs'; -import OptionsView from './Options/View'; -import OptionsEdit from './Options/Edit'; +import Options from './Options'; class System extends Component { componentDidMount = () => { @@ -20,8 +19,7 @@ class System extends Component { <Segment raised> <Tab panes={[ { menuItem: 'Info', render: () => <Tab.Pane><Info state={this.props.state}/></Tab.Pane> }, - { menuItem: 'Options', render: () => <Tab.Pane><OptionsView options={this.props.options}/></Tab.Pane> }, - { menuItem: 'Edit', render: () => <Tab.Pane><OptionsEdit/></Tab.Pane> }, + { menuItem: 'Options', render: () => <Tab.Pane><Options options={this.props.options}/></Tab.Pane> }, { menuItem: 'Logs', render: () => <Tab.Pane><Logs/></Tab.Pane> }, ]}/> </Segment> |
