2021-12-11 22:18:48 +05:30
|
|
|
import { GlToast } from '@gitlab/ui';
|
2021-09-04 01:27:46 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import VueApollo from 'vue-apollo';
|
|
|
|
import createDefaultClient from '~/lib/graphql';
|
2021-10-27 15:23:28 +05:30
|
|
|
import AdminRunnersApp from './admin_runners_app.vue';
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
Vue.use(GlToast);
|
2021-09-04 01:27:46 +05:30
|
|
|
Vue.use(VueApollo);
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const initAdminRunners = (selector = '#js-admin-runners') => {
|
2021-09-04 01:27:46 +05:30
|
|
|
const el = document.querySelector(selector);
|
|
|
|
|
|
|
|
if (!el) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
// TODO `activeRunnersCount` should be implemented using a GraphQL API
|
|
|
|
// https://gitlab.com/gitlab-org/gitlab/-/issues/333806
|
2021-12-11 22:18:48 +05:30
|
|
|
const {
|
|
|
|
runnerInstallHelpPage,
|
|
|
|
registrationToken,
|
|
|
|
|
|
|
|
activeRunnersCount,
|
|
|
|
allRunnersCount,
|
|
|
|
instanceRunnersCount,
|
|
|
|
groupRunnersCount,
|
|
|
|
projectRunnersCount,
|
|
|
|
} = el.dataset;
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
const apolloProvider = new VueApollo({
|
2021-12-11 22:18:48 +05:30
|
|
|
defaultClient: createDefaultClient(),
|
2021-09-04 01:27:46 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
apolloProvider,
|
|
|
|
provide: {
|
|
|
|
runnerInstallHelpPage,
|
|
|
|
},
|
|
|
|
render(h) {
|
2021-10-27 15:23:28 +05:30
|
|
|
return h(AdminRunnersApp, {
|
2021-09-04 01:27:46 +05:30
|
|
|
props: {
|
|
|
|
registrationToken,
|
2021-12-11 22:18:48 +05:30
|
|
|
|
|
|
|
// All runner counts are returned as formatted
|
|
|
|
// strings, we do not use `parseInt`.
|
|
|
|
activeRunnersCount,
|
|
|
|
allRunnersCount,
|
|
|
|
instanceRunnersCount,
|
|
|
|
groupRunnersCount,
|
|
|
|
projectRunnersCount,
|
2021-09-04 01:27:46 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|