diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 03:14:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-15 03:14:10 +0300 |
commit | 119c999cf1f1bb51d4324e3c4847435347eb32cf (patch) | |
tree | 83f92f606877455177bb57c7d2ad31704d10027b /app/assets/javascripts/snippets | |
parent | 5594a6badf033359b84c2e9822f145c66b0dce8f (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/snippets')
-rw-r--r-- | app/assets/javascripts/snippets/components/show.vue | 4 | ||||
-rw-r--r-- | app/assets/javascripts/snippets/constants.js | 20 | ||||
-rw-r--r-- | app/assets/javascripts/snippets/index.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/snippets/utils/blob.js | 4 |
4 files changed, 18 insertions, 18 deletions
diff --git a/app/assets/javascripts/snippets/components/show.vue b/app/assets/javascripts/snippets/components/show.vue index ee8b00c1f5d..853293e5eb6 100644 --- a/app/assets/javascripts/snippets/components/show.vue +++ b/app/assets/javascripts/snippets/components/show.vue @@ -6,7 +6,7 @@ import { SNIPPET_MEASURE_BLOBS_CONTENT, } from '~/performance/constants'; import { performanceMarkAndMeasure } from '~/performance/utils'; -import { SNIPPET_VISIBILITY_PUBLIC } from '~/snippets/constants'; +import { VISIBILITY_LEVEL_PUBLIC_STRING } from '~/visibility_level/constants'; import CloneDropdownButton from '~/vue_shared/components/clone_dropdown.vue'; import { getSnippetMixin } from '../mixins/snippets'; @@ -31,7 +31,7 @@ export default { mixins: [getSnippetMixin], computed: { embeddable() { - return this.snippet.visibilityLevel === SNIPPET_VISIBILITY_PUBLIC; + return this.snippet.visibilityLevel === VISIBILITY_LEVEL_PUBLIC_STRING; }, canBeCloned() { return Boolean(this.snippet.sshUrlToRepo || this.snippet.httpUrlToRepo); diff --git a/app/assets/javascripts/snippets/constants.js b/app/assets/javascripts/snippets/constants.js index 2a9ecbc27dc..84a940ed1f8 100644 --- a/app/assets/javascripts/snippets/constants.js +++ b/app/assets/javascripts/snippets/constants.js @@ -1,22 +1,23 @@ import { __ } from '~/locale'; - -export const SNIPPET_VISIBILITY_PRIVATE = 'private'; -export const SNIPPET_VISIBILITY_INTERNAL = 'internal'; -export const SNIPPET_VISIBILITY_PUBLIC = 'public'; +import { + VISIBILITY_LEVEL_PRIVATE_STRING, + VISIBILITY_LEVEL_INTERNAL_STRING, + VISIBILITY_LEVEL_PUBLIC_STRING, +} from '~/visibility_level/constants'; export const SNIPPET_VISIBILITY = { - [SNIPPET_VISIBILITY_PRIVATE]: { + [VISIBILITY_LEVEL_PRIVATE_STRING]: { label: __('Private'), icon: 'lock', description: __('The snippet is visible only to me.'), description_project: __('The snippet is visible only to project members.'), }, - [SNIPPET_VISIBILITY_INTERNAL]: { + [VISIBILITY_LEVEL_INTERNAL_STRING]: { label: __('Internal'), icon: 'shield', description: __('The snippet is visible to any logged in user except external users.'), }, - [SNIPPET_VISIBILITY_PUBLIC]: { + [VISIBILITY_LEVEL_PUBLIC_STRING]: { label: __('Public'), icon: 'earth', description: __('The snippet can be accessed without any authentication.'), @@ -34,11 +35,6 @@ export const SNIPPET_BLOB_ACTION_DELETE = 'delete'; export const SNIPPET_MAX_BLOBS = 10; -export const SNIPPET_LEVELS_MAP = { - 0: SNIPPET_VISIBILITY_PRIVATE, - 10: SNIPPET_VISIBILITY_INTERNAL, - 20: SNIPPET_VISIBILITY_PUBLIC, -}; export const SNIPPET_LEVELS_RESTRICTED = __( 'Other visibility settings have been disabled by the administrator.', ); diff --git a/app/assets/javascripts/snippets/index.js b/app/assets/javascripts/snippets/index.js index 21f38c4d8c9..89dd5e586fb 100644 --- a/app/assets/javascripts/snippets/index.js +++ b/app/assets/javascripts/snippets/index.js @@ -2,7 +2,10 @@ import Vue from 'vue'; import VueApollo from 'vue-apollo'; import createDefaultClient from '~/lib/graphql'; -import { SNIPPET_LEVELS_MAP, SNIPPET_VISIBILITY_PRIVATE } from '~/snippets/constants'; +import { + VISIBILITY_LEVEL_PRIVATE_STRING, + VISIBILITY_LEVELS_INTEGER_TO_STRING, +} from '~/visibility_level/constants'; import Translate from '~/vue_shared/translate'; Vue.use(VueApollo); @@ -36,7 +39,8 @@ export default function appFactory(el, Component) { apolloProvider, provide: { visibilityLevels: JSON.parse(visibilityLevels), - selectedLevel: SNIPPET_LEVELS_MAP[selectedLevel] ?? SNIPPET_VISIBILITY_PRIVATE, + selectedLevel: + VISIBILITY_LEVELS_INTEGER_TO_STRING[selectedLevel] ?? VISIBILITY_LEVEL_PRIVATE_STRING, multipleLevelsRestricted: 'multipleLevelsRestricted' in el.dataset, reportAbusePath, canReportSpam, diff --git a/app/assets/javascripts/snippets/utils/blob.js b/app/assets/javascripts/snippets/utils/blob.js index 2a3f590a803..a228d6111ce 100644 --- a/app/assets/javascripts/snippets/utils/blob.js +++ b/app/assets/javascripts/snippets/utils/blob.js @@ -1,12 +1,12 @@ import { uniqueId } from 'lodash'; import { SNIPPET_MARK_BLOBS_CONTENT, SNIPPET_MEASURE_BLOBS_CONTENT } from '~/performance/constants'; import { performanceMarkAndMeasure } from '~/performance/utils'; +import { VISIBILITY_LEVELS_INTEGER_TO_STRING } from '~/visibility_level/constants'; import { SNIPPET_BLOB_ACTION_CREATE, SNIPPET_BLOB_ACTION_UPDATE, SNIPPET_BLOB_ACTION_MOVE, SNIPPET_BLOB_ACTION_DELETE, - SNIPPET_LEVELS_MAP, SNIPPET_VISIBILITY, } from '../constants'; @@ -72,7 +72,7 @@ export const diffAll = (blobs, origBlobs) => { export const defaultSnippetVisibilityLevels = (arr) => { if (Array.isArray(arr)) { return arr.map((l) => { - const translatedLevel = SNIPPET_LEVELS_MAP[l]; + const translatedLevel = VISIBILITY_LEVELS_INTEGER_TO_STRING[l]; return { value: translatedLevel, ...SNIPPET_VISIBILITY[translatedLevel], |