diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/components/System/Options/Edit.js | 24 | ||||
| -rw-r--r-- | src/web/src/components/System/Options/View.js | 6 | ||||
| -rw-r--r-- | src/web/src/components/System/System.css | 15 |
3 files changed, 30 insertions, 15 deletions
diff --git a/src/web/src/components/System/Options/Edit.js b/src/web/src/components/System/Options/Edit.js index 0092279a..67739c98 100644 --- a/src/web/src/components/System/Options/Edit.js +++ b/src/web/src/components/System/Options/Edit.js @@ -1,14 +1,14 @@ import React, { useState, useEffect } from 'react'; import { Button, Icon, Message } from 'semantic-ui-react'; -import CodeEditor from './CodeEditor'; +import CodeEditor from '../../Shared/CodeEditor'; -import { getYaml, validateYaml, updateYaml } from '../../../lib/options'; +import { getYamlLocation, getYaml, validateYaml, updateYaml } from '../../../lib/options'; import PlaceholderSegment from '../../Shared/PlaceholderSegment'; -const Edit = ({ cancelAction }) => { +const Edit = ({ filename, cancelAction }) => { const [{ loading, error }, setLoading] = useState({ loading: true, error: false }); - const [{ yaml, isDirty }, setYaml] = useState({ yaml: undefined, isDirty: false }); + const [{ location, yaml, isDirty }, setYaml] = useState({ location: undefined, yaml: undefined, isDirty: false }); const [yamlError, setYamlError] = useState(); useEffect(() => { @@ -19,8 +19,9 @@ const Edit = ({ cancelAction }) => { setLoading({ loading: true, error: false }); try { - const yaml = await getYaml(); - setYaml({ yaml: yaml, isDirty: false }) + const [location, yaml] = await Promise.all([getYamlLocation(), getYaml()]); + + setYaml({ location, yaml, isDirty: false }) setLoading({ loading: false, error: false }) } catch (error) { setLoading({ loading: false, error: error.message }) @@ -28,7 +29,7 @@ const Edit = ({ cancelAction }) => { } const update = async (yaml) => { - setYaml({ yaml, isDirty: true }); + setYaml({ location, yaml, isDirty: true }); validate(yaml); } @@ -56,16 +57,19 @@ const Edit = ({ cancelAction }) => { return ( <> + <Message warning> + <Icon name='warning sign'/>Editing {location} + </Message> <div - className='code-container' - style={{height: yamlError ? 'calc(100vh - 316px)' : undefined}} + {...{ className: yamlError ? 'edit-code-container-error' : 'edit-code-container' }} + //style={{height: yamlError ? 'calc(100vh - 316px)' : undefined}} > <CodeEditor value={yaml} onChange={(value) => update(value)} /> </div> - {yamlError && <Message className='yaml-error' icon='x' negative>{yamlError}</Message>} + {yamlError && <Message className='yaml-error' negative><Icon name='x'/>{yamlError}</Message>} <div className='footer-buttons'> <Button primary disabled={!isDirty} onClick={() => save(yaml)}><Icon name='save'/>Save</Button> <Button onClick={() => cancelAction()}><Icon name='close'/>Cancel</Button> diff --git a/src/web/src/components/System/Options/View.js b/src/web/src/components/System/Options/View.js index c3a62214..83b24a88 100644 --- a/src/web/src/components/System/Options/View.js +++ b/src/web/src/components/System/Options/View.js @@ -2,16 +2,16 @@ import React from 'react'; import YAML from 'yaml'; import { Icon, Button } from 'semantic-ui-react'; -import CodeEditor from './CodeEditor'; +import CodeEditor from '../../Shared/CodeEditor'; const View = ({ options, editAction }) => { const { remoteConfiguration } = options; - const optionsAsYaml = YAML.stringify(options, { simpleKeys: true }) + const optionsAsYaml = YAML.stringify(options, { simpleKeys: true, sortMapEntries: true }) return ( <> - <div className='code-container'> + <div className='view-code-container'> <CodeEditor value={optionsAsYaml} basicSetup={false} diff --git a/src/web/src/components/System/System.css b/src/web/src/components/System/System.css index 23f05221..3d1594b7 100644 --- a/src/web/src/components/System/System.css +++ b/src/web/src/components/System/System.css @@ -38,8 +38,19 @@ text-align: right; } -.code-container { +.view-code-container, .edit-code-container, .edit-code-container-error { border: 1px solid #d4d4d5; overflow: auto; - height: calc(100vh - 254px); +} + +.view-code-container { + height: calc(100vh - 254px); +} + +.edit-code-container { + height: calc(100vh - 316px); +} + +.edit-code-container-error { + height: calc(100vh - 378px); }
\ No newline at end of file |
