From d3b1d58c4d164052641a693abfe1e8b8219c29ba Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Thu, 20 Jul 2023 11:38:52 -0500 Subject: [PATCH] backport of commit 715764bfe448fc6a80ca3858377b4f760d39c611 (#18010) This pull request was automerged via backport-assistant --- .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 000000000..bf2c06128 --- /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 bd8d712a1..0b5f2dc2e 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 69a1a6c9c..c2f214831 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 37c62d034..062df782c 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 ed574c7b6..505f5f128 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