A11Y: more descriptive user page titles (#19819)

This commit is contained in:
Kris 2023-01-19 12:45:45 -05:00 committed by GitHub
parent cc39effe0e
commit f66e798ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 107 additions and 5 deletions

View File

@ -11,6 +11,7 @@ const EMAIL_LEVELS = {
};
export default Controller.extend({
subpageTitle: I18n.t("user.preferences_nav.emails"),
emailMessagesLevelAway: equal(
"model.user_option.email_messages_level",
EMAIL_LEVELS.ONLY_WHEN_AWAY

View File

@ -36,6 +36,7 @@ export default Controller.extend({
preferencesController: controller("preferences"),
makeColorSchemeDefault: true,
canPreviewColorScheme: propertyEqual("model.id", "currentUser.id"),
subpageTitle: I18n.t("user.preferences_nav.interface"),
init() {
this._super(...arguments);

View File

@ -5,6 +5,8 @@ import { NotificationLevels } from "discourse/lib/notification-levels";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({
subpageTitle: I18n.t("user.preferences_nav.notifications"),
init() {
this._super(...arguments);

View File

@ -12,6 +12,7 @@ import { inject as service } from "@ember/service";
export default Controller.extend({
dialog: service(),
subpageTitle: I18n.t("user.preferences_nav.profile"),
init() {
this._super(...arguments);
this.saveAttrNames = [

View File

@ -15,7 +15,7 @@ const DEFAULT_AUTH_TOKENS_COUNT = 2;
export default Controller.extend(CanCheckEmails, {
passwordProgress: null,
subpageTitle: I18n.t("user.preferences_nav.security"),
showAllAuthTokens: false,
@discourseComputed("model.is_anonymous")

View File

@ -12,6 +12,7 @@ export default class extends Controller {
@tracked saved = false;
@tracked selectedSidebarCategories = [];
@tracked selectedSidebarTagNames = [];
subpageTitle = I18n.t("user.preferences_nav.sidebar");
saveAttrNames = [
"sidebar_category_ids",

View File

@ -2,6 +2,7 @@ import RestrictedUserRoute from "discourse/routes/restricted-user";
import UserBadge from "discourse/models/user-badge";
import showModal from "discourse/lib/show-modal";
import { action } from "@ember/object";
import I18n from "I18n";
export default RestrictedUserRoute.extend({
showFooter: true,
@ -32,6 +33,7 @@ export default RestrictedUserRoute.extend({
newPrimaryGroupInput: user.get("primary_group_id"),
newFlairGroupId: user.get("flair_group_id"),
newStatus: user.status,
subpageTitle: I18n.t("user.preferences_nav.account"),
});
},

View File

@ -1,7 +1,19 @@
import RestrictedUserRoute from "discourse/routes/restricted-user";
import I18n from "I18n";
import { inject as service } from "@ember/service";
export default RestrictedUserRoute.extend({
router: service(),
model() {
return this.modelFor("user");
},
titleToken() {
let controller = this.controllerFor(this.router.currentRouteName);
let subpageTitle = controller?.subpageTitle;
return subpageTitle
? `${subpageTitle} - ${I18n.t("user.preferences")}`
: I18n.t("user.preferences");
},
});

View File

@ -2,6 +2,7 @@ import { action } from "@ember/object";
import { ajax } from "discourse/lib/ajax";
import DiscourseRoute from "discourse/routes/discourse";
import { Promise } from "rsvp";
import I18n from "I18n";
export default DiscourseRoute.extend({
queryParams: {
@ -50,6 +51,10 @@ export default DiscourseRoute.extend({
this.render("user_bookmarks");
},
titleToken() {
return I18n.t("user_action_groups.3");
},
@action
didTransition() {
this.controllerFor("user-activity")._showFooter();

View File

@ -38,6 +38,10 @@ export default DiscourseRoute.extend({
this.appEvents.off("draft:destroyed", this, this.refresh);
},
titleToken() {
return I18n.t("user_action_groups.15");
},
@action
didTransition() {
this.controllerFor("user-activity")._showFooter();

View File

@ -25,4 +25,8 @@ export default UserActivityStreamRoute.extend({
return { title, body };
},
titleToken() {
return I18n.t("user.filters.all");
},
});

View File

@ -25,6 +25,10 @@ export default UserActivityStreamRoute.extend({
return { title, body };
},
titleToken() {
return I18n.t("user_action_groups.1");
},
@action
didTransition() {
this.controllerFor("application").set("showFooter", true);

View File

@ -42,6 +42,10 @@ export default UserTopicListRoute.extend({
return { title, body };
},
titleToken() {
return `${I18n.t("user.read")}`;
},
@action
triggerRefresh() {
this.refresh();

View File

@ -29,6 +29,10 @@ export default UserActivityStreamRoute.extend({
return { title, body };
},
titleToken() {
return I18n.t("user_action_groups.5");
},
@action
didTransition() {
this.controllerFor("application").set("showFooter", true);

View File

@ -50,6 +50,10 @@ export default UserTopicListRoute.extend({
return { title, body };
},
titleToken() {
return I18n.t("user_action_groups.4");
},
@action
triggerRefresh() {
this.refresh();

View File

@ -1,4 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
export default DiscourseRoute.extend({
model() {
@ -19,4 +20,8 @@ export default DiscourseRoute.extend({
setupController(controller, user) {
this.controllerFor("user-activity").set("model", user);
},
titleToken() {
return I18n.t("user.activity_stream");
},
});

View File

@ -2,6 +2,7 @@ import DiscourseRoute from "discourse/routes/discourse";
import UserBadge from "discourse/models/user-badge";
import ViewingActionType from "discourse/mixins/viewing-action-type";
import { action } from "@ember/object";
import I18n from "I18n";
export default DiscourseRoute.extend(ViewingActionType, {
model() {
@ -20,6 +21,10 @@ export default DiscourseRoute.extend(ViewingActionType, {
this.render("user/badges");
},
titleToken() {
return I18n.t("badges.title");
},
@action
didTransition() {
this.controllerFor("application").set("showFooter", true);

View File

@ -1,6 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import Invite from "discourse/models/invite";
import { action } from "@ember/object";
import I18n from "I18n";
export default DiscourseRoute.extend({
model(params) {
@ -27,6 +28,10 @@ export default DiscourseRoute.extend({
});
},
titleToken() {
return I18n.t("user.invited." + this.inviteFilter + "_tab");
},
@action
triggerRefresh() {
this.refresh();

View File

@ -1,4 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
export default DiscourseRoute.extend({
setupController(controller) {
@ -10,4 +11,8 @@ export default DiscourseRoute.extend({
can_see_invite_details,
});
},
titleToken() {
return I18n.t("user.invited.title");
},
});

View File

@ -1,6 +1,11 @@
import UserAction from "discourse/models/user-action";
import UserActivityStreamRoute from "discourse/routes/user-activity-stream";
import I18n from "I18n";
export default UserActivityStreamRoute.extend({
userActionType: UserAction.TYPES["edits"],
titleToken() {
return I18n.t("user_action_groups.11");
},
});

View File

@ -1,4 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
export default DiscourseRoute.extend({
controllerName: "user-notifications",
@ -6,6 +7,10 @@ export default DiscourseRoute.extend({
this.render("user/notifications-index");
},
titleToken() {
return I18n.t("user.filters.all");
},
afterModel(model) {
if (!model) {
this.transitionTo("userNotifications.responses");

View File

@ -1,6 +1,11 @@
import UserAction from "discourse/models/user-action";
import UserActivityStreamRoute from "discourse/routes/user-activity-stream";
import I18n from "I18n";
export default UserActivityStreamRoute.extend({
userActionType: UserAction.TYPES["likes_received"],
titleToken() {
return I18n.t("user_action_groups.1");
},
});

View File

@ -1,6 +1,11 @@
import UserAction from "discourse/models/user-action";
import UserActivityStreamRoute from "discourse/routes/user-activity-stream";
import I18n from "I18n";
export default UserActivityStreamRoute.extend({
userActionType: UserAction.TYPES["mentions"],
titleToken() {
return I18n.t("user_action_groups.7");
},
});

View File

@ -1,6 +1,11 @@
import UserAction from "discourse/models/user-action";
import UserActivityStreamRoute from "discourse/routes/user-activity-stream";
import I18n from "I18n";
export default UserActivityStreamRoute.extend({
userActionType: UserAction.TYPES["replies"],
titleToken() {
return I18n.t("user_action_groups.6");
},
});

View File

@ -1,6 +1,7 @@
import DiscourseRoute from "discourse/routes/discourse";
import ViewingActionType from "discourse/mixins/viewing-action-type";
import { action } from "@ember/object";
import I18n from "I18n";
export default DiscourseRoute.extend(ViewingActionType, {
controllerName: "user-notifications",
@ -31,4 +32,8 @@ export default DiscourseRoute.extend(ViewingActionType, {
controller.set("user", this.modelFor("user"));
this.viewingActionType(-1);
},
titleToken() {
return I18n.t("user.notifications");
},
});

View File

@ -1,4 +1,5 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
export default DiscourseRoute.extend({
showFooter: true,
@ -11,4 +12,8 @@ export default DiscourseRoute.extend({
return user.summary();
},
titleToken() {
return I18n.t("user.summary.title");
},
});

View File

@ -1,5 +1,4 @@
import DiscourseRoute from "discourse/routes/discourse";
import I18n from "I18n";
import User from "discourse/models/user";
import { action } from "@ember/object";
import { bind } from "discourse-common/utils/decorators";
@ -98,9 +97,7 @@ export default DiscourseRoute.extend({
titleToken() {
const username = this.modelFor("user").username;
if (username) {
return [I18n.t("user.profile"), username];
}
return username ? username : null;
},
@action

View File

@ -22,6 +22,7 @@ const EMAIL_FREQUENCY_OPTIONS = [
export default class PreferencesChatController extends Controller {
@service chatAudioManager;
subpageTitle = I18n.t("chat.admin.title");
emailFrequencyOptions = EMAIL_FREQUENCY_OPTIONS;