debian-mirror-gitlab/app/assets/javascripts/search/topbar/index.js

45 lines
917 B
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import Vue from 'vue';
import Translate from '~/vue_shared/translate';
import GroupFilter from './components/group_filter.vue';
import ProjectFilter from './components/project_filter.vue';
Vue.use(Translate);
const mountSearchableDropdown = (store, { id, component }) => {
const el = document.getElementById(id);
if (!el) {
return false;
}
let { initialData } = el.dataset;
initialData = JSON.parse(initialData);
return new Vue({
el,
store,
render(createElement) {
return createElement(component, {
props: {
initialData,
},
});
},
});
};
const searchableDropdowns = [
{
id: 'js-search-group-dropdown',
component: GroupFilter,
},
{
id: 'js-search-project-dropdown',
component: ProjectFilter,
},
];
export const initTopbar = store =>
searchableDropdowns.map(dropdown => mountSearchableDropdown(store, dropdown));