Improve UI and UX when permission are not editable

This commit is contained in:
Benoit Marty 2021-01-06 23:03:09 +01:00
parent 81bdf506bc
commit a28dfdc48e
2 changed files with 12 additions and 6 deletions

View file

@ -73,11 +73,6 @@ class RoomPermissionsController @Inject constructor(
stringProvider.getString(R.string.room_permissions_title) stringProvider.getString(R.string.room_permissions_title)
) )
settingsInfoItem {
id("notice")
helperText(stringProvider.getString(R.string.room_permissions_notice))
}
when (val content = data?.currentPowerLevelsContent) { when (val content = data?.currentPowerLevelsContent) {
is Success -> buildPermissions(data, content()) is Success -> buildPermissions(data, content())
else -> { else -> {
@ -90,6 +85,12 @@ class RoomPermissionsController @Inject constructor(
} }
private fun buildPermissions(data: RoomPermissionsViewState, content: PowerLevelsContent) { private fun buildPermissions(data: RoomPermissionsViewState, content: PowerLevelsContent) {
val editable = data.actionPermissions.canChangePowerLevels
settingsInfoItem {
id("notice")
helperText(stringProvider.getString(if (editable) R.string.room_permissions_notice else R.string.room_permissions_notice_read_only))
}
allEditablePermissions.forEach { editablePermission -> allEditablePermissions.forEach { editablePermission ->
val currentRole = getCurrentRole(editablePermission, content) val currentRole = getCurrentRole(editablePermission, content)
buildProfileAction( buildProfileAction(
@ -99,7 +100,11 @@ class RoomPermissionsController @Inject constructor(
dividerColor = dividerColor, dividerColor = dividerColor,
divider = true, divider = true,
editable = data.actionPermissions.canChangePowerLevels, editable = data.actionPermissions.canChangePowerLevels,
action = { callback?.onEditPermission(editablePermission, currentRole) } action = {
callback
?.takeIf { editable }
?.onEditPermission(editablePermission, currentRole)
}
) )
} }
} }

View file

@ -615,6 +615,7 @@
<string name="room_permissions_title">"Permissions"</string> <string name="room_permissions_title">"Permissions"</string>
<string name="room_permissions_notice">"Select the roles required to change various parts of the room"</string> <string name="room_permissions_notice">"Select the roles required to change various parts of the room"</string>
<string name="room_permissions_notice_read_only">"You don't have permission to update the roles required to change various parts of the room"</string>
<string name="room_permissions_default_role">Default role</string> <string name="room_permissions_default_role">Default role</string>
<string name="room_permissions_send_messages">Send messages</string> <string name="room_permissions_send_messages">Send messages</string>