From ee04677d4b002813b6dc88b0248f3da26cf4fe59 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Wed, 7 Dec 2022 17:47:29 +0530 Subject: [PATCH] settings: Remove ID from discard button in save-discard widget. This commit removes ID from discard button in save-discard widget. Generating IDs using variables results in difficulty to grep the code and we can anyway access the discard button by using ID of the settings-subsection-parent div. Also, we do not use ID to access this button, so we can change this safely. --- frontend_tests/node_tests/settings_org.js | 6 +++--- static/templates/settings/settings_save_discard_widget.hbs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend_tests/node_tests/settings_org.js b/frontend_tests/node_tests/settings_org.js index de0f3cc759..fde530ace2 100644 --- a/frontend_tests/node_tests/settings_org.js +++ b/frontend_tests/node_tests/settings_org.js @@ -58,7 +58,7 @@ function createSaveButtons(subsection) { const $stub_save_button_header = $(`#org-${CSS.escape(subsection)}`); const $save_button_controls = $(".save-button-controls"); const $stub_save_button = $(".save-discard-widget-button.save-button"); - const $stub_discard_button = $(`#org-discard-${CSS.escape(subsection)}`); + const $stub_discard_button = $(".save-discard-widget-button.discard-button"); const $stub_save_button_text = $(".save-discard-widget-button-text"); $stub_save_button_header.set_find_results( ".subsection-failed-status p", @@ -70,7 +70,7 @@ function createSaveButtons(subsection) { $stub_save_button_header.set_find_results(".save-button-controls", $save_button_controls); $stub_save_button_header.set_find_results( ".subsection-changes-discard button", - $(`#org-discard-${CSS.escape(subsection)}`), + $stub_discard_button, ); $save_button_controls.set_find_results(".discard-button", $stub_discard_button); const props = {}; @@ -439,7 +439,7 @@ function test_discard_changes_button(discard_changes) { const ev = { preventDefault: noop, stopPropagation: noop, - target: "#org-discard-msg-editing", + target: ".save-discard-widget-button.discard-button", }; page_params.realm_allow_edit_history = true; diff --git a/static/templates/settings/settings_save_discard_widget.hbs b/static/templates/settings/settings_save_discard_widget.hbs index 3b1243d551..81bb5a785e 100644 --- a/static/templates/settings/settings_save_discard_widget.hbs +++ b/static/templates/settings/settings_save_discard_widget.hbs @@ -10,7 +10,7 @@
-