Commit 73366c2e authored by Joseph Snyder's avatar Joseph Snyder

Switch to "positive" description

Switch from opting into "hiding" the diff displays but to opting out
of showing the diff previews.

Ensure that the new value is true by default.
parent 9950838e
......@@ -199,7 +199,7 @@ export default {
requestAccessEnabled: true,
highlightChangesClass: false,
emailsDisabled: false,
hideDiffsInEmail: false,
showDiffPreviewInEmail: true,
cveIdRequestEnabled: true,
featureAccessLevelEveryone,
featureAccessLevelMembers,
......@@ -763,17 +763,19 @@ export default {
</project-setting-row>
<project-setting-row class="mb-3">
<input
:value="hideDiffsInEmail"
:value="showDiffPreviewInEmail"
type="hidden"
name="project[project_setting_attributes][hide_diffs_in_email]"
name="project[project_setting_attributes][show_diff_preview_in_email]"
/>
<gl-form-checkbox
v-model="hideDiffsInEmail"
name="project[project_setting_attributes][hide_diffs_in_email]"
v-model="showDiffPreviewInEmail"
name="project[project_setting_attributes][show_diff_preview_in_email]"
>
{{ s__('ProjectSettings|Stop displaying diffs in MR emails') }}
{{ s__('ProjectSettings|Include diff preview in merge request notification emails') }}
<template #help>{{
s__('ProjectSettings|Disable the inclusion of code diffs in an MR review .')
s__(
'ProjectSettings|Include the code diff preview on comment threads in merge request notification emails.',
)
}}</template>
</gl-form-checkbox>
</project-setting-row>
......
......@@ -419,7 +419,7 @@ class ProjectsController < Projects::ApplicationController
%i[
show_default_award_emojis
squash_option
hide_diffs_in_email
show_diff_preview_in_email
mr_default_target_self
warn_about_potentially_unwanted_characters
]
......
......@@ -586,7 +586,7 @@ module ProjectsHelper
metricsDashboardAccessLevel: feature.metrics_dashboard_access_level,
operationsAccessLevel: feature.operations_access_level,
showDefaultAwardEmojis: project.show_default_award_emojis?,
hideDiffsInEmail: project.hide_diffs_in_email?,
showDiffPreviewInEmail: project.show_diff_preview_in_email?,
warnAboutPotentiallyUnwantedCharacters: project.warn_about_potentially_unwanted_characters?,
securityAndComplianceAccessLevel: project.security_and_compliance_access_level,
containerRegistryAccessLevel: feature.container_registry_access_level
......
......@@ -433,7 +433,7 @@ class Project < ApplicationRecord
alias_method :container_registry_enabled, :container_registry_enabled?
delegate :show_default_award_emojis, :show_default_award_emojis=, :show_default_award_emojis?,
:warn_about_potentially_unwanted_characters, :warn_about_potentially_unwanted_characters=, :warn_about_potentially_unwanted_characters?,
:hide_diffs_in_email, :hide_diffs_in_email=, :hide_diffs_in_email?,
:show_diff_preview_in_email, :show_diff_preview_in_email=, :show_diff_preview_in_email?,
to: :project_setting, allow_nil: true
delegate :scheduled?, :started?, :in_progress?, :failed?, :finished?,
prefix: :import, to: :import_state, allow_nil: true
......
......@@ -229,7 +229,7 @@ class ProjectPolicy < BasePolicy
enable :set_note_created_at
enable :set_emails_disabled
enable :set_show_default_award_emojis
enable :set_hide_diffs_in_email
enable :set_show_diff_preview_in_email
enable :set_warn_about_potentially_unwanted_characters
end
......
......@@ -20,7 +20,7 @@
discussion on #{link_to(discussion.file_path, target_url)}
- else
= link_to 'discussion', target_url
- if discussion&.diff_discussion? && discussion.on_text? && !@project.hide_diffs_in_email?
- if discussion&.diff_discussion? && discussion.on_text? && @project.show_diff_preview_in_email?
= content_for :head do
= stylesheet_link_tag 'mailers/highlighted_diff_email'
......
......@@ -20,7 +20,7 @@
<% end -%>
<% if discussion&.diff_discussion? && discussion.on_text? && !@project.hide_diffs_in_email? -%>
<% if discussion&.diff_discussion? && discussion.on_text? && @project.show_diff_preview_in_email? -%>
<% discussion.truncated_diff_lines(highlight: false, diff_limit: diff_limit).each do |line| -%>
<%= "> #{line.text}\n" -%>
<% end -%>
......
# frozen_string_literal: true
class AddHideDiffsInEmailToProjectSettings < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def change
add_column :project_settings, :hide_diffs_in_email, :boolean, default: false, null: false
end
end
# frozen_string_literal: true
class AddShowDiffPreviewInEmailToProjectSettings < Gitlab::Database::Migration[1.0]
enable_lock_retries!
def change
add_column :project_settings, :show_diff_preview_in_email, :boolean, default: true, null: false
end
end
7b2e3f15dcc364fbb6cc0c2f2b7923dd717fdd0294a8158a139b689f4a940c64
\ No newline at end of file
3b9068f109685dcfa8a0a1fda886cca3909d29cbc280cf70ed9f3d927def12ac
\ No newline at end of file
......@@ -18695,7 +18695,7 @@ CREATE TABLE project_settings (
merge_commit_template text,
has_shimo boolean DEFAULT false NOT NULL,
squash_commit_template text,
hide_diffs_in_email boolean DEFAULT false NOT NULL,
show_diff_preview_in_email boolean DEFAULT true NOT NULL,
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
......@@ -28201,9 +28201,6 @@ msgstr ""
msgid "ProjectSettings|Disable email notifications"
msgstr ""
msgid "ProjectSettings|Disable the inclusion of code diffs in an MR review ."
msgstr ""
msgid "ProjectSettings|Do not allow"
msgstr ""
......@@ -28267,6 +28264,12 @@ msgstr ""
msgid "ProjectSettings|If merge trains are enabled, merging is only possible if the branch can be rebased without conflicts."
msgstr ""
msgid "ProjectSettings|Include diff preview in merge request notification emails"
msgstr ""
msgid "ProjectSettings|Include the code diff preview on comment threads in merge request notification emails."
msgstr ""
msgid "ProjectSettings|Internal"
msgstr ""
......@@ -28408,9 +28411,6 @@ msgstr ""
msgid "ProjectSettings|Squashing is never performed and the checkbox is hidden."
msgstr ""
msgid "ProjectSettings|Stop displaying diffs in MR emails"
msgstr ""
msgid "ProjectSettings|Submit changes to be merged upstream."
msgstr ""
......
......@@ -85,33 +85,33 @@ RSpec.describe 'Projects settings' do
end
end
context 'hide diffs in emails', :js do
context 'show diffs in emails', :js do
it 'does not hide diffs by default' do
visit edit_project_path(project)
hide_diffs_in_email_input = find('input[name="project[project_setting_attributes][hide_diffs_in_email]"]', visible: :hidden)
show_diff_preview_in_email_input = find('input[name="project[project_setting_attributes][show_diff_preview_in_email]"]', visible: :hidden)
expect(hide_diffs_in_email_input.value).to eq('false')
expect(show_diff_preview_in_email_input.value).to eq('true')
end
it 'hides diffs in emails when toggled on' do
it 'hides diffs in emails when toggled' do
visit edit_project_path(project)
hide_diffs_in_email_input = find('input[name="project[project_setting_attributes][hide_diffs_in_email]"]', visible: :hidden)
hide_diffs_in_email_checkbox = find('input[name="project[project_setting_attributes][hide_diffs_in_email]"][type=checkbox]')
show_diff_preview_in_email_input = find('input[name="project[project_setting_attributes][show_diff_preview_in_email]"]', visible: :hidden)
show_diff_preview_in_email_checkbox = find('input[name="project[project_setting_attributes][show_diff_preview_in_email]"][type=checkbox]')
expect(hide_diffs_in_email_input.value).to eq('false')
expect(show_diff_preview_in_email_input.value).to eq('true')
hide_diffs_in_email_checkbox.click
show_diff_preview_in_email_checkbox.click
expect(hide_diffs_in_email_input.value).to eq('true')
expect(show_diff_preview_in_email_input.value).to eq('false')
page.within('.sharing-permissions') do
find('[data-testid="project-features-save-button"]').click
end
wait_for_requests
expect(hide_diffs_in_email_input.value).to eq('true')
expect(show_diff_preview_in_email_input.value).to eq('false')
end
end
......
......@@ -28,7 +28,7 @@ const defaultProps = {
emailsDisabled: false,
packagesEnabled: true,
showDefaultAwardEmojis: true,
hideDiffsInEmail: false,
showDiffPreviewInEmail: true,
warnAboutPotentiallyUnwantedCharacters: true,
},
isGitlabCom: true,
......@@ -103,8 +103,8 @@ describe('Settings Panel', () => {
const findShowDefaultAwardEmojis = () =>
wrapper.find('input[name="project[project_setting_attributes][show_default_award_emojis]"]');
const findHideDiffsInEmail = () =>
wrapper.find('input[name="project[project_setting_attributes][hide_diffs_in_email]"]');
const findShowDiffPreviewInEmail = () =>
wrapper.find('input[name="project[project_setting_attributes][show_diff_preview_in_email]"]');
const findWarnAboutPuc = () =>
wrapper.find(
'input[name="project[project_setting_attributes][warn_about_potentially_unwanted_characters]"]',
......@@ -593,7 +593,7 @@ describe('Settings Panel', () => {
it('should show the "Hide Diffs in email" input', () => {
wrapper = mountComponent();
expect(findHideDiffsInEmail().exists()).toBe(true);
expect(findShowDiffPreviewInEmail().exists()).toBe(true);
});
});
......
......@@ -964,7 +964,7 @@ RSpec.describe ProjectsHelper do
metricsDashboardAccessLevel: project.project_feature.metrics_dashboard_access_level,
operationsAccessLevel: project.project_feature.operations_access_level,
showDefaultAwardEmojis: project.show_default_award_emojis?,
hideDiffsInEmail: project.hide_diffs_in_email?,
showDiffPreviewInEmail: project.show_diff_preview_in_email?,
securityAndComplianceAccessLevel: project.security_and_compliance_access_level,
containerRegistryAccessLevel: project.project_feature.container_registry_access_level
)
......
......@@ -145,7 +145,7 @@ project_setting:
- project_id
- push_rule_id
- show_default_award_emojis
- hide_diffs_in_email
- show_diff_preview_in_email
- updated_at
- cve_id_request_enabled
- mr_default_target_self
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment