Change the test to hide multi signout of devices.

We do not need an external account management URL, which is optional, but we need to know if account management is delegate to Oidc.
This commit is contained in:
Benoit Marty 2023-08-31 15:51:18 +02:00 committed by Benoit Marty
parent a889d8d678
commit 52a06931f4
7 changed files with 22 additions and 16 deletions

View File

@ -146,6 +146,8 @@ data class HomeServerCapabilities(
return cap?.preferred ?: cap?.support?.lastOrNull() return cap?.preferred ?: cap?.support?.lastOrNull()
} }
val delegatedOidcAuthEnabled: Boolean = authenticationIssuer != null
companion object { companion object {
const val MAX_UPLOAD_FILE_SIZE_UNKNOWN = -1L const val MAX_UPLOAD_FILE_SIZE_UNKNOWN = -1L
const val ROOM_CAP_KNOCK = "knock" const val ROOM_CAP_KNOCK = "knock"

View File

@ -35,6 +35,7 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
import timber.log.Timber import timber.log.Timber
@ -69,16 +70,17 @@ class DevicesViewModel @AssistedInject constructor(
refreshDeviceList() refreshDeviceList()
refreshIpAddressVisibility() refreshIpAddressVisibility()
observePreferences() observePreferences()
initExternalAccountManagementUrl() initDelegatedOidcAuthEnabled()
} }
private fun initExternalAccountManagementUrl() { private fun initDelegatedOidcAuthEnabled() {
setState { setState {
copy( copy(
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession() delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
?.homeServerCapabilitiesService() ?.homeServerCapabilitiesService()
?.getHomeServerCapabilities() ?.getHomeServerCapabilities()
?.externalAccountManagementUrl ?.delegatedOidcAuthEnabled
.orFalse()
) )
} }
} }

View File

@ -26,7 +26,7 @@ data class DevicesViewState(
val devices: Async<DeviceFullInfoList> = Uninitialized, val devices: Async<DeviceFullInfoList> = Uninitialized,
val isLoading: Boolean = false, val isLoading: Boolean = false,
val isShowingIpAddress: Boolean = false, val isShowingIpAddress: Boolean = false,
val externalAccountManagementUrl: String? = null, val delegatedOidcAuthEnabled: Boolean = false,
) : MavericksState ) : MavericksState
data class DeviceFullInfoList( data class DeviceFullInfoList(

View File

@ -355,8 +355,8 @@ class VectorSettingsDevicesFragment :
views.deviceListHeaderOtherSessions.isVisible = true views.deviceListHeaderOtherSessions.isVisible = true
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError) val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
val multiSignoutItem = views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderMultiSignout) val multiSignoutItem = views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderMultiSignout)
// Hide multi signout if we have an external account manager // Hide multi signout if the homeserver delegates the account management
multiSignoutItem.isVisible = state.externalAccountManagementUrl == null multiSignoutItem.isVisible = state.delegatedOidcAuthEnabled.not()
val nbDevices = otherDevices.size val nbDevices = otherDevices.size
multiSignoutItem.title = stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices) multiSignoutItem.title = stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
multiSignoutItem.setTextColor(colorDestructive) multiSignoutItem.setTextColor(colorDestructive)
@ -396,8 +396,8 @@ class VectorSettingsDevicesFragment :
signoutSessionItem.setTextColor(colorDestructive) signoutSessionItem.setTextColor(colorDestructive)
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions) val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
signoutOtherSessionsItem.setTextColor(colorDestructive) signoutOtherSessionsItem.setTextColor(colorDestructive)
// Hide signout other sessions if we have an external account manager // Hide signout other sessions if the homeserver delegates the account management
signoutOtherSessionsItem.isVisible = hasOtherDevices && state.externalAccountManagementUrl == null signoutOtherSessionsItem.isVisible = hasOtherDevices && state.delegatedOidcAuthEnabled.not()
} }
private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) { private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) {

View File

@ -103,8 +103,8 @@ class OtherSessionsFragment :
val nbDevices = viewState.devices()?.size ?: 0 val nbDevices = viewState.devices()?.size ?: 0
stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices) stringProvider.getQuantityString(R.plurals.device_manager_other_sessions_multi_signout_all, nbDevices, nbDevices)
} }
multiSignoutItem.isVisible = if (viewState.externalAccountManagementUrl != null) { multiSignoutItem.isVisible = if (viewState.delegatedOidcAuthEnabled) {
// Hide multi signout if we have an external account manager // Hide multi signout if the homeserver delegates the account management
false false
} else { } else {
if (viewState.isSelectModeEnabled) { if (viewState.isSelectModeEnabled) {

View File

@ -36,6 +36,7 @@ import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsReAuthN
import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsUseCase import im.vector.app.features.settings.devices.v2.signout.SignoutSessionsUseCase
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
import timber.log.Timber import timber.log.Timber
@ -65,16 +66,17 @@ class OtherSessionsViewModel @AssistedInject constructor(
observeDevices(initialState.currentFilter) observeDevices(initialState.currentFilter)
refreshIpAddressVisibility() refreshIpAddressVisibility()
observePreferences() observePreferences()
initExternalAccountManagementUrl() initDelegatedOidcAuthEnabled()
} }
private fun initExternalAccountManagementUrl() { private fun initDelegatedOidcAuthEnabled() {
setState { setState {
copy( copy(
externalAccountManagementUrl = activeSessionHolder.getSafeActiveSession() delegatedOidcAuthEnabled = activeSessionHolder.getSafeActiveSession()
?.homeServerCapabilitiesService() ?.homeServerCapabilitiesService()
?.getHomeServerCapabilities() ?.getHomeServerCapabilities()
?.externalAccountManagementUrl ?.delegatedOidcAuthEnabled
.orFalse()
) )
} }
} }

View File

@ -29,7 +29,7 @@ data class OtherSessionsViewState(
val isSelectModeEnabled: Boolean = false, val isSelectModeEnabled: Boolean = false,
val isLoading: Boolean = false, val isLoading: Boolean = false,
val isShowingIpAddress: Boolean = false, val isShowingIpAddress: Boolean = false,
val externalAccountManagementUrl: String? = null, val delegatedOidcAuthEnabled: Boolean = false,
) : MavericksState { ) : MavericksState {
constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice) constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice)