Skip to content

Commit 082821c

Browse files
authored
DEV: Remove legacy user menu (discourse#21308)
1 parent 0c1efec commit 082821c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+148
-2422
lines changed

app/assets/javascripts/discourse/app/components/d-document.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,9 @@ export default Component.extend({
5050
}
5151

5252
let count = pluginCounterFunctions.reduce((sum, fn) => sum + fn(), 0);
53-
if (this.currentUser.redesigned_user_menu_enabled) {
54-
count += this.currentUser.all_unread_notifications_count;
55-
if (this.currentUser.unseen_reviewable_count) {
56-
count += this.currentUser.unseen_reviewable_count;
57-
}
58-
} else {
59-
count +=
60-
this.currentUser.unread_notifications +
61-
this.currentUser.unread_high_priority_notifications;
53+
count += this.currentUser.all_unread_notifications_count;
54+
if (this.currentUser.unseen_reviewable_count) {
55+
count += this.currentUser.unseen_reviewable_count;
6256
}
6357
this.documentTitle.updateNotificationCount(count, { forced: opts?.forced });
6458
},

app/assets/javascripts/discourse/app/components/site-header.js

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const SiteHeaderComponent = MountWidget.extend(
3535
"currentUser.unread_notifications",
3636
"currentUser.unread_high_priority_notifications",
3737
"currentUser.all_unread_notifications_count",
38-
"currentUser.reviewable_count", // TODO: remove this when redesigned_user_menu_enabled is removed
38+
"currentUser.reviewable_count",
3939
"currentUser.unseen_reviewable_count",
4040
"session.defaultColorSchemeIsDark",
4141
"session.darkModeAvailable"
@@ -250,9 +250,7 @@ const SiteHeaderComponent = MountWidget.extend(
250250
this.appEvents.on("header:show-topic", this, "setTopic");
251251
this.appEvents.on("header:hide-topic", this, "setTopic");
252252

253-
if (this.currentUser?.redesigned_user_menu_enabled) {
254-
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
255-
}
253+
this.appEvents.on("user-menu:rendered", this, "_animateMenu");
256254

257255
if (this._dropDownHeaderEnabled()) {
258256
this.appEvents.on(
@@ -274,53 +272,35 @@ const SiteHeaderComponent = MountWidget.extend(
274272

275273
const header = document.querySelector("header.d-header");
276274
this._itsatrap = new ItsATrap(header);
277-
const dirs = this.currentUser?.redesigned_user_menu_enabled
278-
? ["up", "down"]
279-
: ["right", "left"];
275+
const dirs = ["up", "down"];
280276
this._itsatrap.bind(dirs, (e) => this._handleArrowKeysNav(e));
281277
},
282278

283279
_handleArrowKeysNav(event) {
284-
if (this.currentUser?.redesigned_user_menu_enabled) {
285-
const activeTab = document.querySelector(
286-
".menu-tabs-container .btn.active"
280+
const activeTab = document.querySelector(
281+
".menu-tabs-container .btn.active"
282+
);
283+
if (activeTab) {
284+
let activeTabNumber = Number(
285+
document.activeElement.dataset.tabNumber ||
286+
activeTab.dataset.tabNumber
287287
);
288-
if (activeTab) {
289-
let activeTabNumber = Number(
290-
document.activeElement.dataset.tabNumber ||
291-
activeTab.dataset.tabNumber
292-
);
293-
const maxTabNumber =
294-
document.querySelectorAll(".menu-tabs-container .btn").length - 1;
295-
const isNext = event.key === "ArrowDown";
296-
let nextTab = isNext ? activeTabNumber + 1 : activeTabNumber - 1;
297-
if (isNext && nextTab > maxTabNumber) {
298-
nextTab = 0;
299-
}
300-
if (!isNext && nextTab < 0) {
301-
nextTab = maxTabNumber;
302-
}
303-
event.preventDefault();
304-
document
305-
.querySelector(
306-
`.menu-tabs-container .btn[data-tab-number='${nextTab}']`
307-
)
308-
.focus();
288+
const maxTabNumber =
289+
document.querySelectorAll(".menu-tabs-container .btn").length - 1;
290+
const isNext = event.key === "ArrowDown";
291+
let nextTab = isNext ? activeTabNumber + 1 : activeTabNumber - 1;
292+
if (isNext && nextTab > maxTabNumber) {
293+
nextTab = 0;
309294
}
310-
} else {
311-
const activeTab = document.querySelector(".glyphs .menu-link.active");
312-
313-
if (activeTab) {
314-
let focusedTab = document.activeElement;
315-
if (!focusedTab.dataset.tabNumber) {
316-
focusedTab = activeTab;
317-
}
318-
319-
this.appEvents.trigger("user-menu:navigation", {
320-
key: event.key,
321-
tabNumber: Number(focusedTab.dataset.tabNumber),
322-
});
295+
if (!isNext && nextTab < 0) {
296+
nextTab = maxTabNumber;
323297
}
298+
event.preventDefault();
299+
document
300+
.querySelector(
301+
`.menu-tabs-container .btn[data-tab-number='${nextTab}']`
302+
)
303+
.focus();
324304
}
325305
},
326306

@@ -339,9 +319,7 @@ const SiteHeaderComponent = MountWidget.extend(
339319
this.appEvents.off("header:show-topic", this, "setTopic");
340320
this.appEvents.off("header:hide-topic", this, "setTopic");
341321
this.appEvents.off("dom:clean", this, "_cleanDom");
342-
if (this.currentUser?.redesigned_user_menu_enabled) {
343-
this.appEvents.off("user-menu:rendered", this, "_animateMenu");
344-
}
322+
this.appEvents.off("user-menu:rendered", this, "_animateMenu");
345323

346324
if (this._dropDownHeaderEnabled()) {
347325
this.appEvents.off(

app/assets/javascripts/discourse/app/initializers/badging.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ export default {
1616
const appEvents = container.lookup("service:app-events");
1717
appEvents.on("notifications:changed", () => {
1818
let notifications;
19-
if (user.redesigned_user_menu_enabled) {
20-
notifications = user.all_unread_notifications_count;
21-
if (user.unseen_reviewable_count) {
22-
notifications += user.unseen_reviewable_count;
23-
}
24-
} else {
25-
notifications =
26-
user.unread_notifications + user.unread_high_priority_notifications;
19+
notifications = user.all_unread_notifications_count;
20+
if (user.unseen_reviewable_count) {
21+
notifications += user.unseen_reviewable_count;
2722
}
2823

2924
navigator.setAppBadge(notifications);

app/assets/javascripts/discourse/app/initializers/subscribe-user-notifications.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ export default {
3333
this.site = container.lookup("service:site");
3434
this.router = container.lookup("router:main");
3535

36-
this.reviewableCountsChannel = this.currentUser.redesigned_user_menu_enabled
37-
? `/reviewable_counts/${this.currentUser.id}`
38-
: "/reviewable_counts";
36+
this.reviewableCountsChannel = `/reviewable_counts/${this.currentUser.id}`;
3937

4038
this.messageBus.subscribe(
4139
this.reviewableCountsChannel,
@@ -126,12 +124,10 @@ export default {
126124
this.currentUser.updateReviewableCount(data.reviewable_count);
127125
}
128126

129-
if (this.currentUser.redesigned_user_menu_enabled) {
130-
this.currentUser.set(
131-
"unseen_reviewable_count",
132-
data.unseen_reviewable_count
133-
);
134-
}
127+
this.currentUser.set(
128+
"unseen_reviewable_count",
129+
data.unseen_reviewable_count
130+
);
135131
},
136132

137133
@bind

app/assets/javascripts/discourse/app/lib/plugin-api.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ import {
6565
addPostSmallActionClassesCallback,
6666
addPostSmallActionIcon,
6767
} from "discourse/widgets/post-small-action";
68-
import { addQuickAccessProfileItem } from "discourse/widgets/quick-access-profile";
6968
import { addTagsHtmlCallback } from "discourse/lib/render-tags";
7069
import { addToolbarCallback } from "discourse/components/d-editor";
7170
import { addTopicParticipantClassesCallback } from "discourse/widgets/topic-map";
7271
import { addTopicSummaryCallback } from "discourse/widgets/toggle-topic-summary";
7372
import { addTopicTitleDecorator } from "discourse/components/topic-title";
74-
import { addUserMenuGlyph } from "discourse/widgets/user-menu";
7573
import { addUserMenuProfileTabItem } from "discourse/components/user-menu/profile-tab-content";
7674
import { addUsernameSelectorDecorator } from "discourse/helpers/decorate-username-selector";
7775
import { addWidgetCleanCallback } from "discourse/components/mount-widget";
@@ -120,7 +118,7 @@ import { registerHashtagType } from "discourse/lib/hashtag-autocomplete";
120118
// based on Semantic Versioning 2.0.0. Please update the changelog at
121119
// docs/CHANGELOG-JAVASCRIPT-PLUGIN-API.md whenever you change the version
122120
// using the format described at https://keepachangelog.com/en/1.0.0/.
123-
const PLUGIN_API_VERSION = "1.6.0";
121+
const PLUGIN_API_VERSION = "1.6.1";
124122

125123
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
126124
function canModify(klass, type, resolverName, changes) {
@@ -1001,8 +999,11 @@ class PluginApi {
1001999
*
10021000
* To customize the new user menu, see api.registerUserMenuTab
10031001
*/
1004-
addUserMenuGlyph(glyph) {
1005-
addUserMenuGlyph(glyph);
1002+
addUserMenuGlyph() {
1003+
deprecated(
1004+
"addUserMenuGlyph has been removed. Use api.registerUserMenuTab instead.",
1005+
{ id: "discourse.add-user-menu-glyph" }
1006+
);
10061007
}
10071008

10081009
/**
@@ -1590,7 +1591,6 @@ class PluginApi {
15901591
*
15911592
**/
15921593
addQuickAccessProfileItem(item) {
1593-
addQuickAccessProfileItem(item);
15941594
addUserMenuProfileTabItem(item);
15951595
}
15961596

app/assets/javascripts/discourse/app/routes/review-index.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ export default DiscourseRoute.extend({
9595
},
9696

9797
get _reviewableCountsChannel() {
98-
return this.currentUser.redesigned_user_menu_enabled
99-
? `/reviewable_counts/${this.currentUser.id}`
100-
: "/reviewable_counts";
98+
return `/reviewable_counts/${this.currentUser.id}`;
10199
},
102100

103101
@action

app/assets/javascripts/discourse/app/widgets/hamburger-menu.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,7 @@ export default createWidget("hamburger-menu", {
354354
});
355355
},
356356

357-
html(attrs, state) {
358-
if (
359-
this.currentUser &&
360-
!this.currentUser.redesigned_user_menu_enabled &&
361-
!state.loaded
362-
) {
363-
this.refreshReviewableCount(state);
364-
}
365-
357+
html() {
366358
return this.attach("menu-panel", {
367359
contents: () => this.panelContents(),
368360
maxWidth: this.settings.maxWidth,

0 commit comments

Comments
 (0)