Skip to content

A platform for community discussion. Free, open, simple.

FIX: Customize form template view modal footer buttons (#25804)

Keegan George3b87a174e790
diff --git a/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.js b/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.js
index 259d039a7d7..55a2f7e3046 100644
--- a/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.js
+++ b/app/assets/javascripts/discourse/app/components/modal/customize-form-template-view.js
@@ -18,17 +18,20 @@ export default class CustomizeFormTemplateViewModal extends Component {
@action
editTemplate() {
- this.router.transitionTo("adminCustomizeFormTemplates.edit", this.model);
+ this.router.transitionTo(
+ "adminCustomizeFormTemplates.edit",
+ this.args.model
+ );
}
@action
deleteTemplate() {
return this.dialog.yesNoConfirm({
message: I18n.t("admin.form_templates.delete_confirm", {
- template_name: this.model.name,
+ template_name: this.args.model.name,
}),
didConfirm: () => {
- ajax(`/admin/customize/form-templates/${this.model.id}.json`, {
+ ajax(`/admin/customize/form-templates/${this.args.model.id}.json`, {
type: "DELETE",
})
.then(() => {
diff --git a/spec/system/admin_customize_form_templates_spec.rb b/spec/system/admin_customize_form_templates_spec.rb
index 69fde858142..49176a0d7bb 100644
--- a/spec/system/admin_customize_form_templates_spec.rb
+++ b/spec/system/admin_customize_form_templates_spec.rb
@@ -44,6 +44,25 @@ describe "Admin Customize Form Templates", type: :system do
form_template_page.click_toggle_preview
expect(form_template_page).to have_input_field("input")
end
+
+ context "when using the view template modal" do
+ it "should navigate to the edit page when clicking the edit button" do
+ form_template_page.visit
+ form_template_page.click_view_form_template
+ form_template_page.find(".d-modal__footer .btn-primary").click
+ expect(page).to have_current_path("/admin/customize/form-templates/#{form_template.id}")
+ end
+
+ it "should delete the form template when clicking the delete button" do
+ form_template_page.visit
+ original_template_name = form_template.name
+ form_template_page.click_view_form_template
+ form_template_page.find(".d-modal__footer .btn-danger").click
+ form_template_page.find(".dialog-footer .btn-primary").click
+
+ expect(form_template_page).to have_no_form_template(original_template_name)
+ end
+ end
end
describe "when visiting the page to edit a form template" do
diff --git a/spec/system/page_objects/pages/form_template.rb b/spec/system/page_objects/pages/form_template.rb
index 119eca11a5b..681f94714a9 100644
--- a/spec/system/page_objects/pages/form_template.rb
+++ b/spec/system/page_objects/pages/form_template.rb
@@ -31,6 +31,10 @@ module PageObjects
find(".form-templates__table tbody tr td", text: name).present?
end
+ def has_no_form_template?(name)
+ has_no_css?(".form-templates__table tbody tr td", text: name)
+ end
+
def has_category_in_template_row?(category_name)
find(
".form-templates__table .categories .badge-category__name",