diff options
Diffstat (limited to 'app/assets/javascripts/pages/projects/learn_gitlab')
4 files changed, 91 insertions, 0 deletions
diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue new file mode 100644 index 00000000000..0393793bfe1 --- /dev/null +++ b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_a.vue @@ -0,0 +1,27 @@ +<script> +import { GlLink } from '@gitlab/ui'; +import { ACTION_TEXT } from '../constants'; + +export default { + components: { GlLink }, + i18n: { + ACTION_TEXT, + }, + props: { + actions: { + required: true, + type: Object, + }, + }, +}; +</script> +<template> + <ul> + <li v-for="(value, action) in actions" :key="action"> + <span v-if="value.completed">{{ $options.i18n.ACTION_TEXT[action] }}</span> + <span v-else> + <gl-link :href="value.url">{{ $options.i18n.ACTION_TEXT[action] }}</gl-link> + </span> + </li> + </ul> +</template> diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue new file mode 100644 index 00000000000..0393793bfe1 --- /dev/null +++ b/app/assets/javascripts/pages/projects/learn_gitlab/components/learn_gitlab_b.vue @@ -0,0 +1,27 @@ +<script> +import { GlLink } from '@gitlab/ui'; +import { ACTION_TEXT } from '../constants'; + +export default { + components: { GlLink }, + i18n: { + ACTION_TEXT, + }, + props: { + actions: { + required: true, + type: Object, + }, + }, +}; +</script> +<template> + <ul> + <li v-for="(value, action) in actions" :key="action"> + <span v-if="value.completed">{{ $options.i18n.ACTION_TEXT[action] }}</span> + <span v-else> + <gl-link :href="value.url">{{ $options.i18n.ACTION_TEXT[action] }}</gl-link> + </span> + </li> + </ul> +</template> diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js b/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js new file mode 100644 index 00000000000..8606af29785 --- /dev/null +++ b/app/assets/javascripts/pages/projects/learn_gitlab/constants/index.js @@ -0,0 +1,12 @@ +import { s__ } from '~/locale'; + +export const ACTION_TEXT = { + gitWrite: s__('LearnGitLab|Create a repository'), + userAdded: s__('LearnGitLab|Invite your colleagues'), + pipelineCreated: s__('LearnGitLab|Set-up CI/CD'), + trialStarted: s__('LearnGitLab|Start a free trial of GitLab Gold'), + codeOwnersEnabled: s__('LearnGitLab|Add code owners'), + requiredMrApprovalsEnabled: s__('LearnGitLab|Enable require merge approvals'), + mergeRequestCreated: s__('LearnGitLab|Submit a merge request (MR)'), + securityScanEnabled: s__('LearnGitLab|Run a Security scan using CI/CD'), +}; diff --git a/app/assets/javascripts/pages/projects/learn_gitlab/index/index.js b/app/assets/javascripts/pages/projects/learn_gitlab/index/index.js new file mode 100644 index 00000000000..c4dec89b984 --- /dev/null +++ b/app/assets/javascripts/pages/projects/learn_gitlab/index/index.js @@ -0,0 +1,25 @@ +import Vue from 'vue'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import LearnGitlabA from '../components/learn_gitlab_a.vue'; +import LearnGitlabB from '../components/learn_gitlab_b.vue'; + +function initLearnGitlab() { + const el = document.getElementById('js-learn-gitlab-app'); + + if (!el) { + return false; + } + + const actions = convertObjectPropsToCamelCase(JSON.parse(el.dataset.actions)); + + const { learnGitlabA } = gon.experiments; + + return new Vue({ + el, + render(createElement) { + return createElement(learnGitlabA ? LearnGitlabA : LearnGitlabB, { props: { actions } }); + }, + }); +} + +initLearnGitlab(); |