2021-05-19 17:12:42 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2021-07-21 14:09:27 -04:00
|
|
|
import AdminRunnersApp from './admin_runners_app.vue';
|
2021-05-19 17:12:42 -04:00
|
|
|
|
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2021-07-21 14:09:27 -04:00
|
|
|
export const initAdminRunners = (selector = '#js-admin-runners') => {
|
2021-05-19 17:12:42 -04:00
|
|
|
const el = document.querySelector(selector);
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-12 14:09:09 -04:00
|
|
|
// TODO `activeRunnersCount` should be implemented using a GraphQL API
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/issues/333806
|
2021-05-19 17:12:42 -04:00
|
|
|
const { activeRunnersCount, registrationToken, runnerInstallHelpPage } = el.dataset;
|
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
|
|
|
defaultClient: createDefaultClient(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
assumeImmutableResults: true,
|
|
|
|
},
|
|
|
|
),
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
provide: {
|
|
|
|
runnerInstallHelpPage,
|
|
|
|
},
|
|
|
|
render(h) {
|
2021-07-21 14:09:27 -04:00
|
|
|
return h(AdminRunnersApp, {
|
2021-05-19 17:12:42 -04:00
|
|
|
props: {
|
|
|
|
activeRunnersCount: parseInt(activeRunnersCount, 10),
|
|
|
|
registrationToken,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|