Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/admin/users/tabs.js')
-rw-r--r--app/assets/javascripts/admin/users/tabs.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/assets/javascripts/admin/users/tabs.js b/app/assets/javascripts/admin/users/tabs.js
new file mode 100644
index 00000000000..9ada77396c7
--- /dev/null
+++ b/app/assets/javascripts/admin/users/tabs.js
@@ -0,0 +1,23 @@
+import { historyPushState } from '~/lib/utils/common_utils';
+import { mergeUrlParams } from '~/lib/utils/url_utility';
+
+const COHORTS_PANE = 'cohorts';
+
+const tabClickHandler = (e) => {
+ const { hash } = e.currentTarget;
+ const tab = hash === `#${COHORTS_PANE}` ? COHORTS_PANE : null;
+ const newUrl = mergeUrlParams({ tab }, window.location.href);
+ historyPushState(newUrl);
+};
+
+const initTabs = () => {
+ const tabLinks = document.querySelectorAll('.js-users-tab-item a');
+
+ if (tabLinks.length) {
+ tabLinks.forEach((tabLink) => {
+ tabLink.addEventListener('click', (e) => tabClickHandler(e));
+ });
+ }
+};
+
+export default initTabs;