Skip to content

Commit

Permalink
Do not barf on undefined permissions (#444)
Browse files Browse the repository at this point in the history
When the Permissions Inspector encounters an undefined permission
(which should never happen) it now shows that permission's true name
in bold red instead of crashing.

Fixes UID-183.
  • Loading branch information
MikeTaylor authored Nov 28, 2024
1 parent 5b4be2d commit e661b44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 9.1.0 IN PROGRESS

* Sort locales by label instead of locale-code. Refs UID-107.
* When the Permissions Inspector encounters an undefined permission (which should never happen) it now shows that permission's true name in bold red instead of crashing. Fixes UID-183.

## [9.0.0](https://github.com/folio-org/ui-developer/tree/v9.0.0) (2024-10-09)
[Full Changelog](https://github.com/folio-org/ui-developer/compare/v8.0.0...v9.0.0)
Expand Down
15 changes: 15 additions & 0 deletions src/settings/PermissionsInspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ function SinglePermission({ permName, name2perm }) {
const intl = useIntl();
const perm = name2perm[permName];
const [expanded, setExpanded] = useState(false);

if (!perm) {
// This should never happen
return (
<span
style={{
color: 'red',
fontWeight: 'bold',
}}
>
{permName}
</span>
);
}

const displayName = getPermissionLabelString(perm, intl.formatMessage);

return (
Expand Down

0 comments on commit e661b44

Please sign in to comment.