diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 06:08:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 06:08:14 +0300 |
commit | bc69b91579a1406bc62eb2ea696e5e35cff56d59 (patch) | |
tree | 9f8158a8b7d09024c88b6dcd395ed7fc80621555 /app | |
parent | 6fbaac1974d2e9a0e5296a9da2d99f356a684f91 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
3 files changed, 89 insertions, 17 deletions
diff --git a/app/assets/javascripts/admin/broadcast_messages/components/message_form.vue b/app/assets/javascripts/admin/broadcast_messages/components/message_form.vue index 427e6c14327..42a959e1b89 100644 --- a/app/assets/javascripts/admin/broadcast_messages/components/message_form.vue +++ b/app/assets/javascripts/admin/broadcast_messages/components/message_form.vue @@ -17,7 +17,15 @@ import { createAlert, VARIANT_DANGER } from '~/alert'; import { redirectTo } from '~/lib/utils/url_utility'; // eslint-disable-line import/no-deprecated import { DEFAULT_DEBOUNCE_AND_THROTTLE_MS } from '~/lib/utils/constants'; import SafeHtml from '~/vue_shared/directives/safe_html'; -import { THEMES, TYPES, TYPE_BANNER } from '../constants'; +import { + THEMES, + TYPES, + TYPE_BANNER, + TARGET_OPTIONS, + TARGET_ALL, + TARGET_ALL_MATCHING_PATH, + TARGET_ROLES, +} from '../constants'; import DatetimePicker from './datetime_picker.vue'; const FORM_HEADERS = { headers: { 'Content-Type': 'application/json; charset=utf-8' } }; @@ -59,10 +67,8 @@ export default { theme: s__('BroadcastMessages|Theme'), dismissable: s__('BroadcastMessages|Dismissable'), dismissableDescription: s__('BroadcastMessages|Allow users to dismiss the broadcast message'), + target: s__('BroadcastMessages|Target broadcast message'), targetRoles: s__('BroadcastMessages|Target roles'), - targetRolesDescription: s__( - 'BroadcastMessages|The broadcast message displays only to users in projects and groups who have these roles.', - ), targetPath: s__('BroadcastMessages|Target Path'), targetPathDescription: s__('BroadcastMessages|Paths can contain wildcards, like */welcome'), startsAt: s__('BroadcastMessages|Starts at'), @@ -79,6 +85,7 @@ export default { }, messageThemes: THEMES, messageTypes: TYPES, + targetOptions: TARGET_OPTIONS, props: { broadcastMessage: { type: Object, @@ -92,6 +99,7 @@ export default { type: this.broadcastMessage.broadcastType, theme: this.broadcastMessage.theme, dismissable: this.broadcastMessage.dismissable || false, + targetSelected: '', targetPath: this.broadcastMessage.targetPath, targetAccessLevels: this.broadcastMessage.targetAccessLevels, targetAccessLevelOptions: this.targetAccessLevelOptions.map(([text, value]) => ({ @@ -122,6 +130,14 @@ export default { ? this.messagesPath : `${this.messagesPath}/${this.broadcastMessage.id}`; }, + showTargetRoles() { + return this.targetSelected === TARGET_ROLES; + }, + showTargetPath() { + return ( + this.targetSelected === TARGET_ROLES || this.targetSelected === TARGET_ALL_MATCHING_PATH + ); + }, formPayload() { return JSON.stringify({ message: this.message, @@ -143,6 +159,17 @@ export default { }, immediate: true, }, + targetSelected(newTarget) { + if (newTarget === TARGET_ALL) { + this.targetPath = ''; + this.targetAccessLevels = []; + } else if (newTarget === TARGET_ALL_MATCHING_PATH) { + this.targetAccessLevels = []; + } + }, + }, + created() { + this.targetSelected = this.initialTarget(); }, methods: { async onSubmit() { @@ -179,6 +206,15 @@ export default { this.renderedMessage = ''; } }, + + initialTarget() { + if (this.targetAccessLevels.length > 0) { + return TARGET_ROLES; + } else if (this.targetPath !== '') { + return TARGET_ALL_MATCHING_PATH; + } + return TARGET_ALL; + }, }, safeHtmlConfig: { ADD_TAGS: ['use'], @@ -245,14 +281,29 @@ export default { </gl-form-group> </template> - <gl-form-group :label="$options.i18n.targetRoles" data-testid="target-roles-checkboxes"> + <gl-form-group :label="$options.i18n.target" label-for="target-select"> + <gl-form-select + id="target-select" + v-model="targetSelected" + :options="$options.targetOptions" + data-testid="target-select" + /> + </gl-form-group> + + <gl-form-group + v-show="showTargetRoles" + :label="$options.i18n.targetRoles" + data-testid="target-roles-checkboxes" + > <gl-form-checkbox-group v-model="targetAccessLevels" :options="targetAccessLevelOptions" /> - <gl-form-text> - {{ $options.i18n.targetRolesDescription }} - </gl-form-text> </gl-form-group> - <gl-form-group :label="$options.i18n.targetPath" label-for="target-path-input"> + <gl-form-group + v-show="showTargetPath" + :label="$options.i18n.targetPath" + label-for="target-path-input" + data-testid="target-path-input" + > <gl-form-input id="target-path-input" v-model="targetPath" /> <gl-form-text> {{ $options.i18n.targetPathDescription }} diff --git a/app/assets/javascripts/admin/broadcast_messages/constants.js b/app/assets/javascripts/admin/broadcast_messages/constants.js index ed137181a48..76e1cf91c2f 100644 --- a/app/assets/javascripts/admin/broadcast_messages/constants.js +++ b/app/assets/javascripts/admin/broadcast_messages/constants.js @@ -21,6 +21,27 @@ export const THEMES = [ { value: 'light', text: s__('BroadcastMessages|Light') }, ]; +export const TARGET_ALL = 'target_all'; +export const TARGET_ALL_MATCHING_PATH = 'target_all_matching_path'; +export const TARGET_ROLES = 'target_roles'; + +export const TARGET_OPTIONS = [ + { + value: TARGET_ALL, + text: s__('BroadcastMessages|Show to all users on all pages'), + }, + { + value: TARGET_ALL_MATCHING_PATH, + text: s__('BroadcastMessages|Show to all users on specific matching pages'), + }, + { + value: TARGET_ROLES, + text: s__( + 'BroadcastMessages|Show only to users who have specific roles on groups/project pages', + ), + }, +]; + export const NEW_BROADCAST_MESSAGE = { message: '', broadcastType: TYPES[0].value, diff --git a/app/graphql/types/ci/config/include_type.rb b/app/graphql/types/ci/config/include_type.rb index 71eb8f755ab..b5816453a51 100644 --- a/app/graphql/types/ci/config/include_type.rb +++ b/app/graphql/types/ci/config/include_type.rb @@ -15,22 +15,22 @@ module Types field :location, GraphQL::Types::String, null: true, - description: 'File location. It can be masked if it contains masked variables, e.g., ' \ - '".gitlab/ci/build-images.gitlab-ci.yml".' + description: 'File location. It can be masked if it contains masked variables. For example, ' \ + '`".gitlab/ci/build-images.gitlab-ci.yml"`.' field :blob, GraphQL::Types::String, null: true, - description: 'File blob location. It can be masked if it contains masked variables, e.g., ' \ - '"https://gitlab.com/gitlab-org/gitlab/-/blob/e52d6d0246d7375291850e61f0abc101fbda9dc2' \ - '/.gitlab/ci/build-images.gitlab-ci.yml".' + description: 'File blob location. It can be masked if it contains masked variables. For example, ' \ + '`"https://gitlab.com/gitlab-org/gitlab/-/blob/e52d6d0246d7375291850e61f0abc101fbda9dc2' \ + '/.gitlab/ci/build-images.gitlab-ci.yml"`.' field :raw, GraphQL::Types::String, null: true, - description: 'File raw location. It can be masked if it contains masked variables, e.g., ' \ - '"https://gitlab.com/gitlab-org/gitlab/-/raw/e52d6d0246d7375291850e61f0abc101fbda9dc2' \ - '/.gitlab/ci/build-images.gitlab-ci.yml".' + description: 'File raw location. It can be masked if it contains masked variables. For example, ' \ + '`"https://gitlab.com/gitlab-org/gitlab/-/raw/e52d6d0246d7375291850e61f0abc101fbda9dc2' \ + '/.gitlab/ci/build-images.gitlab-ci.yml"`.' field :extra, # rubocop:disable Graphql/JSONType GraphQL::Types::JSON, |