diff --git a/app/assets/javascripts/clusters/agents/components/token_table.vue b/app/assets/javascripts/clusters/agents/components/token_table.vue index 232a0ea1513..019fac531d1 100644 --- a/app/assets/javascripts/clusters/agents/components/token_table.vue +++ b/app/assets/javascripts/clusters/agents/components/token_table.vue @@ -62,8 +62,8 @@ export default { ]; }, learnMoreUrl() { - return helpPagePath('user/clusters/agent/index.md', { - anchor: 'create-an-agent-record-in-gitlab', + return helpPagePath('user/clusters/agent/install/index', { + anchor: 'register-an-agent-with-gitlab', }); }, }, diff --git a/app/assets/javascripts/clusters_list/components/install_agent_modal.vue b/app/assets/javascripts/clusters_list/components/install_agent_modal.vue index a2f3c3579ab..5eef76252bd 100644 --- a/app/assets/javascripts/clusters_list/components/install_agent_modal.vue +++ b/app/assets/javascripts/clusters_list/components/install_agent_modal.vue @@ -47,7 +47,7 @@ export default { enableKasPath: helpPagePath('administration/clusters/kas'), installAgentPath: helpPagePath('user/clusters/agent/install/index'), registerAgentPath: helpPagePath('user/clusters/agent/install/index', { - anchor: 'create-an-agent-record-in-gitlab', + anchor: 'register-an-agent-with-gitlab', }), components: { AvailableAgentsDropdown, diff --git a/app/assets/javascripts/vue_alerts.js b/app/assets/javascripts/vue_alerts.js index abc1dd75645..b44f787cf30 100644 --- a/app/assets/javascripts/vue_alerts.js +++ b/app/assets/javascripts/vue_alerts.js @@ -1,7 +1,17 @@ import Vue from 'vue'; +import Cookies from 'js-cookie'; import { parseBoolean } from '~/lib/utils/common_utils'; import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue'; +const getCookieExpirationPeriod = (expirationPeriod) => { + const defaultExpirationPeriod = 30; + const alertExpirationPeriod = Number(expirationPeriod); + + return !expirationPeriod || Number.isNaN(alertExpirationPeriod) + ? defaultExpirationPeriod + : alertExpirationPeriod; +}; + const mountVueAlert = (el) => { const props = { html: el.innerHTML, @@ -10,11 +20,25 @@ const mountVueAlert = (el) => { ...el.dataset, dismissible: parseBoolean(el.dataset.dismissible), }; + const { dismissCookieName, dismissCookieExpire } = el.dataset; return new Vue({ el, - render(h) { - return h(DismissibleAlert, { props, attrs }); + render(createElement) { + return createElement(DismissibleAlert, { + props, + attrs, + on: { + alertDismissed() { + if (!dismissCookieName) { + return; + } + Cookies.set(dismissCookieName, true, { + expires: getCookieExpirationPeriod(dismissCookieExpire), + }); + }, + }, + }); }, }); }; diff --git a/app/assets/javascripts/vue_shared/components/dismissible_alert.vue b/app/assets/javascripts/vue_shared/components/dismissible_alert.vue index 52371e42ba1..0621ec14c6c 100644 --- a/app/assets/javascripts/vue_shared/components/dismissible_alert.vue +++ b/app/assets/javascripts/vue_shared/components/dismissible_alert.vue @@ -24,6 +24,7 @@ export default { methods: { dismiss() { this.isDismissed = true; + this.$emit('alertDismissed'); }, }, }; diff --git a/doc/user/application_security/policies/index.md b/doc/user/application_security/policies/index.md index 1bb9b7513ee..e6dbd96537f 100644 --- a/doc/user/application_security/policies/index.md +++ b/doc/user/application_security/policies/index.md @@ -159,7 +159,7 @@ at the bottom of the editor. You can use policy alerts to track your policy's impact. Alerts are only available if you've [installed](../../clusters/agent/repository.md) -and [configured](../../clusters/agent/install/index.md#create-an-agent-record-in-gitlab) +and [configured](../../clusters/agent/install/index.md#register-an-agent-with-gitlab) an agent for this project. There are two ways to create policy alerts: diff --git a/doc/user/clusters/agent/ci_cd_tunnel.md b/doc/user/clusters/agent/ci_cd_tunnel.md index f4b03ff930b..93768164df2 100644 --- a/doc/user/clusters/agent/ci_cd_tunnel.md +++ b/doc/user/clusters/agent/ci_cd_tunnel.md @@ -20,10 +20,10 @@ Only CI/CD jobs set in the configuration project can access one of the configure ## Prerequisites - A running [`kas` instance](install/index.md#set-up-the-agent-server). -- A [configuration repository](install/index.md#define-a-configuration-repository) with an Agent config file +- A [configuration repository](install/index.md#define-a-configuration-repository) with an agent config file installed (`.gitlab/agents//config.yaml`). -- An [Agent record](install/index.md#create-an-agent-record-in-gitlab). -- The Agent [installed in the cluster](install/index.md#install-the-agent-into-the-cluster). +- A [registered agent](install/index.md#register-an-agent-with-gitlab). +- The agent [installed in the cluster](install/index.md#install-the-agent-into-the-cluster). ## Use the CI/CD Tunnel to run Kubernetes commands from GitLab CI/CD diff --git a/doc/user/clusters/agent/install/index.md b/doc/user/clusters/agent/install/index.md index deb8599a9f8..cf8467a8d28 100644 --- a/doc/user/clusters/agent/install/index.md +++ b/doc/user/clusters/agent/install/index.md @@ -21,9 +21,9 @@ To install the [Agent](../index.md) in your cluster: 1. [Set up the Agent Server](#set-up-the-agent-server) for your GitLab instance. 1. [Define a configuration repository](#define-a-configuration-repository). -1. [Create an Agent record in GitLab](#create-an-agent-record-in-gitlab). -1. [Install the Agent into the cluster](#install-the-agent-into-the-cluster). -1. [Generate and copy a Secret token used to connect to the Agent](#create-the-kubernetes-secret). +1. [Register an agent with GitLab](#register-an-agent-with-gitlab). +1. [Install the agent into the cluster](#install-the-agent-into-the-cluster). +1. [Generate and copy a Secret token used to connect to the agent](#create-the-kubernetes-secret). 1. [Create manifest files](#create-manifest-files). Watch a GitLab 14.2 [walking-through video](https://www.youtube.com/watch?v=XuBpKtsgGkE) with this process. @@ -75,7 +75,7 @@ To see all the settings available, read the [Agent configuration repository docu Use the [CI/CD Tunnel](../ci_cd_tunnel.md#example-for-a-kubectl-command-using-the-cicd-tunnel) to access your cluster from GitLab CI/CD. -### Create an Agent record in GitLab +### Register an agent with GitLab > [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/5786) in GitLab 14.1, you can create a new Agent record directly from the GitLab UI. @@ -88,7 +88,7 @@ In GitLab: 1. Ensure that [GitLab CI/CD is enabled in your project](../../../../ci/enable_or_disable_ci.md#enable-cicd-in-a-project). 1. From your project's sidebar, select **Infrastructure > Kubernetes clusters**. 1. Select **Actions**. -1. From the **Select an Agent** dropdown, select the Agent you want to connect and select **Register Agent** to access the installation form. +1. From the **Select an agent** dropdown, select the agent you want to connect and select **Register an agent** to access the installation form. 1. The form reveals your registration token. Securely store this secret token as you cannot view it again. 1. Copy the command under **Recommended installation method**. @@ -97,7 +97,7 @@ In your computer: 1. Open your local terminal and connect to your cluster. 1. Run the command you copied from the installation form. -### Install the Agent into the cluster +### Install the agent into the cluster To install the in-cluster component of the Agent, first you need to define a namespace. To create a new namespace, for example, `gitlab-kubernetes-agent`, run: diff --git a/spec/frontend/vue_shared/components/dismissible_alert_spec.js b/spec/frontend/vue_shared/components/dismissible_alert_spec.js index fcd004d35a7..879d4aba441 100644 --- a/spec/frontend/vue_shared/components/dismissible_alert_spec.js +++ b/spec/frontend/vue_shared/components/dismissible_alert_spec.js @@ -43,6 +43,10 @@ describe('vue_shared/components/dismissible_alert', () => { it('hides the alert', () => { expect(findAlert().exists()).toBe(false); }); + + it('emmits alertDismissed', () => { + expect(wrapper.emitted('alertDismissed')).toBeTruthy(); + }); }); });