FEATURE: Improve blank page syndrome (#110)
This commit is contained in:
parent
6edd9393b2
commit
2aa309b070
|
@ -0,0 +1 @@
|
||||||
|
2.9.0.beta3: 2de1fe5df1a5c25ad1e0e31e8d28adca315d9092
|
|
@ -1,12 +1,31 @@
|
||||||
import UserTopicListRoute from "discourse/routes/user-topic-list";
|
import UserTopicListRoute from "discourse/routes/user-topic-list";
|
||||||
import UserAction from "discourse/models/user-action";
|
import UserAction from "discourse/models/user-action";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default UserTopicListRoute.extend({
|
export default UserTopicListRoute.extend({
|
||||||
userActionType: UserAction.TYPES.topics,
|
userActionType: UserAction.TYPES.topics,
|
||||||
|
|
||||||
model: function () {
|
model() {
|
||||||
return this.store.findFiltered("topicList", {
|
return this.store
|
||||||
filter: "topics/voted-by/" + this.modelFor("user").get("username_lower"),
|
.findFiltered("topicList", {
|
||||||
});
|
filter:
|
||||||
|
"topics/voted-by/" + this.modelFor("user").get("username_lower"),
|
||||||
|
})
|
||||||
|
.then((model) => {
|
||||||
|
model.set("emptyState", this.emptyState());
|
||||||
|
return model;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
emptyState() {
|
||||||
|
const user = this.modelFor("user");
|
||||||
|
const title = this.isCurrentUser(user)
|
||||||
|
? I18n.t("voting.no_votes_title_self")
|
||||||
|
: I18n.t("voting.no_votes_title_others", { username: user.username });
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: title,
|
||||||
|
body: "",
|
||||||
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -28,6 +28,8 @@ en:
|
||||||
one: "Vote"
|
one: "Vote"
|
||||||
other: "Votes"
|
other: "Votes"
|
||||||
remove_vote: "Remove vote"
|
remove_vote: "Remove vote"
|
||||||
|
no_votes_title_self: "You haven't voted for any topic yet"
|
||||||
|
no_votes_title_others: "%{username} hasn't voted for any topic yet"
|
||||||
filters:
|
filters:
|
||||||
votes:
|
votes:
|
||||||
title: "Votes"
|
title: "Votes"
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { acceptance, query } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { test } from "qunit";
|
||||||
|
import { visit } from "@ember/test-helpers";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
acceptance(
|
||||||
|
"Discourse Voting Plugin | /activity/votes | empty state",
|
||||||
|
function (needs) {
|
||||||
|
const currentUser = "eviltrout";
|
||||||
|
const anotherUser = "charlie";
|
||||||
|
|
||||||
|
needs.user();
|
||||||
|
|
||||||
|
needs.pretender((server, helper) => {
|
||||||
|
const emptyResponse = { topic_list: { topics: [] } };
|
||||||
|
|
||||||
|
server.get(`/topics/voted-by/${currentUser}.json`, () => {
|
||||||
|
return helper.response(emptyResponse);
|
||||||
|
});
|
||||||
|
|
||||||
|
server.get(`/topics/voted-by/${anotherUser}.json`, () => {
|
||||||
|
return helper.response(emptyResponse);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("When looking at the own activity page", async function (assert) {
|
||||||
|
await visit(`/u/${currentUser}/activity/votes`);
|
||||||
|
assert.equal(
|
||||||
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("voting.no_votes_title_self")
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("When looking at another user's activity page", async function (assert) {
|
||||||
|
await visit(`/u/${anotherUser}/activity/votes`);
|
||||||
|
assert.equal(
|
||||||
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("voting.no_votes_title_others", { username: anotherUser })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
Loading…
Reference in New Issue