From 12f26dde84f8f532d37bff400b9b6f8babc3d968 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 --- 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 +++++ 4 files changed, 23 insertions(+) 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