debian-mirror-gitlab/app/assets/javascripts/pipelines/pipelines_index.js

86 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-02-22 17:27:13 +05:30
import { GlToast } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import Vue from 'vue';
2021-02-22 17:27:13 +05:30
import {
parseBoolean,
historyReplaceState,
buildUrlWithCurrentLocation,
} from '~/lib/utils/common_utils';
2021-03-11 19:13:27 +05:30
import { doesHashExistInUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
2021-02-22 17:27:13 +05:30
import Translate from '~/vue_shared/translate';
import Pipelines from './components/pipelines_list/pipelines.vue';
import PipelinesStore from './stores/pipelines_store';
Vue.use(Translate);
Vue.use(GlToast);
export const initPipelinesIndex = (selector = '#pipelines-list-vue') => {
const el = document.querySelector(selector);
if (!el) {
return null;
}
const {
endpoint,
2021-06-08 01:23:25 +05:30
artifactsEndpoint,
artifactsEndpointPlaceholder,
2021-02-22 17:27:13 +05:30
pipelineScheduleUrl,
emptyStateSvgPath,
errorStateSvgPath,
noPipelinesSvgPath,
newPipelinePath,
2021-04-29 21:17:54 +05:30
addCiYmlPath,
suggestedCiTemplates,
2021-02-22 17:27:13 +05:30
canCreatePipeline,
hasGitlabCi,
ciLintPath,
resetCachePath,
projectId,
params,
2021-06-08 01:23:25 +05:30
codeQualityPagePath,
2021-09-04 01:27:46 +05:30
ciRunnerSettingsPath,
2021-02-22 17:27:13 +05:30
} = el.dataset;
return new Vue({
el,
2021-04-29 21:17:54 +05:30
provide: {
addCiYmlPath,
2021-06-08 01:23:25 +05:30
artifactsEndpoint,
artifactsEndpointPlaceholder,
2021-04-29 21:17:54 +05:30
suggestedCiTemplates: JSON.parse(suggestedCiTemplates),
},
2021-02-22 17:27:13 +05:30
data() {
return {
store: new PipelinesStore(),
};
},
created() {
if (doesHashExistInUrl('delete_success')) {
this.$toast.show(__('The pipeline has been deleted'));
historyReplaceState(buildUrlWithCurrentLocation());
}
},
render(createElement) {
return createElement(Pipelines, {
props: {
store: this.store,
endpoint,
pipelineScheduleUrl,
emptyStateSvgPath,
errorStateSvgPath,
noPipelinesSvgPath,
newPipelinePath,
canCreatePipeline: parseBoolean(canCreatePipeline),
hasGitlabCi: parseBoolean(hasGitlabCi),
ciLintPath,
resetCachePath,
projectId,
params: JSON.parse(params),
2021-06-08 01:23:25 +05:30
codeQualityPagePath,
2021-09-04 01:27:46 +05:30
ciRunnerSettingsPath,
2021-02-22 17:27:13 +05:30
},
});
},
});
};