From b9e265e6fe0e4e84c491e816852944c423270425 Mon Sep 17 00:00:00 2001 From: Yulei Chen Date: Wed, 12 Apr 2023 13:10:34 +0800 Subject: [PATCH] #2441 - Refactor constants according to review --- .../ui/dialog/template/template-attach.jsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/ketcher-react/src/script/ui/dialog/template/template-attach.jsx b/packages/ketcher-react/src/script/ui/dialog/template/template-attach.jsx index 344368244a..57b09648e7 100644 --- a/packages/ketcher-react/src/script/ui/dialog/template/template-attach.jsx +++ b/packages/ketcher-react/src/script/ui/dialog/template/template-attach.jsx @@ -192,9 +192,14 @@ const editorStyles = { } class Attach extends Component { + MODES = { + SAVE: 'save', + EDIT: 'edit' + } + constructor({ onInit, ...props }) { super() - this.mode = isEmpty(props.tmpl.props) ? 'save' : 'edit' + this.mode = isEmpty(props.tmpl.props) ? this.MODES.SAVE : this.MODES.EDIT this.tmpl = initTmpl(props.tmpl) onInit(this.tmpl.struct.name, this.tmpl.props) this.onResult = this.onResult.bind(this) @@ -232,10 +237,14 @@ class Attach extends Component { const options = Object.assign(editorStyles, this.props.globalSettings, { scale: getScale(struct) }) + const dialogTitle = + this.mode === this.MODES.SAVE ? 'Save to Templates' : 'Template Edit' + const warningObject = + this.mode === this.MODES.SAVE ? 'Templates' : 'Edited templates' return ( this.props.formState.valid && name} params={prop} @@ -244,8 +253,8 @@ class Attach extends Component { >
- {this.mode === 'save' ? 'Templates' : 'Edited templates'} are saved - locally and cannot be accessed on different browsers or computers. + {warningObject} are saved locally and cannot be accessed on + different browsers or computers.
Be aware that other users of the same computer and browser can @@ -301,7 +310,7 @@ class Attach extends Component { className={classes.button} disabled={!this.checkIsValidName(name)} > - {this.mode === 'save' ? 'Save' : 'Edit'} + {this.mode === this.MODES.SAVE ? 'Save' : 'Edit'}