From 715764bfe448fc6a80ca3858377b4f760d39c611 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Thu, 13 Jul 2023 09:45:53 -0400 Subject: [PATCH] Adds N V for variable creation as a keyboard shortcut --- .changelog/17932.txt | 3 +++ ui/app/controllers/variables/index.js | 4 ++++ ui/app/controllers/variables/path.js | 9 +++++++++ ui/app/templates/variables/index.hbs | 5 +++++ ui/app/templates/variables/path.hbs | 5 +++++ 5 files changed, 26 insertions(+) create mode 100644 .changelog/17932.txt diff --git a/.changelog/17932.txt b/.changelog/17932.txt new file mode 100644 index 00000000000..bf2c06128f4 --- /dev/null +++ b/.changelog/17932.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: adds a keyboard shortcut for Create Variable +``` diff --git a/ui/app/controllers/variables/index.js b/ui/app/controllers/variables/index.js index bd8d712a1da..0b5f2dc2ee3 100644 --- a/ui/app/controllers/variables/index.js +++ b/ui/app/controllers/variables/index.js @@ -20,6 +20,10 @@ export default class VariablesIndexController extends Controller { this.router.transitionTo('variables.variable', variable.path); } + @action goToNewVariable() { + this.router.transitionTo('variables.new'); + } + @controller variables; @action diff --git a/ui/app/controllers/variables/path.js b/ui/app/controllers/variables/path.js index 69a1a6c9c13..c2f21483136 100644 --- a/ui/app/controllers/variables/path.js +++ b/ui/app/controllers/variables/path.js @@ -4,11 +4,14 @@ */ import Controller, { inject as controller } from '@ember/controller'; +import { inject as service } from '@ember/service'; import { action } from '@ember/object'; const ALL_NAMESPACE_WILDCARD = '*'; export default class VariablesPathController extends Controller { + @service router; + get absolutePath() { return this.model?.absolutePath || ''; } @@ -28,6 +31,12 @@ export default class VariablesPathController extends Controller { } } + @action goToNewVariable() { + this.router.transitionTo('variables.new', { + queryParams: { path: `${this.absolutePath}/` }, + }); + } + @controller variables; @action diff --git a/ui/app/templates/variables/index.hbs b/ui/app/templates/variables/index.hbs index 37c62d03491..062df782cb6 100644 --- a/ui/app/templates/variables/index.hbs +++ b/ui/app/templates/variables/index.hbs @@ -22,6 +22,11 @@ @route="variables.new" class="button is-primary" data-test-create-var + {{keyboard-shortcut + pattern=(array "n" "v") + action=(action this.goToNewVariable) + label="Create Variable" + }} > Create Variable diff --git a/ui/app/templates/variables/path.hbs b/ui/app/templates/variables/path.hbs index ed574c7b6df..505f5f1288f 100644 --- a/ui/app/templates/variables/path.hbs +++ b/ui/app/templates/variables/path.hbs @@ -25,6 +25,11 @@ @route="variables.new" @query={{hash path=(concat this.absolutePath "/")}} class="button is-primary" + {{keyboard-shortcut + pattern=(array "n" "v") + action=(action this.goToNewVariable) + label="Create Variable" + }} > Create Variable