Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the dont-open-twice logic into the variable-paths component #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions ui/app/components/variable-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,27 @@ export default class VariablePathsComponent extends Component {
}

@action
async handleFolderClick(path) {
async handleFolderClick(path, trigger) {
// Don't navigate if the user clicked on a link; this will happen with modifier keys like cmd/ctrl on the link itself
if (
trigger instanceof PointerEvent &&
/** @type {HTMLElement} */ (trigger.target).tagName === 'A'
) {
return;
}
this.router.transitionTo('variables.path', path);
}

@action
async handleFileClick({ path, variable: { id, namespace } }) {
async handleFileClick({ path, variable: { id, namespace } }, trigger) {
if (this.can.can('read variable', null, { path, namespace })) {
// Don't navigate if the user clicked on a link; this will happen with modifier keys like cmd/ctrl on the link itself
if (
trigger instanceof PointerEvent &&
/** @type {HTMLElement} */ (trigger.target).tagName === 'A'
) {
return;
}
this.router.transitionTo('variables.variable', id);
}
}
Expand Down
19 changes: 0 additions & 19 deletions ui/app/controllers/variables/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import Controller, { inject as controller } from '@ember/controller';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
// eslint-disable-next-line no-unused-vars
import VariableModel from '../../models/variable';

const ALL_NAMESPACE_WILDCARD = '*';

Expand All @@ -17,23 +15,6 @@ export default class VariablesIndexController extends Controller {

isForbidden = false;

/**
* Trigger can either be the pointer event itself, or if the keyboard shorcut was used, the html element corresponding to the variable.
* @param {VariableModel} variable
* @param {PointerEvent|HTMLElement} trigger
*/
@action
goToVariable(variable, trigger) {
// Don't navigate if the user clicked on a link; this will happen with modifier keys like cmd/ctrl on the link itself
if (
trigger instanceof PointerEvent &&
/** @type {HTMLElement} */ (trigger.target).tagName === 'A'
) {
return;
}
this.router.transitionTo('variables.variable', variable.path);
}

@action goToNewVariable() {
this.router.transitionTo('variables.new');
}
Expand Down
Loading