2019-07-07 11:18:12 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import Translate from '../vue_shared/translate';
|
|
|
|
import ImportProjectsTable from './components/import_projects_table.vue';
|
|
|
|
import { parseBoolean } from '../lib/utils/common_utils';
|
|
|
|
import createStore from './store';
|
|
|
|
|
|
|
|
Vue.use(Translate);
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
export function initStoreFromElement(element) {
|
2019-07-07 11:18:12 +05:30
|
|
|
const {
|
|
|
|
reposPath,
|
|
|
|
provider,
|
|
|
|
canSelectNamespace,
|
|
|
|
jobsPath,
|
|
|
|
importPath,
|
|
|
|
ciCdOnly,
|
2020-06-23 00:09:42 +05:30
|
|
|
} = element.dataset;
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
return createStore({
|
|
|
|
reposPath,
|
|
|
|
provider,
|
|
|
|
jobsPath,
|
|
|
|
importPath,
|
|
|
|
defaultTargetNamespace: gon.current_username,
|
|
|
|
ciCdOnly: parseBoolean(ciCdOnly),
|
|
|
|
canSelectNamespace: parseBoolean(canSelectNamespace),
|
|
|
|
});
|
|
|
|
}
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
export function initPropsFromElement(element) {
|
|
|
|
return {
|
|
|
|
providerTitle: element.dataset.providerTitle,
|
|
|
|
filterable: parseBoolean(element.dataset.filterable),
|
|
|
|
};
|
|
|
|
}
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
export default function mountImportProjectsTable(mountElement) {
|
|
|
|
if (!mountElement) return undefined;
|
|
|
|
|
|
|
|
const store = initStoreFromElement(mountElement);
|
|
|
|
const props = initPropsFromElement(mountElement);
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
return new Vue({
|
|
|
|
el: mountElement,
|
|
|
|
store,
|
2019-07-07 11:18:12 +05:30
|
|
|
render(createElement) {
|
2020-06-23 00:09:42 +05:30
|
|
|
return createElement(ImportProjectsTable, { props });
|
2019-07-07 11:18:12 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|