Skip to content

Commit

Permalink
#2441 - Refactor constants according to review
Browse files Browse the repository at this point in the history
  • Loading branch information
yuleicul committed Apr 12, 2023
1 parent 8f612bd commit b9e265e
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 (
<TemplateEditDialog
title={this.mode === 'save' ? 'Save to Templates' : 'Template Edit'}
title={dialogTitle}
result={this.onResult}
valid={() => this.props.formState.valid && name}
params={prop}
Expand All @@ -244,8 +253,8 @@ class Attach extends Component {
>
<Message>
<div>
{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.
</div>
<div>
Be aware that other users of the same computer and browser can
Expand Down Expand Up @@ -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'}
</SaveButton>
</Buttons>
</RightColumn>
Expand Down

0 comments on commit b9e265e

Please sign in to comment.