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
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
const { emptyStateImage, projectPath, accessTokensPath, terraformApiUrl, username } = el.dataset;
|
2021-01-29 00:20:46 +05:30
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider: new VueApollo({ defaultClient }),
|
2021-10-27 15:23:28 +05:30
|
|
|
provide: {
|
|
|
|
accessTokensPath,
|
|
|
|
terraformApiUrl,
|
|
|
|
username,
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
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
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|