2022-04-04 11:22:00 +05:30
|
|
|
import { defaultDataIdFromObject } from '@apollo/client/core';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { GlToast } from '@gitlab/ui';
|
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: {
|
2022-07-23 23:45:48 +05:30
|
|
|
projectPath,
|
2021-10-27 15:23:28 +05:30
|
|
|
accessTokensPath,
|
|
|
|
terraformApiUrl,
|
|
|
|
username,
|
|
|
|
},
|
2021-01-29 00:20:46 +05:30
|
|
|
render(createElement) {
|
|
|
|
return createElement(TerraformList, {
|
|
|
|
props: {
|
|
|
|
emptyStateImage,
|
2022-07-23 23:45:48 +05:30
|
|
|
terraformAdmin: Object.prototype.hasOwnProperty.call(el.dataset, 'terraformAdmin'),
|
2021-01-29 00:20:46 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|