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

43 lines
1 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import { GlToast } from '@gitlab/ui';
import { defaultDataIdFromObject } from 'apollo-cache-inmemory';
2021-01-29 00:20:46 +05:30
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
2021-03-11 19:13:27 +05:30
import TerraformList from './components/terraform_list.vue';
import resolvers from './graphql/resolvers';
2021-01-29 00:20:46 +05:30
2021-03-11 19:13:27 +05:30
Vue.use(GlToast);
2021-01-29 00:20:46 +05:30
Vue.use(VueApollo);
export default () => {
const el = document.querySelector('#js-terraform-list');
if (!el) {
return null;
}
2021-03-11 19:13:27 +05:30
const defaultClient = createDefaultClient(resolvers, {
cacheConfig: {
dataIdFromObject: (object) => {
return object.id || defaultDataIdFromObject(object);
},
},
});
2021-01-29 00:20:46 +05:30
const { emptyStateImage, projectPath } = el.dataset;
return new Vue({
el,
apolloProvider: new VueApollo({ defaultClient }),
render(createElement) {
return createElement(TerraformList, {
props: {
emptyStateImage,
projectPath,
2021-02-22 17:27:13 +05:30
terraformAdmin: el.hasAttribute('data-terraform-admin'),
2021-01-29 00:20:46 +05:30
},
});
},
});
};