From 6d9fcf8f76a873d7494855061d204484fceb192e Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Thu, 11 Jan 2024 11:35:00 +0100 Subject: [PATCH] DEV: Don't apply this-fallback to strict-mode components (#25216) fixes the issue with imported components references in plugin gjs files --- ...llback+0.4.0+003+exclude-strict-mode.patch | 76 +++++++++++++++++++ .../discourse/components/chat/list/index.gjs | 6 +- .../components/chat/navbar/actions.gjs | 60 +++------------ .../components/chat/navbar/index.gjs | 24 +----- .../components/chat/navbar/sub-title.gjs | 5 -- .../components/chat/navbar/title.gjs | 6 +- 6 files changed, 92 insertions(+), 85 deletions(-) create mode 100644 app/assets/javascripts/patches/ember-this-fallback+0.4.0+003+exclude-strict-mode.patch diff --git a/app/assets/javascripts/patches/ember-this-fallback+0.4.0+003+exclude-strict-mode.patch b/app/assets/javascripts/patches/ember-this-fallback+0.4.0+003+exclude-strict-mode.patch new file mode 100644 index 00000000000..b02e762050e --- /dev/null +++ b/app/assets/javascripts/patches/ember-this-fallback+0.4.0+003+exclude-strict-mode.patch @@ -0,0 +1,76 @@ +diff --git a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js +index a8ee337..9b144de 100644 +--- a/node_modules/ember-this-fallback/lib/this-fallback-plugin.js ++++ b/node_modules/ember-this-fallback/lib/this-fallback-plugin.js +@@ -60,9 +60,15 @@ class ThisFallbackPlugin { + handleBlock() { + return { + enter: (node) => { ++ if (this.env.strictMode) { ++ return; ++ } + this.scopeStack.push(node.blockParams); + }, + exit: () => { ++ if (this.env.strictMode) { ++ return; ++ } + this.scopeStack.pop(); + }, + }; +@@ -70,6 +76,9 @@ class ThisFallbackPlugin { + handleAttrNodes() { + return { + enter: (elementNode, elementPath) => { ++ if (this.env.strictMode) { ++ return; ++ } + const ambiguousHeads = new Map(); + const blockParamName = (0, scope_stack_1.unusedNameLike)('maybeHelpers', this.scopeStack); + for (const attrNode of elementNode.attributes) { +@@ -119,6 +128,9 @@ class ThisFallbackPlugin { + return { + keys: { + params: (node) => { ++ if (this.env.strictMode) { ++ return; ++ } + const { scopeStack } = this; + node.params = node.params.map((expr) => { + if ((0, fallback_1.needsFallback)(expr, scopeStack)) { +@@ -131,6 +143,9 @@ class ThisFallbackPlugin { + }); + }, + hash: (node) => { ++ if (this.env.strictMode) { ++ return; ++ } + const { scopeStack } = this; + node.hash.pairs = node.hash.pairs.map((pair) => { + const { key, value: expr, loc } = pair; +@@ -149,6 +164,9 @@ class ThisFallbackPlugin { + handleMustache() { + return { + enter: (node, path) => { ++ if (this.env.strictMode) { ++ return; ++ } + // Alias node to n so that the type of `node` doesn't get narrowed, + // which prevents mutation + const n = node; +@@ -174,9 +192,15 @@ class ThisFallbackPlugin { + handleTemplate() { + return { + enter: (node) => { ++ if (this.env.strictMode) { ++ return; ++ } + this.logger.debug("before: '%s'", (0, string_1.squish)((0, syntax_1.print)(node))); + }, + exit: (node, path) => { ++ if (this.env.strictMode) { ++ return; ++ } + this.logger.debug("after_: '%s'", (0, string_1.squish)((0, syntax_1.print)(node))); + if (this.scopeStack.size !== 1) { + throw new Error(`unbalanced ScopeStack push and pop, ScopeStack size is ${this.scopeStack.size}`); diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/list/index.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/list/index.gjs index 20b10d6b825..fe56feea51a 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/list/index.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat/list/index.gjs @@ -37,10 +37,6 @@ export default class List extends Component { return this.args.itemComponent ?? Item; } - get emptyStateComponent() { - return EmptyState; - } - @action loadCollection() { discourseDebounce(this, this.debouncedLoadCollection, INPUT_DELAY); @@ -57,7 +53,7 @@ export default class List extends Component { {{yield (hash Item=(component this.itemComponent item=item))}} {{else}} {{#if @collection.fetchedOnce}} - {{yield (hash EmptyState=this.emptyStateComponent)}} + {{yield (hash EmptyState=EmptyState)}} {{/if}} {{/each}} diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/actions.gjs b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/actions.gjs index 4ef52c78330..c46ad3b7a8f 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/navbar/actions.gjs +++ b/plugins/chat/assets/javascripts/discourse/components/chat/navbar/actions.gjs @@ -12,60 +12,20 @@ import ThreadsListButton from "./threads-list-button"; import ToggleDrawerButton from "./toggle-drawer-button"; export default class ChatNavbarActions extends Component { - get openDrawerButtonComponent() { - return OpenDrawerButton; - } - - get newChannelButtonComponent() { - return NewChannelButton; - } - - get threadTrackingDropdownComponent() { - return ThreadTrackingDropdown; - } - - get closeThreadButtonComponent() { - return CloseThreadButton; - } - - get closeThreadsButtonComponent() { - return CloseThreadsButton; - } - - get threadSettingsButtonComponent() { - return ThreadSettingsButton; - } - - get threadsListButtonComponent() { - return ThreadsListButton; - } - - get closeDrawerButtonComponent() { - return CloseDrawerButton; - } - - get toggleDrawerButtonComponent() { - return ToggleDrawerButton; - } - - get chatNavbarFullPageButtonComponent() { - return FullPageButton; - } -