gitlab-org--gitlab-foss/app/assets/javascripts/environments/index.js

55 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-04-27 10:06:17 -04:00
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import canaryCalloutMixin from './mixins/canary_callout_mixin';
2017-11-23 07:04:03 -05:00
import environmentsComponent from './components/environments_app.vue';
import { parseBoolean } from '../lib/utils/common_utils';
2017-11-23 07:04:03 -05:00
import Translate from '../vue_shared/translate';
import createDefaultClient from '~/lib/graphql';
2017-11-23 07:04:03 -05:00
Vue.use(Translate);
Vue.use(VueApollo);
2016-10-14 08:14:18 -04:00
const apolloProvider = new VueApollo({
defaultClient: createDefaultClient(),
});
export default () => {
const el = document.getElementById('environments-list-view');
return new Vue({
el,
components: {
environmentsComponent,
},
mixins: [canaryCalloutMixin],
apolloProvider,
provide: {
projectPath: el.dataset.projectPath,
},
data() {
const environmentsData = el.dataset;
2017-11-23 07:04:03 -05:00
return {
endpoint: environmentsData.environmentsDataEndpoint,
newEnvironmentPath: environmentsData.newEnvironmentPath,
helpPagePath: environmentsData.helpPagePath,
deployBoardsHelpPath: environmentsData.deployBoardsHelpPath,
canCreateEnvironment: parseBoolean(environmentsData.canCreateEnvironment),
canReadEnvironment: parseBoolean(environmentsData.canReadEnvironment),
};
},
render(createElement) {
return createElement('environments-component', {
props: {
endpoint: this.endpoint,
newEnvironmentPath: this.newEnvironmentPath,
helpPagePath: this.helpPagePath,
deployBoardsHelpPath: this.deployBoardsHelpPath,
canCreateEnvironment: this.canCreateEnvironment,
canReadEnvironment: this.canReadEnvironment,
...this.canaryCalloutProps,
},
});
},
});
};