2018-10-17 06:34:19 -04:00
|
|
|
import Vue from 'vue';
|
2021-12-10 13:14:42 -05:00
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
|
|
|
import BridgeApp from './bridge/app.vue';
|
2018-10-17 06:34:19 -04:00
|
|
|
import JobApp from './components/job_app.vue';
|
2020-02-04 07:09:00 -05:00
|
|
|
import createStore from './store';
|
2018-10-17 06:34:19 -04:00
|
|
|
|
2021-12-10 13:14:42 -05:00
|
|
|
const initializeJobPage = (element) => {
|
2020-02-04 07:09:00 -05:00
|
|
|
const store = createStore();
|
|
|
|
|
|
|
|
// Let's start initializing the store (i.e. fetching data) right away
|
|
|
|
store.dispatch('init', element.dataset);
|
|
|
|
|
2020-11-10 07:08:57 -05:00
|
|
|
const {
|
|
|
|
artifactHelpUrl,
|
|
|
|
deploymentHelpUrl,
|
|
|
|
runnerSettingsUrl,
|
|
|
|
subscriptionsMoreMinutesUrl,
|
|
|
|
endpoint,
|
|
|
|
pagePath,
|
|
|
|
logState,
|
|
|
|
buildStatus,
|
|
|
|
projectPath,
|
|
|
|
retryOutdatedJobDocsUrl,
|
|
|
|
} = element.dataset;
|
|
|
|
|
2018-10-17 06:34:19 -04:00
|
|
|
return new Vue({
|
|
|
|
el: element,
|
2020-02-04 07:09:00 -05:00
|
|
|
store,
|
2018-10-17 06:34:19 -04:00
|
|
|
components: {
|
|
|
|
JobApp,
|
|
|
|
},
|
2020-11-10 07:08:57 -05:00
|
|
|
provide: {
|
|
|
|
retryOutdatedJobDocsUrl,
|
|
|
|
},
|
2018-10-17 06:34:19 -04:00
|
|
|
render(createElement) {
|
|
|
|
return createElement('job-app', {
|
|
|
|
props: {
|
2020-09-07 02:08:35 -04:00
|
|
|
artifactHelpUrl,
|
2019-08-05 08:12:47 -04:00
|
|
|
deploymentHelpUrl,
|
|
|
|
runnerSettingsUrl,
|
2019-09-04 16:48:58 -04:00
|
|
|
subscriptionsMoreMinutesUrl,
|
2019-08-05 08:12:47 -04:00
|
|
|
endpoint,
|
|
|
|
pagePath,
|
|
|
|
logState,
|
|
|
|
buildStatus,
|
|
|
|
projectPath,
|
2018-10-17 06:34:19 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
2021-12-10 13:14:42 -05:00
|
|
|
|
|
|
|
const initializeBridgePage = (el) => {
|
2022-01-10 07:15:34 -05:00
|
|
|
const {
|
|
|
|
buildId,
|
|
|
|
downstreamPipelinePath,
|
|
|
|
emptyStateIllustrationPath,
|
|
|
|
pipelineIid,
|
|
|
|
projectFullPath,
|
|
|
|
} = el.dataset;
|
2021-12-10 13:14:42 -05:00
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(),
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
provide: {
|
2022-01-10 07:15:34 -05:00
|
|
|
buildId,
|
|
|
|
downstreamPipelinePath,
|
2021-12-10 13:14:42 -05:00
|
|
|
emptyStateIllustrationPath,
|
2022-01-10 07:15:34 -05:00
|
|
|
pipelineIid,
|
|
|
|
projectFullPath,
|
2021-12-10 13:14:42 -05:00
|
|
|
},
|
|
|
|
render(h) {
|
|
|
|
return h(BridgeApp);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {
|
|
|
|
const jobElement = document.getElementById('js-job-page');
|
|
|
|
const bridgeElement = document.getElementById('js-bridge-page');
|
|
|
|
|
|
|
|
if (jobElement) {
|
|
|
|
initializeJobPage(jobElement);
|
|
|
|
} else {
|
|
|
|
initializeBridgePage(bridgeElement);
|
|
|
|
}
|
|
|
|
};
|