Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission grid fixes #3197

Merged
merged 3 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion js/src/admin/components/PermissionDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export default class PermissionDropdown extends Dropdown {

attrs.className = 'PermissionDropdown';
attrs.buttonClassName = 'Button Button--text';
attrs.lazyDraw = true;
}

view(vnode) {
Expand Down
6 changes: 4 additions & 2 deletions js/src/admin/components/PermissionGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export default class PermissionGrid<CustomAttrs extends IPermissionGridAttrs = I

const permissionCells = (permission: PermissionGridEntry | { children: PermissionGridEntry[] }) => {
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 <td></td>;
}

return scope.render(permission);
return <td>{scope.render(permission)}</td>;
});
};

Expand Down Expand Up @@ -416,7 +418,7 @@ export default class PermissionGrid<CustomAttrs extends IPermissionGridAttrs = I
});
}

return '';
return null;
},
},
100
Expand Down
11 changes: 8 additions & 3 deletions js/src/admin/components/SettingDropdown.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import app from '../../admin/app';
import app from '../app';
import SelectDropdown from '../../common/components/SelectDropdown';
import Button from '../../common/components/Button';
import saveSettings from '../utils/saveSettings';
Expand All @@ -11,18 +11,23 @@ export default class SettingDropdown extends SelectDropdown {
attrs.buttonClassName = 'Button Button--text';
attrs.caretIcon = 'fas fa-caret-down';
attrs.defaultLabel = 'Custom';

if ('key' in attrs) {
attrs.setting = attrs.key;
delete attrs.key;
}
}

view(vnode) {
return super.view({
...vnode,
children: this.attrs.options.map(({ value, label }) => {
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
Expand Down