From ca7131648f0096e269dad9842eb2374b2dff2858 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Tue, 14 Feb 2023 10:24:45 +1100 Subject: [PATCH] FIX: edit custom section title (#20258) When custom section is edited, it should say "Edit custom section" instead of "Add custom section" --- .../discourse/app/controllers/sidebar-section-form.js | 6 ++++++ .../discourse/app/templates/modal/sidebar-section-form.hbs | 2 +- spec/system/custom_sidebar_sections_spec.rb | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/controllers/sidebar-section-form.js b/app/assets/javascripts/discourse/app/controllers/sidebar-section-form.js index 318b50c4c9f..33623e16e7a 100644 --- a/app/assets/javascripts/discourse/app/controllers/sidebar-section-form.js +++ b/app/assets/javascripts/discourse/app/controllers/sidebar-section-form.js @@ -203,6 +203,12 @@ export default Controller.extend(ModalFunctionality, { return this.model.links.filter((link) => !link._destroy); }, + get header() { + return this.model.id + ? "sidebar.sections.custom.edit" + : "sidebar.sections.custom.add"; + }, + actions: { addLink() { this.model.links.pushObject(new SectionLink({ router: this.router })); diff --git a/app/assets/javascripts/discourse/app/templates/modal/sidebar-section-form.hbs b/app/assets/javascripts/discourse/app/templates/modal/sidebar-section-form.hbs index 66c864a0ca3..3e21bd08d3e 100644 --- a/app/assets/javascripts/discourse/app/templates/modal/sidebar-section-form.hbs +++ b/app/assets/javascripts/discourse/app/templates/modal/sidebar-section-form.hbs @@ -3,7 +3,7 @@ {{this.flashText}} {{/if}} - +
diff --git a/spec/system/custom_sidebar_sections_spec.rb b/spec/system/custom_sidebar_sections_spec.rb index 7f6cc830d24..390a1f2ae0a 100644 --- a/spec/system/custom_sidebar_sections_spec.rb +++ b/spec/system/custom_sidebar_sections_spec.rb @@ -19,6 +19,7 @@ describe "Custom sidebar sections", type: :system, js: true do expect(section_modal).to be_visible expect(section_modal).to have_disabled_save + expect(find("#discourse-modal-title")).to have_content("Add custom section") section_modal.fill_name("My section") @@ -41,6 +42,8 @@ describe "Custom sidebar sections", type: :system, js: true do visit("/latest") sidebar.edit_custom_section("My section") + expect(find("#discourse-modal-title")).to have_content("Edit custom section") + section_modal.fill_name("Edited section") section_modal.fill_link("Edited Tags", "/tags") section_modal.remove_last_link