debian-mirror-gitlab/app/assets/javascripts/admin/users/tabs.js

24 lines
649 B
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
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;