Fix naming scheme for role types
Opened this issue · 1 comments
In order to work with permissions in PermissionDialog.vue
, there are two declared types in utils/permissions.ts
, being Role
and SingularRole
. Further, there exists an interface called UserPermissionSpec
with two properties: role: Role
and user: UserSpec
.
Semantically, I'd argue that an object which looks like {role: 'writers', user: {...}}
makes little sense, since the actual role of this user would be writer
. The type Role
should be singular, and we should have a new type along the lines of PluralRole
. Furthermore, the function names of singularRoleToPlural(role: SingularRole)
and pluralRoleToSingular(role: Role)
should be changed to singularize(role: PluralRole)
and pluralize(role: Role)
. The typing of the function signatures already communicates what is being changed.
This is not a high priority set of changes, but they would make our code easier to read.
For the record, naglepuff and I discussed this change and the ideas expressed are a mix of ideas that came out of our meeting. @AlmightyYakob if you have thoughts on this, please share.