debian-mirror-gitlab/app/assets/javascripts/ci_settings_pipeline_triggers/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
851 B
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
2021-03-11 19:13:27 +05:30
import TriggersList from './components/triggers_list.vue';
2021-01-03 14:25:43 +05:30
2021-03-08 18:12:59 +05:30
const parseJsonArray = (triggers) => {
2021-01-03 14:25:43 +05:30
try {
return convertObjectPropsToCamelCase(JSON.parse(triggers), { deep: true });
} catch {
return [];
}
};
export default (containerId = 'js-ci-pipeline-triggers-list') => {
const containerEl = document.getElementById(containerId);
// Note: Remove this check when FF `ci_pipeline_triggers_settings_vue_ui` is removed.
if (!containerEl) {
return null;
}
const triggers = parseJsonArray(containerEl.dataset.triggers);
return new Vue({
el: containerEl,
components: {
TriggersList,
},
render(h) {
return h(TriggersList, {
props: {
triggers,
},
});
},
});
};