diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-11 18:07:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-03-11 18:07:48 +0300 |
commit | e46506bcc32de1af076ec8a5d51d405f827dd986 (patch) | |
tree | bb08cb3d53132eef0e8d17e1f6bab9d672454ddd /app | |
parent | e105f6b881d9341331558c8c42f90391bab2fd19 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
11 files changed, 137 insertions, 23 deletions
diff --git a/app/assets/javascripts/admin/applications/components/delete_application.vue b/app/assets/javascripts/admin/applications/components/delete_application.vue new file mode 100644 index 00000000000..77694296b0a --- /dev/null +++ b/app/assets/javascripts/admin/applications/components/delete_application.vue @@ -0,0 +1,84 @@ +<script> +import { GlModal, GlSprintf } from '@gitlab/ui'; +import { __ } from '~/locale'; +import csrf from '~/lib/utils/csrf'; + +export default { + components: { + GlModal, + GlSprintf, + }, + data() { + return { + name: '', + path: '', + buttons: [], + }; + }, + mounted() { + this.buttons = document.querySelectorAll('.js-application-delete-button'); + + this.buttons.forEach((button) => button.addEventListener('click', this.buttonEvent)); + }, + destroy() { + this.buttons.forEach((button) => button.removeEventListener('click', this.buttonEvent)); + }, + methods: { + buttonEvent(e) { + e.preventDefault(); + this.show(e.target.dataset); + }, + show(dataset) { + const { name, path } = dataset; + + this.name = name; + this.path = path; + + this.$refs.deleteModal.show(); + }, + deleteApplication() { + this.$refs.deleteForm.submit(); + }, + }, + i18n: { + destroy: __('Destroy'), + title: __('Confirm destroy application'), + body: __('Are you sure that you want to destroy %{application}'), + }, + modal: { + actionPrimary: { + text: __('Destroy'), + attributes: { + variant: 'danger', + }, + }, + actionSecondary: { + text: __('Cancel'), + attributes: { + variant: 'default', + }, + }, + }, + csrf, +}; +</script> +<template> + <gl-modal + ref="deleteModal" + :title="$options.i18n.title" + :action-primary="$options.modal.actionPrimary" + :action-secondary="$options.modal.actionSecondary" + modal-id="delete-application-modal" + size="sm" + @primary="deleteApplication" + ><gl-sprintf :message="$options.i18n.body"> + <template #application> + <strong>{{ name }}</strong> + </template></gl-sprintf + > + <form ref="deleteForm" method="post" :action="path"> + <input type="hidden" name="_method" value="delete" /> + <input type="hidden" name="authenticity_token" :value="$options.csrf.token" /> + </form> + </gl-modal> +</template> diff --git a/app/assets/javascripts/admin/applications/index.js b/app/assets/javascripts/admin/applications/index.js new file mode 100644 index 00000000000..5875fd18729 --- /dev/null +++ b/app/assets/javascripts/admin/applications/index.js @@ -0,0 +1,15 @@ +import Vue from 'vue'; +import DeleteApplication from './components/delete_application.vue'; + +export default () => { + const el = document.querySelector('.js-application-delete-modal'); + + if (!el) return false; + + return new Vue({ + el, + render(h) { + return h(DeleteApplication); + }, + }); +}; diff --git a/app/assets/javascripts/pages/admin/applications/index.js b/app/assets/javascripts/pages/admin/applications/index.js new file mode 100644 index 00000000000..3397b02aeba --- /dev/null +++ b/app/assets/javascripts/pages/admin/applications/index.js @@ -0,0 +1,3 @@ +import initApplicationDeleteButtons from '~/admin/applications'; + +initApplicationDeleteButtons(); diff --git a/app/assets/javascripts/security_configuration/components/constants.js b/app/assets/javascripts/security_configuration/components/constants.js index 11e092d8eb4..3def5e9d6b7 100644 --- a/app/assets/javascripts/security_configuration/components/constants.js +++ b/app/assets/javascripts/security_configuration/components/constants.js @@ -222,14 +222,12 @@ export const securityFeatures = [ helpPath: COVERAGE_FUZZING_HELP_PATH, configurationHelpPath: COVERAGE_FUZZING_CONFIG_HELP_PATH, type: REPORT_TYPE_COVERAGE_FUZZING, - secondary: gon?.features?.corpusManagementUi - ? { - type: REPORT_TYPE_CORPUS_MANAGEMENT, - name: CORPUS_MANAGEMENT_NAME, - description: CORPUS_MANAGEMENT_DESCRIPTION, - configurationText: CORPUS_MANAGEMENT_CONFIG_TEXT, - } - : {}, + secondary: { + type: REPORT_TYPE_CORPUS_MANAGEMENT, + name: CORPUS_MANAGEMENT_NAME, + description: CORPUS_MANAGEMENT_DESCRIPTION, + configurationText: CORPUS_MANAGEMENT_CONFIG_TEXT, + }, }, ]; diff --git a/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue b/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue index a27dbee31ec..558fe8ca2aa 100644 --- a/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue +++ b/app/assets/javascripts/sidebar/components/assignees/uncollapsed_assignee_list.vue @@ -114,7 +114,7 @@ export default { class="gl-display-inline-block" > <attention-requested-toggle - v-if="showVerticalList && user.can_update_merge_request" + v-if="showVerticalList" :user="user" type="assignee" @toggle-attention-requested="toggleAttentionRequested" diff --git a/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue b/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue index 42e56906e2c..d11bed4f058 100644 --- a/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue +++ b/app/assets/javascripts/sidebar/components/attention_requested_toggle.vue @@ -8,6 +8,8 @@ export default { attentionRequestedReviewer: __('Request attention to review'), attentionRequestedAssignee: __('Request attention'), removeAttentionRequested: __('Remove attention request'), + attentionRequestedNoPermission: __('Attention requested'), + noAttentionRequestedNoPermission: __('No attention request'), }, components: { GlButton, @@ -33,17 +35,25 @@ export default { computed: { tooltipTitle() { if (this.user.attention_requested) { - return this.$options.i18n.removeAttentionRequested; + if (this.user.can_update_merge_request) { + return this.$options.i18n.removeAttentionRequested; + } + + return this.$options.i18n.attentionRequestedNoPermission; + } + + if (this.user.can_update_merge_request) { + return this.type === 'reviewer' + ? this.$options.i18n.attentionRequestedReviewer + : this.$options.i18n.attentionRequestedAssignee; } - return this.type === 'reviewer' - ? this.$options.i18n.attentionRequestedReviewer - : this.$options.i18n.attentionRequestedAssignee; + return this.$options.i18n.noAttentionRequestedNoPermission; }, }, methods: { toggleAttentionRequired() { - if (this.loading) return; + if (this.loading || !this.user.can_update_merge_request) return; this.$root.$emit(BV_HIDE_TOOLTIP); this.loading = true; @@ -60,12 +70,13 @@ export default { </script> <template> - <span v-gl-tooltip.left.viewport="tooltipTitle"> + <span v-gl-tooltip.left.viewport="tooltipTitle" class="gl-display-inline-block"> <gl-button :loading="loading" :variant="user.attention_requested ? 'warning' : 'default'" :icon="user.attention_requested ? 'attention-solid' : 'attention'" :aria-label="tooltipTitle" + :class="{ 'gl-pointer-events-none': !user.can_update_merge_request }" size="small" category="tertiary" @click="toggleAttentionRequired" diff --git a/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue b/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue index adaf1b65f3f..9485802d3da 100644 --- a/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue +++ b/app/assets/javascripts/sidebar/components/reviewers/uncollapsed_reviewer_list.vue @@ -98,7 +98,7 @@ export default { data-testid="reviewer" > <attention-requested-toggle - v-if="glFeatures.mrAttentionRequests && user.can_update_merge_request" + v-if="glFeatures.mrAttentionRequests" :user="user" type="reviewer" @toggle-attention-requested="toggleAttentionRequested" diff --git a/app/models/repository.rb b/app/models/repository.rb index e0b1901d188..346478b6689 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -1085,10 +1085,10 @@ class Repository blob.data end - def create_if_not_exists + def create_if_not_exists(default_branch = nil) return if exists? - raw.create_repository + raw.create_repository(default_branch) after_create true diff --git a/app/models/snippet.rb b/app/models/snippet.rb index b04fca64c87..ac87da4f3c8 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -367,7 +367,7 @@ class Snippet < ApplicationRecord def create_repository return if repository_exists? && snippet_repository - repository.create_if_not_exists + repository.create_if_not_exists(default_branch) track_snippet_repository(repository.storage) end diff --git a/app/views/admin/applications/_delete_form.html.haml b/app/views/admin/applications/_delete_form.html.haml index d348ad507c2..16ec8014c5e 100644 --- a/app/views/admin/applications/_delete_form.html.haml +++ b/app/views/admin/applications/_delete_form.html.haml @@ -1,4 +1,5 @@ -- submit_btn_css ||= 'gl-button btn btn-danger btn-sm' -= form_tag admin_application_path(application) do - %input{ :name => "_method", :type => "hidden", :value => "delete" }/ - = submit_tag 'Destroy', class: submit_btn_css, data: { confirm: _('Are you sure?') } + +- submit_btn_css ||= 'gl-button btn btn-danger btn-sm js-application-delete-button' +%button{ class: submit_btn_css, data: { path: admin_application_path(application), name: application.name } } + = _('Destroy') + diff --git a/app/views/admin/applications/index.html.haml b/app/views/admin/applications/index.html.haml index 28a7bd1820a..86a4ab00ba3 100644 --- a/app/views/admin/applications/index.html.haml +++ b/app/views/admin/applications/index.html.haml @@ -33,3 +33,5 @@ %td= render 'delete_form', application: application = paginate @applications, theme: 'gitlab' + +.js-application-delete-modal |