1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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>
|