diff options
Diffstat (limited to 'app/assets')
4 files changed, 102 insertions, 1 deletions
diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index cb9c44bc36d..da34c5030f9 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -8,13 +8,20 @@ import Flash from '../flash'; import Poll from '../lib/utils/poll'; import initSettingsPanels from '../settings_panels'; import eventHub from './event_hub'; -import { APPLICATION_STATUS, INGRESS, INGRESS_DOMAIN_SUFFIX, CROSSPLANE } from './constants'; +import { + APPLICATION_STATUS, + INGRESS, + INGRESS_DOMAIN_SUFFIX, + CROSSPLANE, + KNATIVE, +} from './constants'; import ClustersService from './services/clusters_service'; import ClustersStore from './stores/clusters_store'; import Applications from './components/applications.vue'; import RemoveClusterConfirmation from './components/remove_cluster_confirmation.vue'; import setupToggleButtons from '../toggle_buttons'; import initProjectSelectDropdown from '~/project_select'; +import initServerlessSurveyBanner from '~/serverless/survey_banner'; const Environments = () => import('ee_component/clusters/components/environments.vue'); @@ -326,6 +333,10 @@ export default class Clusters { this.store.state.applications[INGRESS], ); } + + if (this.store.state.applications[KNATIVE]?.status === APPLICATION_STATUS.INSTALLED) { + initServerlessSurveyBanner(); + } } showToken() { diff --git a/app/assets/javascripts/pages/projects/serverless/index.js b/app/assets/javascripts/pages/projects/serverless/index.js index 7b08620773c..a883737ac9b 100644 --- a/app/assets/javascripts/pages/projects/serverless/index.js +++ b/app/assets/javascripts/pages/projects/serverless/index.js @@ -1,5 +1,7 @@ import ServerlessBundle from '~/serverless/serverless_bundle'; +import initServerlessSurveyBanner from '~/serverless/survey_banner'; document.addEventListener('DOMContentLoaded', () => { + initServerlessSurveyBanner(); new ServerlessBundle(); // eslint-disable-line no-new }); diff --git a/app/assets/javascripts/serverless/survey_banner.js b/app/assets/javascripts/serverless/survey_banner.js new file mode 100644 index 00000000000..070e8f4c661 --- /dev/null +++ b/app/assets/javascripts/serverless/survey_banner.js @@ -0,0 +1,36 @@ +import Vue from 'vue'; +import { setUrlParams } from '~/lib/utils/url_utility'; +import SurveyBanner from './survey_banner.vue'; + +let bannerInstance; +const SURVEY_URL_BASE = 'https://gitlab.fra1.qualtrics.com/jfe/form/SV_00PfofFfY9s8Shf'; + +export default function initServerlessSurveyBanner() { + const el = document.querySelector('.js-serverless-survey-banner'); + if (el && !bannerInstance) { + const { userName, userEmail } = el.dataset; + + // pre-populate survey fields + const surveyUrl = setUrlParams( + { + Q_PopulateResponse: JSON.stringify({ + QID1: userEmail, + QID2: userName, + QID16: '1', // selects "yes" to "do you currently use GitLab?" + }), + }, + SURVEY_URL_BASE, + ); + + bannerInstance = new Vue({ + el, + render(createElement) { + return createElement(SurveyBanner, { + props: { + surveyUrl, + }, + }); + }, + }); + } +} diff --git a/app/assets/javascripts/serverless/survey_banner.vue b/app/assets/javascripts/serverless/survey_banner.vue new file mode 100644 index 00000000000..a0a90fa5e80 --- /dev/null +++ b/app/assets/javascripts/serverless/survey_banner.vue @@ -0,0 +1,52 @@ +<script> +import Cookies from 'js-cookie'; +import { parseBoolean } from '~/lib/utils/common_utils'; +import { GlBanner } from '@gitlab/ui'; + +export default { + components: { + GlBanner, + }, + props: { + surveyUrl: { + type: String, + required: true, + }, + }, + data() { + return { + visible: true, + }; + }, + created() { + if (parseBoolean(Cookies.get('hide_serverless_survey'))) { + this.visible = false; + } + }, + methods: { + handleClose() { + Cookies.set('hide_serverless_survey', 'true', { expires: 365 * 10 }); + this.visible = false; + }, + }, +}; +</script> + +<template> + <gl-banner + v-if="visible" + class="mt-4" + :title="s__('Serverless|Help shape the future of Serverless at GitLab')" + :button-text="s__('Serverless|Sign up for First Look')" + :button-link="surveyUrl" + @close="handleClose" + > + <p> + {{ + s__( + 'Serverless|We are continually striving to improve our Serverless functionality. As a Knative user, we would love to hear how we can make this experience better for you. Sign up for GitLab First Look today and we will be in touch shortly.', + ) + }} + </p> + </gl-banner> +</template> |