Skip to content

Commit

Permalink
Adds N V for variable creation as a keyboard shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Jul 13, 2023
1 parent 4379418 commit 12f26dd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ui/app/controllers/variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions ui/app/controllers/variables/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '';
}
Expand All @@ -28,6 +31,12 @@ export default class VariablesPathController extends Controller {
}
}

@action goToNewVariable() {
this.router.transitionTo('variables.new', {
queryParams: { path: `${this.absolutePath}/` },
});
}

@controller variables;

@action
Expand Down
5 changes: 5 additions & 0 deletions ui/app/templates/variables/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
</LinkTo>
Expand Down
5 changes: 5 additions & 0 deletions ui/app/templates/variables/path.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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
</LinkTo>
Expand Down

0 comments on commit 12f26dd

Please sign in to comment.