Adds N V for variable creation as a keyboard shortcut (#17932)

This commit is contained in:
Phil Renaud
2023-07-20 12:38:35 -04:00
committed by GitHub
parent 287ad19f0f
commit 51393ddde7
5 changed files with 26 additions and 0 deletions

3
.changelog/17932.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:improvement
ui: adds a keyboard shortcut for Create Variable
```

View File

@@ -20,6 +20,10 @@ export default class VariablesIndexController extends Controller {
this.router.transitionTo('variables.variable', variable.path); this.router.transitionTo('variables.variable', variable.path);
} }
@action goToNewVariable() {
this.router.transitionTo('variables.new');
}
@controller variables; @controller variables;
@action @action

View File

@@ -4,11 +4,14 @@
*/ */
import Controller, { inject as controller } from '@ember/controller'; import Controller, { inject as controller } from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object'; import { action } from '@ember/object';
const ALL_NAMESPACE_WILDCARD = '*'; const ALL_NAMESPACE_WILDCARD = '*';
export default class VariablesPathController extends Controller { export default class VariablesPathController extends Controller {
@service router;
get absolutePath() { get absolutePath() {
return this.model?.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; @controller variables;
@action @action

View File

@@ -22,6 +22,11 @@
@route="variables.new" @route="variables.new"
class="button is-primary" class="button is-primary"
data-test-create-var data-test-create-var
{{keyboard-shortcut
pattern=(array "n" "v")
action=(action this.goToNewVariable)
label="Create Variable"
}}
> >
Create Variable Create Variable
</LinkTo> </LinkTo>

View File

@@ -25,6 +25,11 @@
@route="variables.new" @route="variables.new"
@query={{hash path=(concat this.absolutePath "/")}} @query={{hash path=(concat this.absolutePath "/")}}
class="button is-primary" class="button is-primary"
{{keyboard-shortcut
pattern=(array "n" "v")
action=(action this.goToNewVariable)
label="Create Variable"
}}
> >
Create Variable Create Variable
</LinkTo> </LinkTo>