diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-11 12:12:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-11 12:12:21 +0300 |
commit | 3e9023894d319cf56b7b844910953df19ca010b1 (patch) | |
tree | dfa5e229c23abfd1a7dcb0db9b4427aef4d1ddb9 /app | |
parent | 022301b9e9745a9005df11571045227af4d91733 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
14 files changed, 99 insertions, 35 deletions
diff --git a/app/assets/javascripts/boards/components/board_list_header.vue b/app/assets/javascripts/boards/components/board_list_header.vue index 0863fb2c10a..e985a368e64 100644 --- a/app/assets/javascripts/boards/components/board_list_header.vue +++ b/app/assets/javascripts/boards/components/board_list_header.vue @@ -329,13 +329,13 @@ export default { class="board-title-main-text gl-text-truncate" > {{ listTitle }} - <div + <span v-if="iterationCadencesAvailable" - class="gl-display-inline-block" + class="gl-display-inline-block gl-text-gray-400" data-testid="board-list-iteration-period" > - <time class="gl-text-gray-400">{{ listIterationPeriod }}</time> - </div> + {{ listIterationPeriod }}</span + > </span> <span v-if="listType === 'assignee'" diff --git a/app/assets/javascripts/issues_list/queries/iteration.fragment.graphql b/app/assets/javascripts/issues_list/queries/iteration.fragment.graphql index c094761e915..4f7217be7f7 100644 --- a/app/assets/javascripts/issues_list/queries/iteration.fragment.graphql +++ b/app/assets/javascripts/issues_list/queries/iteration.fragment.graphql @@ -1,6 +1,8 @@ fragment Iteration on Iteration { id title + startDate + dueDate iterationCadence { id title diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/commit_edit.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/commit_edit.vue index c501e410b1f..3eda2828e97 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/commit_edit.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/commit_edit.vue @@ -41,7 +41,7 @@ export default { rows="7" @input="$emit('input', $event.target.value)" ></textarea> - <slot name="checkbox"></slot> + <slot name="text-muted"></slot> </div> </li> </template> diff --git a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue index aca838ce099..d2cc99302a9 100644 --- a/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue +++ b/app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue @@ -18,9 +18,10 @@ import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests import createFlash from '~/flash'; import { secondsToMilliseconds } from '~/lib/utils/datetime_utility'; import simplePoll from '~/lib/utils/simple_poll'; -import { __ } from '~/locale'; +import { __, s__ } from '~/locale'; import SmartInterval from '~/smart_interval'; import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; +import { helpPagePath } from '~/helpers/help_page_helper'; import MergeRequest from '../../../merge_request'; import { AUTO_MERGE_STRATEGIES, @@ -179,6 +180,11 @@ export default { return this.mr.canRemoveSourceBranch; }, + commitTemplateHelpPage() { + return helpPagePath('user/project/merge_requests/commit_templates.md', { + anchor: 'merge-commit-message-template', + }); + }, commits() { if (this.glFeatures.mergeRequestWidgetGraphql) { return this.state.commitsWithoutMergeCommits.nodes; @@ -347,15 +353,6 @@ export default { updateGraphqlState() { return this.$apollo.queries.state.refetch(); }, - updateMergeCommitMessage(includeDescription) { - const commitMessage = this.glFeatures.mergeRequestWidgetGraphql - ? this.state.defaultMergeCommitMessage - : this.mr.commitMessage; - const commitMessageWithDescription = this.glFeatures.mergeRequestWidgetGraphql - ? this.state.defaultMergeCommitMessageWithDescription - : this.mr.commitMessageWithDescription; - this.commitMessage = includeDescription ? commitMessageWithDescription : commitMessage; - }, handleMergeButtonClick(useAutoMerge, mergeImmediately = false, confirmationClicked = false) { if (this.showFailedPipelineModal && !confirmationClicked) { this.isPipelineFailedModalVisible = true; @@ -508,6 +505,11 @@ export default { }); }, }, + i18n: { + mergeCommitTemplateHintText: s__( + 'mrWidget|To change this default message, edit the template for merge commit messages. %{linkStart}Learn more.%{linkEnd}', + ), + }, }; </script> @@ -679,15 +681,20 @@ export default { input-id="merge-message-edit" class="gl-m-0! gl-p-0!" > - <template #checkbox> - <label> - <input - id="include-description" - type="checkbox" - @change="updateMergeCommitMessage($event.target.checked)" - /> - {{ __('Include merge request description') }} - </label> + <template #text-muted> + <p class="form-text text-muted"> + <gl-sprintf :message="$options.i18n.mergeCommitTemplateHintText"> + <template #link="{ content }"> + <gl-link + :href="commitTemplateHelpPage" + class="inline-link" + target="_blank" + > + {{ content }} + </gl-link> + </template> + </gl-sprintf> + </p> </template> </commit-edit> </ul> @@ -792,15 +799,16 @@ export default { :label="__('Merge commit message')" input-id="merge-message-edit" > - <template #checkbox> - <label> - <input - id="include-description" - type="checkbox" - @change="updateMergeCommitMessage($event.target.checked)" - /> - {{ __('Include merge request description') }} - </label> + <template #text-muted> + <p class="form-text text-muted"> + <gl-sprintf :message="$options.i18n.mergeCommitTemplateHintText"> + <template #link="{ content }"> + <gl-link :href="commitTemplateHelpPage" class="inline-link" target="_blank"> + {{ content }} + </gl-link> + </template> + </gl-sprintf> + </p> </template> </commit-edit> </ul> diff --git a/app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/iteration_token.vue b/app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/iteration_token.vue index d93daac1072..aff93ebc9c0 100644 --- a/app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/iteration_token.vue +++ b/app/assets/javascripts/vue_shared/components/filtered_search_bar/tokens/iteration_token.vue @@ -4,6 +4,8 @@ import createFlash from '~/flash'; import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { __ } from '~/locale'; import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue'; +import { formatDate } from '~/lib/utils/datetime_utility'; +import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import { DEFAULT_ITERATIONS } from '../constants'; export default { @@ -13,6 +15,7 @@ export default { GlDropdownSectionHeader, GlFilteredSearchSuggestion, }, + mixins: [glFeatureFlagMixin()], props: { active: { type: Boolean, @@ -49,7 +52,11 @@ export default { return; } const { title } = iteration.iterationCadence; - const cadenceIteration = { id: iteration.id, title: iteration.title }; + const cadenceIteration = { + id: iteration.id, + title: iteration.title, + period: this.getIterationPeriod(iteration), + }; const cadence = cadences.find((cad) => cad.title === title); if (cadence) { cadence.iterations.push(cadenceIteration); @@ -76,6 +83,16 @@ export default { getValue(iteration) { return String(getIdFromGraphQLId(iteration.id)); }, + /** + * TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/344619 + * This method also exists as a utility function in ee/../iterations/utils.js + * Remove the duplication when iteration token is moved to EE. + */ + getIterationPeriod({ startDate, dueDate }) { + const start = formatDate(startDate, 'mmm d, yyyy', true); + const due = formatDate(dueDate, 'mmm d, yyyy', true); + return `${start} - ${due}`; + }, }, }; </script> @@ -111,6 +128,9 @@ export default { :value="getValue(iteration)" > {{ iteration.title }} + <div v-if="glFeatures.iterationCadences" class="gl-text-gray-400"> + {{ iteration.period }} + </div> </gl-filtered-search-suggestion> </template> </template> diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index bda52cd94e4..9dcd3984011 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -447,6 +447,7 @@ class ProjectsController < Projects::ApplicationController :suggestion_commit_message, :packages_enabled, :service_desk_enabled, + :merge_commit_template, project_setting_attributes: project_setting_attributes ] + [project_feature_attributes: project_feature_attributes] end diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index a8a96b0ccef..a0f00ddc3c6 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -99,7 +99,8 @@ module Types field :default_merge_commit_message, GraphQL::Types::String, null: true, description: 'Default merge commit message of the merge request.' field :default_merge_commit_message_with_description, GraphQL::Types::String, null: true, - description: 'Default merge commit message of the merge request with description.' + description: 'Default merge commit message of the merge request with description. Will have the same value as `defaultMergeCommitMessage` when project has `mergeCommitTemplate` set.', + deprecated: { reason: 'Define merge commit template in project and use `defaultMergeCommitMessage`', milestone: '14.5' } field :default_squash_commit_message, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Default squash commit message of the merge request.' field :merge_ongoing, GraphQL::Types::Boolean, method: :merge_ongoing?, null: false, diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 791875242df..dd73fb8dceb 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -381,6 +381,11 @@ module Types description: 'Cluster agents associated with the project.', resolver: ::Resolvers::Clusters::AgentsResolver + field :merge_commit_template, + GraphQL::Types::String, + null: true, + description: 'Template used to create merge commit message in merge requests.' + def label(title:) BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args| LabelsFinder diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 592f7eadc49..3fdc44bccf3 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -171,6 +171,7 @@ module Ci scope :with_live_trace, -> { where('EXISTS (?)', Ci::BuildTraceChunk.where('ci_builds.id = ci_build_trace_chunks.build_id').select(1)) } scope :with_stale_live_trace, -> { with_live_trace.finished_before(12.hours.ago) } scope :finished_before, -> (date) { finished.where('finished_at < ?', date) } + scope :license_management_jobs, -> { where(name: %i(license_management license_scanning)) } # handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911 scope :with_secure_reports_from_config_options, -> (job_types) do joins(:metadata).where("ci_builds_metadata.config_options -> 'artifacts' -> 'reports' ?| array[:job_types]", job_types: job_types) diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 5a74f8392ec..f2f9b527cc0 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -1316,6 +1316,10 @@ class MergeRequest < ApplicationRecord end def default_merge_commit_message(include_description: false) + if self.target_project.merge_commit_template.present? && !include_description + return ::Gitlab::MergeRequests::MergeCommitMessage.new(merge_request: self).message + end + closes_issues_references = visible_closing_issues_for.map do |issue| issue.to_reference(target_project) end diff --git a/app/models/project.rb b/app/models/project.rb index 36f48b91221..2f98a116815 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -452,6 +452,7 @@ class Project < ApplicationRecord :allow_merge_on_skipped_pipeline=, :has_confluence?, to: :project_setting delegate :active?, to: :prometheus_integration, allow_nil: true, prefix: true + delegate :merge_commit_template, :merge_commit_template=, to: :project_setting, allow_nil: true delegate :log_jira_dvcs_integration_usage, :jira_dvcs_server_last_sync_at, :jira_dvcs_cloud_last_sync_at, to: :feature_usage diff --git a/app/models/project_setting.rb b/app/models/project_setting.rb index 24d892290a6..6c8d2226bc9 100644 --- a/app/models/project_setting.rb +++ b/app/models/project_setting.rb @@ -12,6 +12,8 @@ class ProjectSetting < ApplicationRecord self.primary_key = :project_id + validates :merge_commit_template, length: { maximum: 500 } + def squash_enabled_by_default? %w[always default_on].include?(squash_option) end diff --git a/app/views/projects/_merge_request_merge_commit_template.html.haml b/app/views/projects/_merge_request_merge_commit_template.html.haml new file mode 100644 index 00000000000..185b730e0bb --- /dev/null +++ b/app/views/projects/_merge_request_merge_commit_template.html.haml @@ -0,0 +1,17 @@ +- form = local_assigns.fetch(:form) + +.form-group + %b= s_('ProjectSettings|Merge commit message template') + %p.text-secondary + - configure_the_merge_commit_message_help_link_url = help_page_path('user/project/merge_requests/commit_templates.md', anchor: 'merge-commit-message-template') + - configure_the_merge_commit_message_help_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: configure_the_merge_commit_message_help_link_url } + = s_('ProjectSettings|The commit message used when merging, if the merge method creates a merge commit. %{link_start}Learn more about syntax and variables.%{link_end}').html_safe % { link_start: configure_the_merge_commit_message_help_link_start, link_end: '</a>'.html_safe } + .mb-2 + - default_merge_commit_template = "Merge branch '%{source_branch}' into '%{target_branch}'\n\n%{title}\n\n%{issues}\n\nSee merge request %{reference}" + = form.text_area :merge_commit_template, class: 'form-control gl-form-input', rows: 8, maxlength: 500, placeholder: default_merge_commit_template + %p.form-text.text-muted + = s_('ProjectSettings|Maximum 500 characters.') + = s_('ProjectSettings|Supported variables:') + - Gitlab::MergeRequests::MergeCommitMessage::PLACEHOLDERS.keys.each do |placeholder| + %code + = "%{#{placeholder}}".html_safe diff --git a/app/views/projects/_merge_request_settings.html.haml b/app/views/projects/_merge_request_settings.html.haml index f595b4f709b..c5a25bec6eb 100644 --- a/app/views/projects/_merge_request_settings.html.haml +++ b/app/views/projects/_merge_request_settings.html.haml @@ -10,5 +10,7 @@ = render 'projects/merge_request_merge_suggestions_settings', project: @project, form: form += render 'projects/merge_request_merge_commit_template', project: @project, form: form + - if @project.forked? = render 'projects/merge_request_target_project_settings', project: @project, form: form |