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

48 lines
1.2 KiB
JavaScript
Raw Normal View History

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: {
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
},
});
},
});
};