debian-mirror-gitlab/app/assets/javascripts/issues/show/components/incidents/router.js

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

21 lines
512 B
JavaScript
Raw Normal View History

2023-05-27 22:25:52 +05:30
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
export default (currentPath, currentTab = null) => {
// If navigating directly to a tab, determine the base
// path to initialize router, then set the current route.
const base = currentPath.replace(new RegExp(`/${currentTab}$`), '');
const router = new VueRouter({
mode: 'history',
base,
routes: [{ path: '/:tabId', name: 'tab' }],
});
if (currentTab) router.push(`/${currentTab}`);
return router;
};