diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-21 02:50:22 +0300 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/assets/javascripts/namespaces | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/assets/javascripts/namespaces')
-rw-r--r-- | app/assets/javascripts/namespaces/cascading_settings/components/lock_popovers.vue | 77 | ||||
-rw-r--r-- | app/assets/javascripts/namespaces/cascading_settings/index.js | 15 |
2 files changed, 92 insertions, 0 deletions
diff --git a/app/assets/javascripts/namespaces/cascading_settings/components/lock_popovers.vue b/app/assets/javascripts/namespaces/cascading_settings/components/lock_popovers.vue new file mode 100644 index 00000000000..8de6e910bb6 --- /dev/null +++ b/app/assets/javascripts/namespaces/cascading_settings/components/lock_popovers.vue @@ -0,0 +1,77 @@ +<script> +import { GlPopover, GlSprintf, GlLink } from '@gitlab/ui'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; + +export default { + name: 'LockPopovers', + components: { + GlPopover, + GlSprintf, + GlLink, + }, + data() { + return { + targets: [], + }; + }, + mounted() { + this.targets = [...document.querySelectorAll('.js-cascading-settings-lock-popover-target')].map( + (el) => { + const { + dataset: { popoverData }, + } = el; + + const { + lockedByAncestor, + lockedByApplicationSetting, + ancestorNamespace, + } = convertObjectPropsToCamelCase(JSON.parse(popoverData || '{}'), { deep: true }); + + return { + el, + lockedByAncestor, + lockedByApplicationSetting, + ancestorNamespace, + }; + }, + ); + }, +}; +</script> + +<template> + <div> + <template + v-for="( + { el, lockedByApplicationSetting, lockedByAncestor, ancestorNamespace }, index + ) in targets" + > + <gl-popover + v-if="lockedByApplicationSetting || lockedByAncestor" + :key="index" + :target="el" + placement="top" + > + <template #title>{{ s__('CascadingSettings|Setting enforced') }}</template> + <p data-testid="cascading-settings-lock-popover"> + <template v-if="lockedByApplicationSetting">{{ + s__('CascadingSettings|This setting has been enforced by an instance admin.') + }}</template> + + <gl-sprintf + v-else-if="lockedByAncestor && ancestorNamespace" + :message=" + s__('CascadingSettings|This setting has been enforced by an owner of %{link}.') + " + > + <template #link> + <gl-link :href="ancestorNamespace.path" class="gl-font-sm">{{ + ancestorNamespace.fullName + }}</gl-link> + </template> + </gl-sprintf> + </p> + </gl-popover> + </template> + </div> +</template> diff --git a/app/assets/javascripts/namespaces/cascading_settings/index.js b/app/assets/javascripts/namespaces/cascading_settings/index.js new file mode 100644 index 00000000000..3e44d1e9e2d --- /dev/null +++ b/app/assets/javascripts/namespaces/cascading_settings/index.js @@ -0,0 +1,15 @@ +import Vue from 'vue'; +import LockPopovers from './components/lock_popovers.vue'; + +export const initCascadingSettingsLockPopovers = () => { + const el = document.querySelector('.js-cascading-settings-lock-popovers'); + + if (!el) return false; + + return new Vue({ + el, + render(createElement) { + return createElement(LockPopovers); + }, + }); +}; |