1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Save workspace when hitting Enter

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2020-09-09 14:59:42 +03:00
parent a128893522
commit af05b6761d

View File

@ -93,6 +93,12 @@ export class Workspaces extends React.Component {
}) })
} }
onInputKeypress = (evt: React.KeyboardEvent<any>, workspaceId: WorkspaceId) => {
if (evt.key == 'Enter') {
this.saveWorkspace(workspaceId);
}
}
render() { render() {
return ( return (
<WizardLayout className="Workspaces" infoPanel={this.renderInfo()}> <WizardLayout className="Workspaces" infoPanel={this.renderInfo()}>
@ -142,6 +148,7 @@ export class Workspaces extends React.Component {
placeholder={_i18n._(t`Name`)} placeholder={_i18n._(t`Name`)}
value={editingWorkspace.name} value={editingWorkspace.name}
onChange={v => editingWorkspace.name = v} onChange={v => editingWorkspace.name = v}
onKeyPress={(e) => this.onInputKeypress(e, workspaceId)}
autoFocus autoFocus
/> />
<Input <Input
@ -149,17 +156,18 @@ export class Workspaces extends React.Component {
placeholder={_i18n._(t`Description`)} placeholder={_i18n._(t`Description`)}
value={editingWorkspace.description} value={editingWorkspace.description}
onChange={v => editingWorkspace.description = v} onChange={v => editingWorkspace.description = v}
/> onKeyPress={(e) => this.onInputKeypress(e, workspaceId)}
<Icon
material="cancel"
tooltip={<Trans>Cancel</Trans>}
onClick={() => this.clearEditing(workspaceId)}
/> />
<Icon <Icon
material="save" material="save"
tooltip={<Trans>Save</Trans>} tooltip={<Trans>Save</Trans>}
onClick={() => this.saveWorkspace(workspaceId)} onClick={() => this.saveWorkspace(workspaceId)}
/> />
<Icon
material="cancel"
tooltip={<Trans>Cancel</Trans>}
onClick={() => this.clearEditing(workspaceId)}
/>
</Fragment> </Fragment>
)} )}
</div> </div>