Skip to content
Snippets Groups Projects
Commit a8c0ea0b authored by Naman Jagdish Gala's avatar Naman Jagdish Gala :speech_balloon:
Browse files

Rename pages_default_domain_redirect to pages_primary_domain

Related: #481334 (comment 2276384325)

Changelog: changed
parent e300ab70
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 49 deletions
...@@ -68,10 +68,10 @@ def root_directory ...@@ -68,10 +68,10 @@ def root_directory
end end
strong_memoize_attr :root_directory strong_memoize_attr :root_directory
def default_domain_redirect def primary_domain
project&.project_setting&.pages_default_domain_redirect project&.project_setting&.pages_primary_domain
end end
strong_memoize_attr :default_domain_redirect strong_memoize_attr :primary_domain
private private
......
...@@ -14,7 +14,7 @@ def unique_domain_enabled? = project.project_setting.pages_unique_domain_enabled ...@@ -14,7 +14,7 @@ def unique_domain_enabled? = project.project_setting.pages_unique_domain_enabled
def force_https? = project.pages_https_only? def force_https? = project.pages_https_only?
def pages_default_domain_redirect = project.project_setting.pages_default_domain_redirect def pages_primary_domain = project.project_setting.pages_primary_domain
private private
......
...@@ -76,7 +76,7 @@ def emails_enabled? ...@@ -76,7 +76,7 @@ def emails_enabled?
end end
strong_memoize_attr :emails_enabled? strong_memoize_attr :emails_enabled?
def pages_default_domain_redirect=(value) def pages_primary_domain=(value)
super(value.presence) # Call the default setter to set the value super(value.presence) # Call the default setter to set the value
end end
......
...@@ -21,7 +21,7 @@ def execute ...@@ -21,7 +21,7 @@ def execute
private private
def update_pages_project_settings! def update_pages_project_settings!
pages_project_settings = params.slice(:pages_unique_domain_enabled, :pages_default_domain_redirect) pages_project_settings = params.slice(:pages_unique_domain_enabled, :pages_primary_domain)
return if pages_project_settings.empty? return if pages_project_settings.empty?
project.project_setting.update!(pages_project_settings) project.project_setting.update!(pages_project_settings)
......
...@@ -138,12 +138,12 @@ def validate_renaming_project_with_tags ...@@ -138,12 +138,12 @@ def validate_renaming_project_with_tags
end end
def validate_pages_default_domain_redirect def validate_pages_default_domain_redirect
default_domain_redirect = params.dig(:project_setting_attributes, :pages_default_domain_redirect) primary_domain = params.dig(:project_setting_attributes, :pages_primary_domain)
return unless default_domain_redirect.presence return unless primary_domain.presence
return if project.pages_domain_present?(default_domain_redirect) return if project.pages_domain_present?(primary_domain)
raise_validation_error(s_("UpdateProject|The `pages_default_domain_redirect` attribute is missing from the domain list in the Pages project configuration. Assign `pages_default_domain_redirect` to the Pages project or reset it.")) raise_validation_error(s_("UpdateProject|The `pages_primary_domain` attribute is missing from the domain list in the Pages project configuration. Assign `pages_primary_domain` to the Pages project or reset it."))
end end
def ambiguous_head_documentation_link def ambiguous_head_documentation_link
......
...@@ -12,10 +12,10 @@ def handle_event(event) ...@@ -12,10 +12,10 @@ def handle_event(event)
project_settings = ProjectSetting.find_by_project_id(event.data['project_id']) project_settings = ProjectSetting.find_by_project_id(event.data['project_id'])
return unless project_settings return unless project_settings
return unless project_settings.pages_default_domain_redirect return unless project_settings.pages_primary_domain
return unless event.data['domain'] == project_settings.pages_default_domain_redirect return unless event.data['domain'] == project_settings.pages_primary_domain
project_settings.update!(pages_default_domain_redirect: nil) project_settings.update!(pages_primary_domain: nil)
end end
end end
end end
# frozen_string_literal: true
class RenamePagesDefaultDomainRedirectToPagesPrimaryDomain < Gitlab::Database::Migration[2.2]
milestone '17.8'
disable_ddl_transaction!
def up
rename_column :project_settings, :pages_default_domain_redirect, :pages_primary_domain
add_text_limit :project_settings, :pages_primary_domain, 255
end
def down
rename_column :project_settings, :pages_primary_domain, :pages_default_domain_redirect
add_text_limit :project_settings, :pages_default_domain_redirect, 255
end
end
8ec7088fe5d55dbf10e270bdc4c9b8c6312f525e671f654c969da77a58cb6d5f
\ No newline at end of file
...@@ -18725,13 +18725,13 @@ CREATE TABLE project_settings ( ...@@ -18725,13 +18725,13 @@ CREATE TABLE project_settings (
observability_alerts_enabled boolean DEFAULT true NOT NULL, observability_alerts_enabled boolean DEFAULT true NOT NULL,
spp_repository_pipeline_access boolean, spp_repository_pipeline_access boolean,
max_number_of_vulnerabilities integer, max_number_of_vulnerabilities integer,
pages_default_domain_redirect text, pages_primary_domain text,
CONSTRAINT check_1a30456322 CHECK ((char_length(pages_unique_domain) <= 63)), CONSTRAINT check_1a30456322 CHECK ((char_length(pages_unique_domain) <= 63)),
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)), CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
CONSTRAINT check_3ca5cbffe6 CHECK ((char_length(issue_branch_template) <= 255)), CONSTRAINT check_3ca5cbffe6 CHECK ((char_length(issue_branch_template) <= 255)),
CONSTRAINT check_4b142e71f3 CHECK ((char_length(product_analytics_data_collector_host) <= 255)), CONSTRAINT check_4b142e71f3 CHECK ((char_length(product_analytics_data_collector_host) <= 255)),
CONSTRAINT check_67292e4b99 CHECK ((char_length(mirror_branch_regex) <= 255)), CONSTRAINT check_67292e4b99 CHECK ((char_length(mirror_branch_regex) <= 255)),
CONSTRAINT check_999e5f0aaa CHECK ((char_length(pages_default_domain_redirect) <= 255)), CONSTRAINT check_999e5f0aaa CHECK ((char_length(pages_primary_domain) <= 255)),
CONSTRAINT check_acb7fad2f9 CHECK ((char_length(product_analytics_instrumentation_key) <= 255)), CONSTRAINT check_acb7fad2f9 CHECK ((char_length(product_analytics_instrumentation_key) <= 255)),
CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)), CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)), CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
...@@ -12,7 +12,7 @@ class LookupPath < Grape::Entity ...@@ -12,7 +12,7 @@ class LookupPath < Grape::Entity
:source, :source,
:unique_host, :unique_host,
:root_directory, :root_directory,
:default_domain_redirect :primary_domain
end end
end end
end end
......
...@@ -8,7 +8,7 @@ class ProjectSettings < Grape::Entity ...@@ -8,7 +8,7 @@ class ProjectSettings < Grape::Entity
expose :deployments, using: "API::Entities::Pages::Deployments" expose :deployments, using: "API::Entities::Pages::Deployments"
expose :unique_domain_enabled?, as: :is_unique_domain_enabled expose :unique_domain_enabled?, as: :is_unique_domain_enabled
expose :force_https?, as: :force_https expose :force_https?, as: :force_https
expose :pages_default_domain_redirect expose :pages_primary_domain
end end
end end
end end
......
...@@ -43,7 +43,7 @@ class Pages < ::API::Base ...@@ -43,7 +43,7 @@ class Pages < ::API::Base
params do params do
optional :pages_unique_domain_enabled, type: Boolean, desc: 'Whether to use unique domain' optional :pages_unique_domain_enabled, type: Boolean, desc: 'Whether to use unique domain'
optional :pages_https_only, type: Boolean, desc: 'Whether to force HTTPS' optional :pages_https_only, type: Boolean, desc: 'Whether to force HTTPS'
optional :pages_default_domain_redirect, type: String, desc: 'Set pages default domain redirect' optional :pages_primary_domain, type: String, desc: 'Set pages primary domain'
end end
patch ':id/pages' do patch ':id/pages' do
authenticated_with_can_read_all_resources! authenticated_with_can_read_all_resources!
...@@ -51,10 +51,10 @@ class Pages < ::API::Base ...@@ -51,10 +51,10 @@ class Pages < ::API::Base
break not_found! unless user_project.pages_enabled? break not_found! unless user_project.pages_enabled?
if params[:pages_default_domain_redirect] && if params[:pages_primary_domain] &&
!user_project.pages_domain_present?(params[:pages_default_domain_redirect]) !user_project.pages_domain_present?(params[:pages_primary_domain])
bad_request!("The `pages_default_domain_redirect` attribute is missing from the domain list " \ bad_request!("The `pages_primary_domain` attribute is missing from the domain list " \
"in the Pages project configuration. Assign `pages_default_domain_redirect` to " \ "in the Pages project configuration. Assign `pages_primary_domain` to " \
"the Pages project or reset it.") "the Pages project or reset it.")
end end
......
...@@ -44,10 +44,10 @@ def add_unique_domain_to(project) ...@@ -44,10 +44,10 @@ def add_unique_domain_to(project)
project.project_setting.pages_unique_domain = generate_unique_domain(project) project.project_setting.pages_unique_domain = generate_unique_domain(project)
end end
def update_default_domain_redirect(project, default_domain_redirect) def update_default_domain_redirect(project, primary_domain)
return unless enabled? return unless enabled?
project.project_setting.pages_default_domain_redirect = default_domain_redirect.presence project.project_setting.pages_primary_domain = primary_domain.presence
end end
def multiple_versions_enabled_for?(project) def multiple_versions_enabled_for?(project)
......
...@@ -60196,7 +60196,7 @@ msgstr "" ...@@ -60196,7 +60196,7 @@ msgstr ""
msgid "UpdateProject|Pruning unreachable objects can lead to repository corruption." msgid "UpdateProject|Pruning unreachable objects can lead to repository corruption."
msgstr "" msgstr ""
   
msgid "UpdateProject|The `pages_default_domain_redirect` attribute is missing from the domain list in the Pages project configuration. Assign `pages_default_domain_redirect` to the Pages project or reset it." msgid "UpdateProject|The `pages_primary_domain` attribute is missing from the domain list in the Pages project configuration. Assign `pages_primary_domain` to the Pages project or reset it."
msgstr "" msgstr ""
   
msgid "UpdateProject|Updating default branch is blocked by security policy" msgid "UpdateProject|Updating default branch is blocked by security policy"
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
"root_directory": { "root_directory": {
"type": "string" "type": "string"
}, },
"default_domain_redirect": { "primary_domain": {
"type": [ "type": [
"string", "string",
"null" "null"
......
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
it 'does not set pages default domain redirect' do it 'does not set pages default domain redirect' do
expect do expect do
described_class.update_default_domain_redirect(project, 'http://example.com') described_class.update_default_domain_redirect(project, 'http://example.com')
end.not_to change { project.project_setting.pages_default_domain_redirect } end.not_to change { project.project_setting.pages_primary_domain }
end end
end end
...@@ -272,7 +272,7 @@ ...@@ -272,7 +272,7 @@
it 'sets pages default domain redirect' do it 'sets pages default domain redirect' do
expect do expect do
described_class.update_default_domain_redirect(project, 'http://example.com') described_class.update_default_domain_redirect(project, 'http://example.com')
end.to change { project.project_setting.pages_default_domain_redirect }.from(nil).to('http://example.com') end.to change { project.project_setting.pages_primary_domain }.from(nil).to('http://example.com')
end end
context 'when pages default domain redirect is updated with blank' do context 'when pages default domain redirect is updated with blank' do
...@@ -281,11 +281,11 @@ ...@@ -281,11 +281,11 @@
end end
it 'sets pages default domain redirect as nil' do it 'sets pages default domain redirect as nil' do
project.project_setting.update!(pages_default_domain_redirect: 'http://example.com') project.project_setting.update!(pages_primary_domain: 'http://example.com')
expect do expect do
described_class.update_default_domain_redirect(project, '') described_class.update_default_domain_redirect(project, '')
end.to change { project.project_setting.pages_default_domain_redirect }.from('http://example.com').to(nil) end.to change { project.project_setting.pages_primary_domain }.from('http://example.com').to(nil)
end end
end end
end end
......
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
end end
end end
describe '#default_domain_redirect' do describe '#primary_domain' do
it 'delegates to Project#project_setting#pages_default_domain_redirect' do it 'delegates to Project#project_setting#pages_primary_domain' do
project.project_setting.pages_default_domain_redirect = 'my.domain.com' project.project_setting.pages_primary_domain = 'my.domain.com'
expect(lookup_path.default_domain_redirect).to eq('my.domain.com') expect(lookup_path.primary_domain).to eq('my.domain.com')
end end
end end
......
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
}, },
'unique_host' => nil, 'unique_host' => nil,
'root_directory' => deployment.root_directory, 'root_directory' => deployment.root_directory,
'default_domain_redirect' => nil 'primary_domain' => nil
} }
] ]
) )
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
}, },
'unique_host' => 'unique-domain.example.com', 'unique_host' => 'unique-domain.example.com',
'root_directory' => 'public', 'root_directory' => 'public',
'default_domain_redirect' => nil 'primary_domain' => nil
} }
] ]
) )
...@@ -197,7 +197,7 @@ ...@@ -197,7 +197,7 @@
before do before do
project.project_setting.update!( project.project_setting.update!(
pages_default_domain_redirect: 'https://pages.io', pages_primary_domain: 'https://pages.io',
pages_unique_domain: 'unique-domain', pages_unique_domain: 'unique-domain',
pages_unique_domain_enabled: true pages_unique_domain_enabled: true
) )
...@@ -226,7 +226,7 @@ ...@@ -226,7 +226,7 @@
}, },
'unique_host' => 'unique-domain.example.com', 'unique_host' => 'unique-domain.example.com',
'root_directory' => 'public', 'root_directory' => 'public',
'default_domain_redirect' => 'https://pages.io' 'primary_domain' => 'https://pages.io'
} }
] ]
) )
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
}, },
'unique_host' => nil, 'unique_host' => nil,
'root_directory' => 'public', 'root_directory' => 'public',
'default_domain_redirect' => nil 'primary_domain' => nil
} }
] ]
) )
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
}, },
'unique_host' => nil, 'unique_host' => nil,
'root_directory' => 'public', 'root_directory' => 'public',
'default_domain_redirect' => nil 'primary_domain' => nil
} }
] ]
) )
......
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
context 'and updates pages default domain redirect' do context 'and updates pages default domain redirect' do
let(:domain) { 'my.domain.com' } let(:domain) { 'my.domain.com' }
let(:params) { { pages_default_domain_redirect: domain } } let(:params) { { pages_primary_domain: domain } }
before do before do
create(:pages_domain, project: project, domain: domain) create(:pages_domain, project: project, domain: domain)
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
patch api(path, admin, admin_mode: true), params: params patch api(path, admin, admin_mode: true), params: params
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['pages_default_domain_redirect']).to eq(domain) expect(json_response['pages_primary_domain']).to eq(domain)
end end
end end
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
end end
context 'when pages default domain redirect is invalid' do context 'when pages default domain redirect is invalid' do
let(:invalid_params) { { pages_default_domain_redirect: 'other.domain.com' } } let(:invalid_params) { { pages_primary_domain: 'other.domain.com' } }
before do before do
create(:pages_domain, project: project, domain: 'my.domain.com') create(:pages_domain, project: project, domain: 'my.domain.com')
...@@ -193,17 +193,17 @@ ...@@ -193,17 +193,17 @@
it 'returns a 400 bad request' do it 'returns a 400 bad request' do
patch api(path, admin, admin_mode: true), params: invalid_params patch api(path, admin, admin_mode: true), params: invalid_params
expected_message = '400 Bad request - The `pages_default_domain_redirect` attribute is missing from ' \ expected_message = '400 Bad request - The `pages_primary_domain` attribute is missing from ' \
'the domain list in the Pages project configuration. Assign ' \ 'the domain list in the Pages project configuration. Assign ' \
'`pages_default_domain_redirect` to the Pages project or reset it.' '`pages_primary_domain` to the Pages project or reset it.'
expect(response).to have_gitlab_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq(expected_message) expect(json_response['message']).to eq(expected_message)
end end
end end
context 'when `pages_default_domain_redirect` is nil' do context 'when `pages_primary_domain` is nil' do
let(:params) { { pages_default_domain_redirect: nil } } let(:params) { { pages_primary_domain: nil } }
before do before do
create(:pages_domain, project: project, domain: 'my.domain.com') create(:pages_domain, project: project, domain: 'my.domain.com')
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
patch api(path, admin, admin_mode: true), params: params patch api(path, admin, admin_mode: true), params: params
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['pages_default_domain_redirect']).to eq(nil) expect(json_response['pages_primary_domain']).to eq(nil)
end end
end end
end end
......
...@@ -176,7 +176,7 @@ project_setting: ...@@ -176,7 +176,7 @@ project_setting:
- allow_pipeline_trigger_approve_deployment - allow_pipeline_trigger_approve_deployment
- pages_unique_domain_enabled - pages_unique_domain_enabled
- pages_unique_domain - pages_unique_domain
- pages_default_domain_redirect - pages_primary_domain
- pages_multiple_versions_enabled - pages_multiple_versions_enabled
- runner_registration_enabled - runner_registration_enabled
- product_analytics_instrumentation_key - product_analytics_instrumentation_key
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment