From 36eff6e5089629619cc55f4771fa949d6ae2b29b Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 28 Feb 2023 18:08:32 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../javascripts/behaviors/copy_to_clipboard.js | 4 +- .../admin_register_runner_app.vue | 81 ++++++++++++ .../ci/runner/admin_register_runner/index.js | 33 ++++- .../runner/components/registration/cli_command.vue | 42 ++++++ .../registration/registration_instructions.vue | 142 +++++++++++++++++++++ .../ci/runner/components/registration/utils.js | 43 +++++++ app/assets/javascripts/ci/runner/constants.js | 4 + .../register/runner_for_registration.query.graphql | 7 + .../components/related_merge_requests.vue | 6 +- .../components/related_issues_block.vue | 2 +- .../super_sidebar/components/help_center.vue | 2 +- .../super_sidebar/components/user_menu.vue | 99 ++++++++++++-- .../components/extensions/base.vue | 6 +- .../components/widget/widget.vue | 2 +- .../components/upload_dropzone/upload_dropzone.vue | 2 +- .../work_items/components/widget_wrapper.vue | 2 +- 16 files changed, 451 insertions(+), 26 deletions(-) create mode 100644 app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue create mode 100644 app/assets/javascripts/ci/runner/components/registration/cli_command.vue create mode 100644 app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue create mode 100644 app/assets/javascripts/ci/runner/components/registration/utils.js create mode 100644 app/assets/javascripts/ci/runner/graphql/register/runner_for_registration.query.graphql (limited to 'app/assets/javascripts') diff --git a/app/assets/javascripts/behaviors/copy_to_clipboard.js b/app/assets/javascripts/behaviors/copy_to_clipboard.js index 4b337dce8f3..834defe336b 100644 --- a/app/assets/javascripts/behaviors/copy_to_clipboard.js +++ b/app/assets/javascripts/behaviors/copy_to_clipboard.js @@ -10,10 +10,10 @@ const CLIPBOARD_ERROR_EVENT = 'clipboard-error'; const I18N_ERROR_MESSAGE = __('Copy failed. Please manually copy the value.'); function showTooltip(target, title) { - const { title: originalTitle } = target.dataset; + const { originalTitle } = target.dataset; once('hidden', (tooltip) => { - if (tooltip.target === target) { + if (originalTitle && tooltip.target === target) { target.setAttribute('title', originalTitle); target.setAttribute('aria-label', originalTitle); fixTitle(target); diff --git a/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue b/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue new file mode 100644 index 00000000000..b291be41203 --- /dev/null +++ b/app/assets/javascripts/ci/runner/admin_register_runner/admin_register_runner_app.vue @@ -0,0 +1,81 @@ + + diff --git a/app/assets/javascripts/ci/runner/admin_register_runner/index.js b/app/assets/javascripts/ci/runner/admin_register_runner/index.js index edb2ec65e98..bd43a5e8ce9 100644 --- a/app/assets/javascripts/ci/runner/admin_register_runner/index.js +++ b/app/assets/javascripts/ci/runner/admin_register_runner/index.js @@ -1,5 +1,36 @@ +import Vue from 'vue'; +import VueApollo from 'vue-apollo'; +import createDefaultClient from '~/lib/graphql'; import { showAlertFromLocalStorage } from '../local_storage_alert/show_alert_from_local_storage'; +import AdminRegisterRunnerApp from './admin_register_runner_app.vue'; -export const initAdminRegisterRunner = () => { +Vue.use(VueApollo); + +export const initAdminRegisterRunner = (selector = '#js-admin-register-runner') => { showAlertFromLocalStorage(); + + const el = document.querySelector(selector); + + if (!el) { + return null; + } + + const { runnerId, runnersPath } = el.dataset; + + const apolloProvider = new VueApollo({ + defaultClient: createDefaultClient(), + }); + + return new Vue({ + el, + apolloProvider, + render(h) { + return h(AdminRegisterRunnerApp, { + props: { + runnerId, + runnersPath, + }, + }); + }, + }); }; diff --git a/app/assets/javascripts/ci/runner/components/registration/cli_command.vue b/app/assets/javascripts/ci/runner/components/registration/cli_command.vue new file mode 100644 index 00000000000..95b135c83a7 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/cli_command.vue @@ -0,0 +1,42 @@ + + diff --git a/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue b/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue new file mode 100644 index 00000000000..e01d8b64839 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/registration_instructions.vue @@ -0,0 +1,142 @@ + + diff --git a/app/assets/javascripts/ci/runner/components/registration/utils.js b/app/assets/javascripts/ci/runner/components/registration/utils.js new file mode 100644 index 00000000000..32fb8eac5e9 --- /dev/null +++ b/app/assets/javascripts/ci/runner/components/registration/utils.js @@ -0,0 +1,43 @@ +import { + DEFAULT_PLATFORM, + LINUX_PLATFORM, + MACOS_PLATFORM, + WINDOWS_PLATFORM, +} from '../../constants'; + +/* eslint-disable @gitlab/require-i18n-strings */ +const OS = { + [LINUX_PLATFORM]: { + commandPrompt: '$', + executable: 'gitlab-runner', + }, + [MACOS_PLATFORM]: { + commandPrompt: '$', + executable: 'gitlab-runner', + }, + [WINDOWS_PLATFORM]: { + commandPrompt: '>', + executable: '.\\gitlab-runner.exe', + }, +}; + +export const commandPrompt = ({ platform }) => { + return (OS[platform] || OS[DEFAULT_PLATFORM]).commandPrompt; +}; + +export const executable = ({ platform }) => { + return (OS[platform] || OS[DEFAULT_PLATFORM]).executable; +}; + +export const registerCommand = ({ platform, url = gon.gitlab_url, registrationToken }) => { + return [ + `${executable({ platform })} register`, + ` --url ${url}`, + ` --registration-token ${registrationToken}`, + ]; +}; + +export const runCommand = ({ platform }) => { + return `${executable({ platform })} run`; +}; +/* eslint-enable @gitlab/require-i18n-strings */ diff --git a/app/assets/javascripts/ci/runner/constants.js b/app/assets/javascripts/ci/runner/constants.js index 27c02420036..1db4ff68872 100644 --- a/app/assets/javascripts/ci/runner/constants.js +++ b/app/assets/javascripts/ci/runner/constants.js @@ -188,5 +188,9 @@ export const DEFAULT_PLATFORM = LINUX_PLATFORM; // Runner docs are in a separate repository and are not shipped with GitLab // they are rendered as external URLs. +export const INSTALL_HELP_URL = 'https://docs.gitlab.com/runner/install'; +export const EXECUTORS_HELP_URL = 'https://docs.gitlab.com/runner/executors/'; +export const SERVICE_COMMANDS_HELP_URL = + 'https://docs.gitlab.com/runner/commands/#service-related-commands'; export const DOCKER_HELP_URL = 'https://docs.gitlab.com/runner/install/docker.html'; export const KUBERNETES_HELP_URL = 'https://docs.gitlab.com/runner/install/kubernetes.html'; diff --git a/app/assets/javascripts/ci/runner/graphql/register/runner_for_registration.query.graphql b/app/assets/javascripts/ci/runner/graphql/register/runner_for_registration.query.graphql new file mode 100644 index 00000000000..a26d43c3729 --- /dev/null +++ b/app/assets/javascripts/ci/runner/graphql/register/runner_for_registration.query.graphql @@ -0,0 +1,7 @@ +query getRunnerForRegistration($id: CiRunnerID!) { + runner(id: $id) { + id + description + ephemeralAuthenticationToken + } +} diff --git a/app/assets/javascripts/issues/related_merge_requests/components/related_merge_requests.vue b/app/assets/javascripts/issues/related_merge_requests/components/related_merge_requests.vue index 149049247fb..accf4e77043 100644 --- a/app/assets/javascripts/issues/related_merge_requests/components/related_merge_requests.vue +++ b/app/assets/javascripts/issues/related_merge_requests/components/related_merge_requests.vue @@ -66,7 +66,7 @@ export default {