FIX: Reset admin theme controller on modal cancel event (#20289)

When installing themes using the "Install this theme component" button
on meta.discourse.org, we pass the repo name and URL via query params.

However, these stick. So if a user cancels the installation, on the
next navigation to the same route, they'll see the modal again.

This PR clears the query params  of the controller when dismissing the
modal.
This commit is contained in:
Penar Musaraj 2023-02-14 14:23:07 -05:00 committed by GitHub
parent b94fa3b87a
commit afdb4a084a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -135,6 +135,11 @@ export default Controller.extend(ModalFunctionality, {
branch: null,
selection: "popular",
});
this.themesController.setProperties({
repoName: null,
repoUrl: null,
});
},
themeHasSameUrl(theme, url) {

View File

@ -1,5 +1,5 @@
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
import { click, fillIn, visit } from "@ember/test-helpers";
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
import { test } from "qunit";
import I18n from "I18n";
@ -82,6 +82,13 @@ acceptance("Admin - Themes - Install modal", function (needs) {
"testUrl",
"repo url is visible"
);
await click(".d-modal-cancel");
assert.strictEqual(
currentURL(),
"/admin/customize/themes",
"query params are cleared after dismissing the modal"
);
});
test("installed themes are matched with the popular list by URL", async function (assert) {