mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 11:53:55 +08:00
UX: show blank page placeholder instead of the blue panel that says "No Activity" (#16293)
This commit is contained in:
parent
6c46f4af71
commit
d7c1ff3116
|
@ -11,7 +11,6 @@ export default DiscourseRoute.extend({
|
||||||
return draftsStream.findItems(this.site).then(() => {
|
return draftsStream.findItems(this.site).then(() => {
|
||||||
return {
|
return {
|
||||||
stream: draftsStream,
|
stream: draftsStream,
|
||||||
isAnotherUsersPage: !this.isCurrentUser(user),
|
|
||||||
emptyState: this.emptyState(),
|
emptyState: this.emptyState(),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,12 @@ export default UserActivityStreamRoute.extend({
|
||||||
userActionType: null,
|
userActionType: null,
|
||||||
|
|
||||||
emptyState() {
|
emptyState() {
|
||||||
|
const user = this.modelFor("user");
|
||||||
|
|
||||||
const title = I18n.t("user_activity.no_activity_title");
|
const title = I18n.t("user_activity.no_activity_title");
|
||||||
const body = htmlSafe(
|
let body = "";
|
||||||
|
if (this.isCurrentUser(user)) {
|
||||||
|
body = htmlSafe(
|
||||||
I18n.t("user_activity.no_activity_body", {
|
I18n.t("user_activity.no_activity_body", {
|
||||||
topUrl: getURL("/top"),
|
topUrl: getURL("/top"),
|
||||||
categoriesUrl: getURL("/categories"),
|
categoriesUrl: getURL("/categories"),
|
||||||
|
@ -17,6 +21,7 @@ export default UserActivityStreamRoute.extend({
|
||||||
heartIcon: iconHTML("heart"),
|
heartIcon: iconHTML("heart"),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return { title, body };
|
return { title, body };
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,10 +7,15 @@ import { htmlSafe } from "@ember/template";
|
||||||
|
|
||||||
export default UserActivityStreamRoute.extend({
|
export default UserActivityStreamRoute.extend({
|
||||||
userActionType: UserAction.TYPES["likes_given"],
|
userActionType: UserAction.TYPES["likes_given"],
|
||||||
emptyStateOthers: I18n.t("user_activity.no_likes_others"),
|
|
||||||
|
|
||||||
emptyState() {
|
emptyState() {
|
||||||
const title = I18n.t("user_activity.no_likes_title");
|
const user = this.modelFor("user");
|
||||||
|
|
||||||
|
const title = this.isCurrentUser(user)
|
||||||
|
? I18n.t("user_activity.no_likes_title")
|
||||||
|
: I18n.t("user_activity.no_likes_title_others", {
|
||||||
|
username: user.username,
|
||||||
|
});
|
||||||
const body = htmlSafe(
|
const body = htmlSafe(
|
||||||
I18n.t("user_activity.no_likes_body", {
|
I18n.t("user_activity.no_likes_body", {
|
||||||
heartIcon: iconHTML("heart"),
|
heartIcon: iconHTML("heart"),
|
||||||
|
|
|
@ -5,10 +5,15 @@ import { action } from "@ember/object";
|
||||||
|
|
||||||
export default UserActivityStreamRoute.extend({
|
export default UserActivityStreamRoute.extend({
|
||||||
userActionType: UserAction.TYPES["posts"],
|
userActionType: UserAction.TYPES["posts"],
|
||||||
emptyStateOthers: I18n.t("user_activity.no_replies_others"),
|
|
||||||
|
|
||||||
emptyState() {
|
emptyState() {
|
||||||
const title = I18n.t("user_activity.no_replies_title");
|
const user = this.modelFor("user");
|
||||||
|
|
||||||
|
const title = this.isCurrentUser(user)
|
||||||
|
? I18n.t("user_activity.no_replies_title")
|
||||||
|
: I18n.t("user_activity.no_replies_title_others", {
|
||||||
|
username: user.username,
|
||||||
|
});
|
||||||
const body = "";
|
const body = "";
|
||||||
return { title, body };
|
return { title, body };
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,17 +8,13 @@ export default DiscourseRoute.extend(ViewingActionType, {
|
||||||
acting_username: { refreshModel: true },
|
acting_username: { refreshModel: true },
|
||||||
},
|
},
|
||||||
|
|
||||||
emptyStateOthers: I18n.t("user_activity.no_activity_others"),
|
|
||||||
|
|
||||||
model() {
|
model() {
|
||||||
const user = this.modelFor("user");
|
const user = this.modelFor("user");
|
||||||
const stream = user.get("stream");
|
const stream = user.get("stream");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
stream,
|
stream,
|
||||||
isAnotherUsersPage: !this.isCurrentUser(user),
|
|
||||||
emptyState: this.emptyState(),
|
emptyState: this.emptyState(),
|
||||||
emptyStateOthers: this.emptyStateOthers,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
{{#if this.model.stream.noContent}}
|
{{#if this.model.stream.noContent}}
|
||||||
{{#if this.model.isAnotherUsersPage}}
|
|
||||||
<div class="alert alert-info">{{this.model.emptyStateOthers}}</div>
|
|
||||||
{{else}}
|
|
||||||
<EmptyState
|
<EmptyState
|
||||||
@title={{this.model.emptyState.title}}
|
@title={{this.model.emptyState.title}}
|
||||||
@body={{this.model.emptyState.body}}
|
@body={{this.model.emptyState.body}}
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
|
||||||
<UserStream @stream={{this.model.stream}} />
|
<UserStream @stream={{this.model.stream}} />
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { acceptance, exists, query } from "../helpers/qunit-helpers";
|
import { acceptance, query } from "../helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
acceptance("User Activity / All - empty state", function (needs) {
|
acceptance("User Activity / All - empty state", function (needs) {
|
||||||
|
const currentUser = "eviltrout";
|
||||||
|
const anotherUser = "charlie";
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
|
@ -14,17 +16,19 @@ acceptance("User Activity / All - empty state", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("When looking at own activity it renders the empty state panel", async function (assert) {
|
test("When looking at own activity page", async function (assert) {
|
||||||
await visit("/u/eviltrout/activity");
|
await visit(`/u/${currentUser}/activity`);
|
||||||
assert.ok(exists("div.empty-state"));
|
assert.equal(
|
||||||
});
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("user_activity.no_activity_title")
|
||||||
test("When looking at another user activity it renders the 'No activity' message", async function (assert) {
|
|
||||||
await visit("/u/charlie/activity");
|
|
||||||
assert.ok(exists("div.alert-info"));
|
|
||||||
assert.strictEqual(
|
|
||||||
query("div.alert-info").innerText.trim(),
|
|
||||||
I18n.t("user_activity.no_activity_others")
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("When looking at another user's activity page", async function (assert) {
|
||||||
|
await visit(`/u/${anotherUser}/activity`);
|
||||||
|
assert.equal(
|
||||||
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("user_activity.no_activity_title")
|
||||||
|
); // the same title as when looking at own page
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import { acceptance, exists, query } from "../helpers/qunit-helpers";
|
import { acceptance, query } from "../helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
acceptance("User Activity / Likes - empty state", function (needs) {
|
acceptance("User Activity / Likes - empty state", function (needs) {
|
||||||
|
const currentUser = "eviltrout";
|
||||||
|
const anotherUser = "charlie";
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
|
@ -14,17 +16,19 @@ acceptance("User Activity / Likes - empty state", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("When looking at own activity it renders the empty state panel", async function (assert) {
|
test("When looking at own likes page", async function (assert) {
|
||||||
await visit("/u/eviltrout/activity/likes-given");
|
await visit(`/u/${currentUser}/activity/likes-given`);
|
||||||
assert.ok(exists("div.empty-state"));
|
assert.equal(
|
||||||
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("user_activity.no_likes_title")
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("When looking at another user activity it renders the 'No activity' message", async function (assert) {
|
test("When looking at another user's likes page", async function (assert) {
|
||||||
await visit("/u/charlie/activity/likes-given");
|
await visit(`/u/${anotherUser}/activity/likes-given`);
|
||||||
assert.ok(exists("div.alert-info"));
|
assert.equal(
|
||||||
assert.strictEqual(
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
query("div.alert-info").innerText.trim(),
|
I18n.t("user_activity.no_likes_title_others", { username: anotherUser })
|
||||||
I18n.t("user_activity.no_likes_others")
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
import { acceptance, exists, query } from "../helpers/qunit-helpers";
|
import { acceptance, query } from "../helpers/qunit-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { visit } from "@ember/test-helpers";
|
import { visit } from "@ember/test-helpers";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
acceptance("User Activity / Replies - empty state", function (needs) {
|
acceptance("User Activity / Replies - empty state", function (needs) {
|
||||||
|
const currentUser = "eviltrout";
|
||||||
|
const anotherUser = "charlie";
|
||||||
|
|
||||||
needs.user();
|
needs.user();
|
||||||
|
|
||||||
needs.pretender((server, helper) => {
|
needs.pretender((server, helper) => {
|
||||||
|
@ -14,17 +17,19 @@ acceptance("User Activity / Replies - empty state", function (needs) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("When looking at own activity it renders the empty state panel", async function (assert) {
|
test("When looking at own replies page", async function (assert) {
|
||||||
await visit("/u/eviltrout/activity/replies");
|
await visit(`/u/${currentUser}/activity/replies`);
|
||||||
assert.ok(exists("div.empty-state"));
|
assert.equal(
|
||||||
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
|
I18n.t("user_activity.no_replies_title")
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("When looking at another user activity it renders the 'No activity' message", async function (assert) {
|
test("When looking at another user's replies page", async function (assert) {
|
||||||
await visit("/u/charlie/activity/replies");
|
await visit(`/u/${anotherUser}/activity/replies`);
|
||||||
assert.ok(exists("div.alert-info"));
|
assert.equal(
|
||||||
assert.strictEqual(
|
query("div.empty-state span.empty-state-title").innerText,
|
||||||
query("div.alert-info").innerText.trim(),
|
I18n.t("user_activity.no_replies_title_others", { username: anotherUser })
|
||||||
I18n.t("user_activity.no_replies_others")
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4060,14 +4060,13 @@ en:
|
||||||
user_activity:
|
user_activity:
|
||||||
no_activity_title: "No activity yet"
|
no_activity_title: "No activity yet"
|
||||||
no_activity_body: "Welcome to our community! You are brand new here and have not yet contributed to discussions. As a first step, visit <a href='%{topUrl}'>Top</a> or <a href='%{categoriesUrl}'>Categories</a> and just start reading! Select %{heartIcon} on posts that you like or want to learn more about. As you participate, your activity will be listed here."
|
no_activity_body: "Welcome to our community! You are brand new here and have not yet contributed to discussions. As a first step, visit <a href='%{topUrl}'>Top</a> or <a href='%{categoriesUrl}'>Categories</a> and just start reading! Select %{heartIcon} on posts that you like or want to learn more about. As you participate, your activity will be listed here."
|
||||||
no_activity_others: "No activity."
|
|
||||||
no_replies_title: "You have not replied to any topics yet"
|
no_replies_title: "You have not replied to any topics yet"
|
||||||
no_replies_others: "No replies."
|
no_replies_title_others: "%{username} has not replied to any topics yet"
|
||||||
no_drafts_title: "You haven’t started any drafts"
|
no_drafts_title: "You haven’t started any drafts"
|
||||||
no_drafts_body: "Not quite ready to post? We’ll automatically save a new draft and list it here whenever you start composing a topic, reply, or personal message. Select the cancel button to discard or save your draft to continue later."
|
no_drafts_body: "Not quite ready to post? We’ll automatically save a new draft and list it here whenever you start composing a topic, reply, or personal message. Select the cancel button to discard or save your draft to continue later."
|
||||||
no_likes_title: "You haven’t liked any topics yet"
|
no_likes_title: "You haven’t liked any topics yet"
|
||||||
|
no_likes_title_others: "%{username} has not liked any topics yet"
|
||||||
no_likes_body: "A great way to jump in and start contributing is to start reading conversations that have already taken place, and select the %{heartIcon} on posts that you like!"
|
no_likes_body: "A great way to jump in and start contributing is to start reading conversations that have already taken place, and select the %{heartIcon} on posts that you like!"
|
||||||
no_likes_others: "No liked posts."
|
|
||||||
no_topics_title: "You have not started any topics yet"
|
no_topics_title: "You have not started any topics yet"
|
||||||
no_topics_body: "It’s always best to <a href='%{searchUrl}'>search</a> for existing topics of conversation before starting a new one, but if you’re confident the topic you want isn’t out there already, go ahead and start a new topic of your very own. Look for the <kbd>+ New Topic</kbd> button at the top right of the topic list, category, or tag to begin creating a new topic in that area."
|
no_topics_body: "It’s always best to <a href='%{searchUrl}'>search</a> for existing topics of conversation before starting a new one, but if you’re confident the topic you want isn’t out there already, go ahead and start a new topic of your very own. Look for the <kbd>+ New Topic</kbd> button at the top right of the topic list, category, or tag to begin creating a new topic in that area."
|
||||||
no_topics_title_others: "%{username} has not started any topics yet"
|
no_topics_title_others: "%{username} has not started any topics yet"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user