2021-11-18 22:05:49 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import { mergeUrlParams } from '~/lib/utils/url_utility';
|
2021-03-11 19:13:27 +05:30
|
|
|
import ProjectsList from '~/projects_list';
|
2021-11-18 22:05:49 +05:30
|
|
|
import NamespaceSelect from './components/namespace_select.vue';
|
2020-07-28 23:09:34 +05:30
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
new ProjectsList(); // eslint-disable-line no-new
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
function mountNamespaceSelect() {
|
|
|
|
const el = document.querySelector('.js-namespace-select');
|
|
|
|
if (!el) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
const { fieldName, toggleTextPlaceholder, selectedId, selectedText, updateLocation } = el.dataset;
|
2021-11-18 22:05:49 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
render(createComponent) {
|
|
|
|
return createComponent(NamespaceSelect, {
|
|
|
|
props: {
|
|
|
|
fieldName,
|
2023-04-23 21:23:45 +05:30
|
|
|
toggleTextPlaceholder,
|
|
|
|
origSelectedId: selectedId,
|
|
|
|
origSelectedText: selectedText,
|
2021-11-18 22:05:49 +05:30
|
|
|
},
|
|
|
|
on: {
|
|
|
|
setNamespace(newNamespace) {
|
|
|
|
if (fieldName && updateLocation) {
|
|
|
|
window.location = mergeUrlParams({ [fieldName]: newNamespace }, window.location.href);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
mountNamespaceSelect();
|