fix: fixes incorrectly mapping from granted permissions to record types #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rebase of #142
Summary
How we infer Record types from permission names after calling
PermissionController.getGrantedPermissions
doesn't work for all permissions - not all record names overlap with snake cased version of the permission names. For example, the code block:will output:
The only way to extract the exact set of React RecordTypes an app has permissions for would be to run through the record classes supported by the library and run its read/write permission against the list of granted permissions returned by the PermissionController which is what this PR aims to do.
Testing
Manually tested the example app and the granted permissions worked as usual.
Related Issues
Should fix #63 as the record name for sleep is
SleepSession
(ref) while the permission name isREAD_/WRITE_SLEEP
(ref).