debian-mirror-gitlab/app/assets/javascripts/runner/admin_runners/index.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
1.6 KiB
JavaScript
Raw Normal View History

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';
2022-03-02 08:16:31 +05:30
import { visitUrl } from '~/lib/utils/url_utility';
import { updateOutdatedUrl } from '~/runner/runner_search_utils';
2022-06-21 17:19:12 +05:30
import createDefaultClient from '~/lib/graphql';
import { createLocalState } from '../graphql/list/local_state';
2022-07-16 23:28:13 +05:30
import { showAlertFromLocalStorage } from '../local_storage_alert/show_alert_from_local_storage';
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') => {
2022-07-16 23:28:13 +05:30
showAlertFromLocalStorage();
2021-09-04 01:27:46 +05:30
const el = document.querySelector(selector);
if (!el) {
return null;
}
2022-03-02 08:16:31 +05:30
// Redirect outdated URLs
const updatedUrlQuery = updateOutdatedUrl();
if (updatedUrlQuery) {
visitUrl(updatedUrlQuery);
2021-12-11 22:18:48 +05:30
2022-03-02 08:16:31 +05:30
// Prevent mounting the rest of the app, redirecting now.
return null;
}
2022-06-21 17:19:12 +05:30
const {
runnerInstallHelpPage,
registrationToken,
onlineContactTimeoutSecs,
staleTimeoutSecs,
2022-07-23 23:45:48 +05:30
emptyStateSvgPath,
emptyStateFilteredSvgPath,
2022-06-21 17:19:12 +05:30
} = el.dataset;
const { cacheConfig, typeDefs, localMutations } = createLocalState();
2021-09-04 01:27:46 +05:30
const apolloProvider = new VueApollo({
2022-06-21 17:19:12 +05:30
defaultClient: createDefaultClient({}, { cacheConfig, typeDefs }),
2021-09-04 01:27:46 +05:30
});
return new Vue({
el,
apolloProvider,
provide: {
runnerInstallHelpPage,
2022-06-21 17:19:12 +05:30
localMutations,
onlineContactTimeoutSecs,
staleTimeoutSecs,
2022-07-23 23:45:48 +05:30
emptyStateSvgPath,
emptyStateFilteredSvgPath,
2021-09-04 01:27:46 +05:30
},
render(h) {
2021-10-27 15:23:28 +05:30
return h(AdminRunnersApp, {
2021-09-04 01:27:46 +05:30
props: {
registrationToken,
},
});
},
});
};