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

89 lines
2.1 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
2021-09-04 01:27:46 +05:30
import { parseBooleanDataAttributes } from '~/lib/utils/dom_utils';
2021-03-11 19:13:27 +05:30
import SecurityConfigurationApp from './components/app.vue';
2021-09-04 01:27:46 +05:30
import { securityFeatures, complianceFeatures } from './components/constants';
import RedesignedSecurityConfigurationApp from './components/redesigned_app.vue';
import { augmentFeatures } from './utils';
2021-03-11 19:13:27 +05:30
2021-09-30 23:02:18 +05:30
export const initRedesignedSecurityConfiguration = (el) => {
2021-03-11 19:13:27 +05:30
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
2021-09-04 01:27:46 +05:30
const {
projectPath,
upgradePath,
features,
latestPipelinePath,
gitlabCiHistoryPath,
2021-09-30 23:02:18 +05:30
autoDevopsHelpPagePath,
autoDevopsPath,
2021-09-04 01:27:46 +05:30
} = el.dataset;
2021-03-11 19:13:27 +05:30
2021-09-30 23:02:18 +05:30
const { augmentedSecurityFeatures, augmentedComplianceFeatures } = augmentFeatures(
securityFeatures,
complianceFeatures,
features ? JSON.parse(features) : [],
);
return new Vue({
el,
apolloProvider,
provide: {
projectPath,
upgradePath,
autoDevopsHelpPagePath,
autoDevopsPath,
},
render(createElement) {
return createElement(RedesignedSecurityConfigurationApp, {
props: {
augmentedComplianceFeatures,
augmentedSecurityFeatures,
latestPipelinePath,
gitlabCiHistoryPath,
...parseBooleanDataAttributes(el, [
'gitlabCiPresent',
'autoDevopsEnabled',
'canEnableAutoDevops',
]),
},
});
},
});
};
export const initCESecurityConfiguration = (el) => {
if (!el) {
return null;
}
2021-09-04 01:27:46 +05:30
2021-09-30 23:02:18 +05:30
if (gon.features?.securityConfigurationRedesign) {
return initRedesignedSecurityConfiguration(el);
2021-09-04 01:27:46 +05:30
}
2021-09-30 23:02:18 +05:30
Vue.use(VueApollo);
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
const { projectPath, upgradePath } = el.dataset;
2021-03-11 19:13:27 +05:30
return new Vue({
el,
apolloProvider,
provide: {
projectPath,
2021-04-17 20:07:23 +05:30
upgradePath,
2021-03-11 19:13:27 +05:30
},
render(createElement) {
return createElement(SecurityConfigurationApp);
},
});
};