mirror of
https://github.com/discourse/discourse.git
synced 2024-12-19 07:53:47 +08:00
DEV: Switch the glimmer post menu to auto and unsilence deprecations (#30161)
This commit starts the rollout of the Glimmer post menu: - default to `auto`: after the upgrade, it will be enabled on all discourse instances that do not have incompatible customizations - unsilence the deprecation messages in the console - removes the setting `glimmer_post_menu_groups` as it's no longer in the test phase
This commit is contained in:
parent
6fa52a6499
commit
c3e7d97048
|
@ -6,10 +6,6 @@ const DEPRECATION_WORKFLOW = [
|
||||||
handler: "silence",
|
handler: "silence",
|
||||||
matchId: "discourse.decorate-widget.hamburger-widget-links",
|
matchId: "discourse.decorate-widget.hamburger-widget-links",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
handler: "silence",
|
|
||||||
matchId: "discourse.post-menu-widget-overrides",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
handler: "silence",
|
handler: "silence",
|
||||||
matchId: "discourse.hbr-topic-list-overrides",
|
matchId: "discourse.hbr-topic-list-overrides",
|
||||||
|
|
|
@ -171,6 +171,12 @@ const DEPRECATED_POST_MENU_WIDGETS = [
|
||||||
"small-user-list",
|
"small-user-list",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const POST_MENU_DEPRECATION_OPTIONS = {
|
||||||
|
since: "v3.4.0.beta3-dev",
|
||||||
|
id: "discourse.post-menu-widget-overrides",
|
||||||
|
url: "https://meta.discourse.org/t/341014",
|
||||||
|
};
|
||||||
|
|
||||||
const appliedModificationIds = new WeakMap();
|
const appliedModificationIds = new WeakMap();
|
||||||
|
|
||||||
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
|
// This helper prevents us from applying the same `modifyClass` over and over in test mode.
|
||||||
|
@ -880,10 +886,7 @@ class PluginApi {
|
||||||
addPostMenuButton(name, callback) {
|
addPostMenuButton(name, callback) {
|
||||||
deprecated(
|
deprecated(
|
||||||
"`api.addPostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
"`api.addPostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
||||||
{
|
POST_MENU_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.post-menu-widget-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
apiExtraButtons[name] = callback;
|
apiExtraButtons[name] = callback;
|
||||||
|
@ -958,10 +961,7 @@ class PluginApi {
|
||||||
removePostMenuButton(name, callback) {
|
removePostMenuButton(name, callback) {
|
||||||
deprecated(
|
deprecated(
|
||||||
"`api.removePostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
"`api.removePostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
||||||
{
|
POST_MENU_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.post-menu-widget-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
removeButton(name, callback);
|
removeButton(name, callback);
|
||||||
|
@ -986,10 +986,7 @@ class PluginApi {
|
||||||
replacePostMenuButton(name, widget) {
|
replacePostMenuButton(name, widget) {
|
||||||
deprecated(
|
deprecated(
|
||||||
"`api.replacePostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
"`api.replacePostMenuButton` has been deprecated. Use the value transformer `post-menu-buttons` instead.",
|
||||||
{
|
POST_MENU_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.post-menu-widget-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
replaceButton(name, widget);
|
replaceButton(name, widget);
|
||||||
|
@ -3418,10 +3415,7 @@ class PluginApi {
|
||||||
if (DEPRECATED_POST_MENU_WIDGETS.includes(widgetName)) {
|
if (DEPRECATED_POST_MENU_WIDGETS.includes(widgetName)) {
|
||||||
deprecated(
|
deprecated(
|
||||||
`The ${widgetName} widget has been deprecated and ${override} is no longer a supported override.`,
|
`The ${widgetName} widget has been deprecated and ${override} is no longer a supported override.`,
|
||||||
{
|
POST_MENU_DEPRECATION_OPTIONS
|
||||||
since: "v3.4.0.beta3-dev",
|
|
||||||
id: "discourse.post-menu-widget-overrides",
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,11 +550,15 @@ createWidget("post-contents", {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.siteSettings.glimmer_post_menu_mode === "enabled" ||
|
this.siteSettings.glimmer_post_menu_mode === "enabled" ||
|
||||||
((this.siteSettings.glimmer_post_menu_mode === "auto" ||
|
(this.siteSettings.glimmer_post_menu_mode === "auto" &&
|
||||||
this.currentUser?.use_auto_glimmer_post_menu) &&
|
|
||||||
!postMenuWidgetExtensionsAdded)
|
!postMenuWidgetExtensionsAdded)
|
||||||
) {
|
) {
|
||||||
if (!postMenuConsoleWarningLogged) {
|
if (!postMenuConsoleWarningLogged) {
|
||||||
|
if (!isTesting()) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log("✅ Using the new 'glimmer' post menu!");
|
||||||
|
}
|
||||||
|
|
||||||
if (postMenuWidgetExtensionsAdded) {
|
if (postMenuWidgetExtensionsAdded) {
|
||||||
postMenuConsoleWarningLogged = true;
|
postMenuConsoleWarningLogged = true;
|
||||||
|
|
||||||
|
@ -567,12 +571,6 @@ createWidget("post-contents", {
|
||||||
// TODO (glimmer-post-menu): add link to meta topic here when the roadmap for the update is announced
|
// TODO (glimmer-post-menu): add link to meta topic here when the roadmap for the update is announced
|
||||||
].join("\n- ")
|
].join("\n- ")
|
||||||
);
|
);
|
||||||
} else if (this.currentUser?.use_auto_glimmer_post_menu) {
|
|
||||||
// TODO (glimmer-post-menu): remove this else if block when removing the site setting glimmer_post_menu_groups
|
|
||||||
postMenuConsoleWarningLogged = true;
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log("✅ Using the new 'glimmer' post menu!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,8 +615,7 @@ createWidget("post-contents", {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
(this.siteSettings.glimmer_post_menu_mode !== "disabled" ||
|
this.siteSettings.glimmer_post_menu_mode !== "disabled" &&
|
||||||
this.currentUser?.use_auto_glimmer_post_menu) &&
|
|
||||||
postMenuWidgetExtensionsAdded &&
|
postMenuWidgetExtensionsAdded &&
|
||||||
!postMenuConsoleWarningLogged
|
!postMenuConsoleWarningLogged
|
||||||
) {
|
) {
|
||||||
|
@ -1019,7 +1016,8 @@ createWidget("post-article", {
|
||||||
return new RenderGlimmer(
|
return new RenderGlimmer(
|
||||||
this,
|
this,
|
||||||
"div.topic-map.--op",
|
"div.topic-map.--op",
|
||||||
hbs`<TopicMap
|
hbs`
|
||||||
|
<TopicMap
|
||||||
@model={{@data.model}}
|
@model={{@data.model}}
|
||||||
@topicDetails={{@data.topicDetails}}
|
@topicDetails={{@data.topicDetails}}
|
||||||
@postStream={{@data.postStream}}
|
@postStream={{@data.postStream}}
|
||||||
|
|
|
@ -31,7 +31,7 @@ acceptance("Keyboard Shortcuts - Anonymous Users", function (needs) {
|
||||||
await visit("/t/this-is-a-test-topic/9");
|
await visit("/t/this-is-a-test-topic/9");
|
||||||
await triggerKeyEvent(document, "keypress", "G");
|
await triggerKeyEvent(document, "keypress", "G");
|
||||||
await triggerKeyEvent(document, "keypress", "S");
|
await triggerKeyEvent(document, "keypress", "S");
|
||||||
assert.strictEqual(currentURL(), "/t/this-is-a-test-topic/9");
|
assert.true(currentURL().startsWith("/t/this-is-a-test-topic/9"));
|
||||||
|
|
||||||
// Suggested topics elements exist.
|
// Suggested topics elements exist.
|
||||||
await visit("/t/internationalization-localization/280");
|
await visit("/t/internationalization-localization/280");
|
||||||
|
|
|
@ -76,7 +76,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
:use_admin_sidebar,
|
:use_admin_sidebar,
|
||||||
:can_view_raw_email,
|
:can_view_raw_email,
|
||||||
:use_glimmer_topic_list?,
|
:use_glimmer_topic_list?,
|
||||||
:use_auto_glimmer_post_menu?,
|
|
||||||
:login_method,
|
:login_method,
|
||||||
:has_unseen_features
|
:has_unseen_features
|
||||||
|
|
||||||
|
@ -327,10 +326,6 @@ class CurrentUserSerializer < BasicUserSerializer
|
||||||
scope.user.in_any_groups?(SiteSetting.experimental_glimmer_topic_list_groups_map)
|
scope.user.in_any_groups?(SiteSetting.experimental_glimmer_topic_list_groups_map)
|
||||||
end
|
end
|
||||||
|
|
||||||
def use_auto_glimmer_post_menu?
|
|
||||||
scope.user.in_any_groups?(SiteSetting.glimmer_post_menu_groups_map)
|
|
||||||
end
|
|
||||||
|
|
||||||
def do_not_disturb_channel_position
|
def do_not_disturb_channel_position
|
||||||
MessageBus.last_id("/do-not-disturb/#{object.id}")
|
MessageBus.last_id("/do-not-disturb/#{object.id}")
|
||||||
end
|
end
|
||||||
|
|
|
@ -3344,20 +3344,12 @@ experimental:
|
||||||
refresh: true
|
refresh: true
|
||||||
glimmer_post_menu_mode:
|
glimmer_post_menu_mode:
|
||||||
client: true
|
client: true
|
||||||
hidden: true
|
|
||||||
type: enum
|
type: enum
|
||||||
choices:
|
choices:
|
||||||
- disabled
|
- disabled
|
||||||
- auto
|
- auto
|
||||||
- enabled
|
- enabled
|
||||||
default: disabled
|
default: auto
|
||||||
glimmer_post_menu_groups:
|
|
||||||
client: true
|
|
||||||
type: group_list
|
|
||||||
list_type: compact
|
|
||||||
default: ""
|
|
||||||
allow_any: false
|
|
||||||
refresh: true
|
|
||||||
enable_experimental_lightbox:
|
enable_experimental_lightbox:
|
||||||
default: false
|
default: false
|
||||||
client: true
|
client: true
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
class RemoveGlimmerPostMenuGroupsSetting < ActiveRecord::Migration[7.2]
|
||||||
|
def up
|
||||||
|
execute <<~SQL
|
||||||
|
DELETE FROM site_settings
|
||||||
|
WHERE name = 'glimmer_post_menu_groups'
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user