mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: ensures period-chooser is not losing query params (#10534)
eg repro before: - visit http://pr-discourse.test/top/weekly?f=foo - select another period in the period chooser - f=foo was gone After this commit it should still be present
This commit is contained in:
parent
ff4de97dfd
commit
f5eccdd0b8
|
@ -3,11 +3,13 @@ import Controller, { inject as controller } from "@ember/controller";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
import { observes } from "discourse-common/utils/decorators";
|
import { observes } from "discourse-common/utils/decorators";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
discoveryTopics: controller("discovery/topics"),
|
discoveryTopics: controller("discovery/topics"),
|
||||||
navigationCategory: controller("navigation/category"),
|
navigationCategory: controller("navigation/category"),
|
||||||
application: controller(),
|
application: controller(),
|
||||||
|
router: service(),
|
||||||
|
|
||||||
loading: false,
|
loading: false,
|
||||||
|
|
||||||
|
@ -32,6 +34,16 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
url += "/top/" + period;
|
url += "/top/" + period;
|
||||||
|
|
||||||
|
const queryParams = this.router.currentRoute.queryParams;
|
||||||
|
if (Object.keys(queryParams).length) {
|
||||||
|
url =
|
||||||
|
`${url}?` +
|
||||||
|
Object.keys(queryParams)
|
||||||
|
.map(key => `${key}=${queryParams[key]}`)
|
||||||
|
.join("&");
|
||||||
|
}
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
import selectKit from "helpers/select-kit-helper";
|
||||||
import { acceptance } from "helpers/qunit-helpers";
|
import { acceptance } from "helpers/qunit-helpers";
|
||||||
import MessageBus from "message-bus-client";
|
import MessageBus from "message-bus-client";
|
||||||
|
|
||||||
|
@ -107,3 +109,22 @@ QUnit.test("Live update unread state", async assert => {
|
||||||
"shows the topic read"
|
"shows the topic read"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test(
|
||||||
|
"Using period chooser when query params are present",
|
||||||
|
async assert => {
|
||||||
|
await visit("/top?f=foo&d=bar");
|
||||||
|
|
||||||
|
sandbox.stub(DiscourseURL, "routeTo");
|
||||||
|
|
||||||
|
const periodChooser = selectKit(".period-chooser");
|
||||||
|
|
||||||
|
await periodChooser.expand();
|
||||||
|
await periodChooser.selectRowByValue("yearly");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
DiscourseURL.routeTo.calledWith("/top/yearly?f=foo&d=bar"),
|
||||||
|
"it keeps the query params"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user