DEV: Add glimmer header deprecation notice (#25891)
- Remove `_customHeaderClasses`. It was not supposed to have been a part of the glimmer header PR - Add deprecation notice to `addHeaderPanel` # Example <img width="437" alt="Screenshot 2024-02-26 at 2 50 39 PM" src="https://github.com/discourse/discourse/assets/50783505/23fce1ee-fff9-4071-8c34-a480cec7e2e7">
This commit is contained in:
parent
80cc538e77
commit
0e5307d8e2
|
@ -4,7 +4,6 @@ import { action } from "@ember/object";
|
||||||
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
|
||||||
import { inject as service } from "@ember/service";
|
import { inject as service } from "@ember/service";
|
||||||
import { modifier } from "ember-modifier";
|
import { modifier } from "ember-modifier";
|
||||||
import concatClass from "discourse/helpers/concat-class";
|
|
||||||
import scrollLock from "discourse/lib/scroll-lock";
|
import scrollLock from "discourse/lib/scroll-lock";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
import { scrollTop } from "discourse/mixins/scroll-top";
|
import { scrollTop } from "discourse/mixins/scroll-top";
|
||||||
|
@ -21,11 +20,6 @@ import PluginOutlet from "./plugin-outlet";
|
||||||
|
|
||||||
const SEARCH_BUTTON_ID = "search-button";
|
const SEARCH_BUTTON_ID = "search-button";
|
||||||
|
|
||||||
let _customHeaderClasses = [];
|
|
||||||
export function addCustomHeaderClass(className) {
|
|
||||||
_customHeaderClasses.push(className);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class GlimmerHeader extends Component {
|
export default class GlimmerHeader extends Component {
|
||||||
@service router;
|
@service router;
|
||||||
@service search;
|
@service search;
|
||||||
|
@ -53,10 +47,6 @@ export default class GlimmerHeader extends Component {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
get customHeaderClasses() {
|
|
||||||
return _customHeaderClasses.join(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
headerKeyboardTrigger(msg) {
|
headerKeyboardTrigger(msg) {
|
||||||
switch (msg.type) {
|
switch (msg.type) {
|
||||||
|
@ -168,10 +158,7 @@ export default class GlimmerHeader extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<header
|
<header class="d-header" {{this.appEventsListeners}}>
|
||||||
class={{concatClass this.customHeaderClasses "d-header"}}
|
|
||||||
{{this.appEventsListeners}}
|
|
||||||
>
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<Contents
|
<Contents
|
||||||
@sidebarEnabled={{@sidebarEnabled}}
|
@sidebarEnabled={{@sidebarEnabled}}
|
||||||
|
|
|
@ -9,7 +9,6 @@ import {
|
||||||
import { addPluginDocumentTitleCounter } from "discourse/components/d-document";
|
import { addPluginDocumentTitleCounter } from "discourse/components/d-document";
|
||||||
import { addToolbarCallback } from "discourse/components/d-editor";
|
import { addToolbarCallback } from "discourse/components/d-editor";
|
||||||
import { addCategorySortCriteria } from "discourse/components/edit-category-settings";
|
import { addCategorySortCriteria } from "discourse/components/edit-category-settings";
|
||||||
import { addCustomHeaderClass } from "discourse/components/glimmer-header";
|
|
||||||
import { addToHeaderIcons as addToGlimmerHeaderIcons } from "discourse/components/glimmer-header/icons";
|
import { addToHeaderIcons as addToGlimmerHeaderIcons } from "discourse/components/glimmer-header/icons";
|
||||||
import { forceDropdownForMenuPanels as glimmerForceDropdownForMenuPanels } from "discourse/components/glimmer-site-header";
|
import { forceDropdownForMenuPanels as glimmerForceDropdownForMenuPanels } from "discourse/components/glimmer-site-header";
|
||||||
import { addGlobalNotice } from "discourse/components/global-notice";
|
import { addGlobalNotice } from "discourse/components/global-notice";
|
||||||
|
@ -147,6 +146,18 @@ import { modifySelectKit } from "select-kit/mixins/plugin-api";
|
||||||
|
|
||||||
export const PLUGIN_API_VERSION = "1.27.0";
|
export const PLUGIN_API_VERSION = "1.27.0";
|
||||||
|
|
||||||
|
const DEPRECATED_HEADER_WIDGETS = [
|
||||||
|
"header",
|
||||||
|
"site-header",
|
||||||
|
"header-contents",
|
||||||
|
"header-buttons",
|
||||||
|
"user-status-bubble",
|
||||||
|
"sidebar-toggle",
|
||||||
|
"header-icons",
|
||||||
|
"header-topic-info",
|
||||||
|
"header-notifications",
|
||||||
|
];
|
||||||
|
|
||||||
// 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.
|
||||||
function canModify(klass, type, resolverName, changes) {
|
function canModify(klass, type, resolverName, changes) {
|
||||||
if (!changes.pluginId) {
|
if (!changes.pluginId) {
|
||||||
|
@ -185,6 +196,19 @@ function wrapWithErrorHandler(func, messageKey) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deprecatedHeaderWidgetOverride(widgetName, override) {
|
||||||
|
if (DEPRECATED_HEADER_WIDGETS.includes(widgetName)) {
|
||||||
|
deprecated(
|
||||||
|
`The ${widgetName} widget has been deprecated and ${override} is no longer a supported override.`,
|
||||||
|
{
|
||||||
|
since: "v3.3.0.beta1-dev",
|
||||||
|
id: "discourse.header-widget-overrides",
|
||||||
|
url: "https://meta.discourse.org/t/296544",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class PluginApi {
|
class PluginApi {
|
||||||
constructor(version, container) {
|
constructor(version, container) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
@ -528,6 +552,9 @@ class PluginApi {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
decorateWidget(name, fn) {
|
decorateWidget(name, fn) {
|
||||||
|
const widgetName = name.split(":")[0];
|
||||||
|
deprecatedHeaderWidgetOverride(widgetName, "decorateWidget");
|
||||||
|
|
||||||
decorateWidget(name, fn);
|
decorateWidget(name, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,6 +584,8 @@ class PluginApi {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deprecatedHeaderWidgetOverride(widget, "attachWidgetAction");
|
||||||
|
|
||||||
widgetClass.prototype[actionName] = fn;
|
widgetClass.prototype[actionName] = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,6 +903,7 @@ class PluginApi {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
changeWidgetSetting(widgetName, settingName, newValue) {
|
changeWidgetSetting(widgetName, settingName, newValue) {
|
||||||
|
deprecatedHeaderWidgetOverride(widgetName, "changeWidgetSetting");
|
||||||
changeSetting(widgetName, settingName, newValue);
|
changeSetting(widgetName, settingName, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,6 +937,7 @@ class PluginApi {
|
||||||
**/
|
**/
|
||||||
|
|
||||||
reopenWidget(name, args) {
|
reopenWidget(name, args) {
|
||||||
|
deprecatedHeaderWidgetOverride(name, "reopenWidget");
|
||||||
return reopenWidget(name, args);
|
return reopenWidget(name, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,10 +965,13 @@ class PluginApi {
|
||||||
*
|
*
|
||||||
**/
|
**/
|
||||||
addHeaderPanel(name, toggle, transformAttrs) {
|
addHeaderPanel(name, toggle, transformAttrs) {
|
||||||
// deprecated(
|
deprecated(
|
||||||
// "addHeaderPanel has been removed. Use api.addToHeaderIcons instead.",
|
"addHeaderPanel has been removed. Use api.addToHeaderIcons instead.",
|
||||||
// { id: "discourse.add-header-panel" }
|
{
|
||||||
// );
|
id: "discourse.add-header-panel",
|
||||||
|
url: "https://meta.discourse.org/t/296544",
|
||||||
|
}
|
||||||
|
);
|
||||||
attachAdditionalPanel(name, toggle, transformAttrs);
|
attachAdditionalPanel(name, toggle, transformAttrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2802,19 +2836,6 @@ class PluginApi {
|
||||||
addImageWrapperButton(label, btnClass, icon);
|
addImageWrapperButton(label, btnClass, icon);
|
||||||
addApiImageWrapperButtonClickEvent(fn);
|
addApiImageWrapperButtonClickEvent(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a custom css class to the header. The class or classes will live alongside the `d-header` class.
|
|
||||||
*
|
|
||||||
* ```
|
|
||||||
* api.addCustomHeaderClass("class-one");
|
|
||||||
* api.addCustomHeaderClass("class-two");
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
addCustomHeaderClass(klass) {
|
|
||||||
addCustomHeaderClass(klass);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from http://stackoverflow.com/questions/6832596/how-to-compare-software-version-number-using-js-only-number
|
// from http://stackoverflow.com/questions/6832596/how-to-compare-software-version-number-using-js-only-number
|
||||||
|
|
Loading…
Reference in New Issue