debian-mirror-gitlab/app/assets/javascripts/behaviors/shortcuts/shortcuts_navigation.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

78 lines
3 KiB
JavaScript
Raw Normal View History

2018-03-17 18:26:18 +05:30
import Mousetrap from 'mousetrap';
2021-11-18 22:05:49 +05:30
import { visitUrl, constructWebIDEPath } from '~/lib/utils/url_utility';
2022-06-21 17:19:12 +05:30
import findAndFollowLink from '~/lib/utils/navigation_utility';
2021-04-29 21:17:54 +05:30
import {
keysFor,
GO_TO_PROJECT_OVERVIEW,
GO_TO_PROJECT_ACTIVITY_FEED,
GO_TO_PROJECT_RELEASES,
GO_TO_PROJECT_FILES,
GO_TO_PROJECT_COMMITS,
GO_TO_PROJECT_JOBS,
GO_TO_PROJECT_REPO_GRAPH,
GO_TO_PROJECT_REPO_CHARTS,
GO_TO_PROJECT_ISSUES,
GO_TO_PROJECT_ISSUE_BOARDS,
GO_TO_PROJECT_MERGE_REQUESTS,
GO_TO_PROJECT_WIKI,
GO_TO_PROJECT_SNIPPETS,
GO_TO_PROJECT_KUBERNETES,
GO_TO_PROJECT_ENVIRONMENTS,
GO_TO_PROJECT_METRICS,
2021-11-18 22:05:49 +05:30
GO_TO_PROJECT_WEBIDE,
2021-04-29 21:17:54 +05:30
NEW_ISSUE,
} from './keybindings';
2018-03-17 18:26:18 +05:30
import Shortcuts from './shortcuts';
2016-09-13 17:45:13 +05:30
2018-03-17 18:26:18 +05:30
export default class ShortcutsNavigation extends Shortcuts {
constructor() {
super();
2016-09-13 17:45:13 +05:30
2021-04-29 21:17:54 +05:30
Mousetrap.bind(keysFor(GO_TO_PROJECT_OVERVIEW), () => findAndFollowLink('.shortcuts-project'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_ACTIVITY_FEED), () =>
findAndFollowLink('.shortcuts-project-activity'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_RELEASES), () =>
findAndFollowLink('.shortcuts-project-releases'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_FILES), () => findAndFollowLink('.shortcuts-tree'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_COMMITS), () => findAndFollowLink('.shortcuts-commits'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_JOBS), () => findAndFollowLink('.shortcuts-builds'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_REPO_GRAPH), () =>
findAndFollowLink('.shortcuts-network'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_REPO_CHARTS), () =>
findAndFollowLink('.shortcuts-repository-charts'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_ISSUES), () => findAndFollowLink('.shortcuts-issues'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_ISSUE_BOARDS), () =>
findAndFollowLink('.shortcuts-issue-boards'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_MERGE_REQUESTS), () =>
findAndFollowLink('.shortcuts-merge_requests'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_WIKI), () => findAndFollowLink('.shortcuts-wiki'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_SNIPPETS), () => findAndFollowLink('.shortcuts-snippets'));
Mousetrap.bind(keysFor(GO_TO_PROJECT_KUBERNETES), () =>
findAndFollowLink('.shortcuts-kubernetes'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_ENVIRONMENTS), () =>
findAndFollowLink('.shortcuts-environments'),
);
Mousetrap.bind(keysFor(GO_TO_PROJECT_METRICS), () => findAndFollowLink('.shortcuts-metrics'));
2021-11-18 22:05:49 +05:30
Mousetrap.bind(keysFor(GO_TO_PROJECT_WEBIDE), ShortcutsNavigation.navigateToWebIDE);
2021-04-29 21:17:54 +05:30
Mousetrap.bind(keysFor(NEW_ISSUE), () => findAndFollowLink('.shortcuts-new-issue'));
2018-03-17 18:26:18 +05:30
}
2021-11-18 22:05:49 +05:30
static navigateToWebIDE() {
const path = constructWebIDEPath({
sourceProjectFullPath: window.gl.mrWidgetData?.source_project_full_path,
targetProjectFullPath: window.gl.mrWidgetData?.target_project_full_path,
iid: window.gl.mrWidgetData?.iid,
});
if (path) {
visitUrl(path);
}
}
2018-03-17 18:26:18 +05:30
}