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';
|
2020-10-24 23:57:45 +05:30
|
|
|
import { queryToObject } from '../lib/utils/url_utility';
|
2019-07-07 11:18:12 +05:30
|
|
|
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 {
|
2020-10-24 23:57:45 +05:30
|
|
|
ciCdOnly,
|
2019-07-07 11:18:12 +05:30
|
|
|
canSelectNamespace,
|
2020-10-24 23:57:45 +05:30
|
|
|
provider,
|
|
|
|
|
|
|
|
reposPath,
|
2019-07-07 11:18:12 +05:30
|
|
|
jobsPath,
|
|
|
|
importPath,
|
2020-10-24 23:57:45 +05:30
|
|
|
namespacesPath,
|
|
|
|
paginatable,
|
2020-06-23 00:09:42 +05:30
|
|
|
} = element.dataset;
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-10-24 23:57:45 +05:30
|
|
|
const params = queryToObject(document.location.search);
|
|
|
|
const page = parseInt(params.page ?? 1, 10);
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
return createStore({
|
2020-10-24 23:57:45 +05:30
|
|
|
initialState: {
|
|
|
|
defaultTargetNamespace: gon.current_username,
|
|
|
|
ciCdOnly: parseBoolean(ciCdOnly),
|
|
|
|
canSelectNamespace: parseBoolean(canSelectNamespace),
|
|
|
|
provider,
|
|
|
|
pageInfo: {
|
|
|
|
page,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
endpoints: {
|
|
|
|
reposPath,
|
|
|
|
jobsPath,
|
|
|
|
importPath,
|
|
|
|
namespacesPath,
|
|
|
|
},
|
|
|
|
hasPagination: parseBoolean(paginatable),
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
}
|
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),
|
2020-10-24 23:57:45 +05:30
|
|
|
paginatable: parseBoolean(element.dataset.paginatable),
|
2020-06-23 00:09:42 +05:30
|
|
|
};
|
|
|
|
}
|
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
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|