From 46893a9749403dfdea0276ead2bb2d553a1706f5 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 13 Dec 2021 01:39:59 -0500 Subject: [PATCH 1/3] PermissionGrid fixes Fixes https://github.com/flarum/core/issues/3169#issuecomment-979470794 - Restore wrapping `scope.render` results in a table cell tag. This was accidentially introduced in 924815b6e1f01cf709212d58ded1badd3e03779c, and caused the issue linked above - Rename the `SettingDropdown` attr `key` to `setting` in order to avoid naming clashes with Mithril vnode keys. `key` still works, but is deprecated. --- js/src/admin/components/PermissionGrid.tsx | 6 ++++-- js/src/admin/components/SettingDropdown.js | 11 ++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/js/src/admin/components/PermissionGrid.tsx b/js/src/admin/components/PermissionGrid.tsx index 6044576b0..ef2a71c0c 100644 --- a/js/src/admin/components/PermissionGrid.tsx +++ b/js/src/admin/components/PermissionGrid.tsx @@ -38,11 +38,13 @@ export default class PermissionGrid { return scopes.map((scope) => { + // This indicates the "permission" is a permission category, + // in which case we return an empty table cell. if ('children' in permission) { return ; } - return scope.render(permission); + return {scope.render(permission)}; }); }; @@ -416,7 +418,7 @@ export default class PermissionGrid { - const active = app.data.settings[this.attrs.key] === value; + const active = app.data.settings[this.attrs.setting] === value; return Button.component( { icon: active ? 'fas fa-check' : true, - onclick: saveSettings.bind(this, { [this.attrs.key]: value }), + onclick: saveSettings.bind(this, { [this.attrs.setting]: value }), active, }, label From 4ade45e67aed731349b54fcc1e02021469de2021 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 13 Dec 2021 01:57:15 -0500 Subject: [PATCH 2/3] Don't lazy draw permissions dropdown It is already lazy drawn, see https://github.com/flarum/core/blob/23a70affa63b49d4ce3daa92df354a3e63786d97/js/src/admin/components/PermissionDropdown.js#L63-L63 --- js/src/admin/components/PermissionDropdown.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/src/admin/components/PermissionDropdown.js b/js/src/admin/components/PermissionDropdown.js index 597e37b15..aa635d925 100644 --- a/js/src/admin/components/PermissionDropdown.js +++ b/js/src/admin/components/PermissionDropdown.js @@ -38,7 +38,6 @@ export default class PermissionDropdown extends Dropdown { attrs.className = 'PermissionDropdown'; attrs.buttonClassName = 'Button Button--text'; - attrs.lazyDraw = true; } view(vnode) { From 1567ab0cb8e844f3ea759ed17fbe32feefa0d9e2 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Mon, 13 Dec 2021 18:55:25 -0500 Subject: [PATCH 3/3] Return undefined => return null --- js/src/admin/components/PermissionGrid.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/admin/components/PermissionGrid.tsx b/js/src/admin/components/PermissionGrid.tsx index ef2a71c0c..37741ff29 100644 --- a/js/src/admin/components/PermissionGrid.tsx +++ b/js/src/admin/components/PermissionGrid.tsx @@ -418,7 +418,7 @@ export default class PermissionGrid