mirror of
https://github.com/bitwarden/android.git
synced 2024-11-24 10:25:57 +03:00
PM-13842: Hide ownership when the user has no organizations (#4199)
This commit is contained in:
parent
eaa7923d1f
commit
c99e5ce2de
9 changed files with 38 additions and 4 deletions
|
@ -300,7 +300,7 @@ fun LazyListScope.vaultAddEditCardItems(
|
|||
)
|
||||
}
|
||||
|
||||
if (isAddItemMode) {
|
||||
if (isAddItemMode && commonState.hasOrganizations) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
BitwardenListHeaderText(
|
||||
|
|
|
@ -414,7 +414,7 @@ fun LazyListScope.vaultAddEditIdentityItems(
|
|||
)
|
||||
}
|
||||
|
||||
if (isAddItemMode) {
|
||||
if (isAddItemMode && commonState.hasOrganizations) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
BitwardenListHeaderText(
|
||||
|
|
|
@ -317,7 +317,7 @@ fun LazyListScope.vaultAddEditLoginItems(
|
|||
)
|
||||
}
|
||||
|
||||
if (isAddItemMode) {
|
||||
if (isAddItemMode && commonState.hasOrganizations) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
BitwardenListHeaderText(
|
||||
|
|
|
@ -176,7 +176,7 @@ fun LazyListScope.vaultAddEditSecureNotesItems(
|
|||
)
|
||||
}
|
||||
|
||||
if (isAddItemMode) {
|
||||
if (isAddItemMode && commonState.hasOrganizations) {
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
BitwardenListHeaderText(
|
||||
|
|
|
@ -2114,6 +2114,7 @@ data class VaultAddEditState(
|
|||
* @property availableFolders The list of folders that this item could be added too.
|
||||
* @property selectedOwnerId The ID of the owner associated with the item.
|
||||
* @property availableOwners A list of available owners.
|
||||
* @property hasOrganizations Indicates if the user is part of any organizations.
|
||||
*/
|
||||
@Parcelize
|
||||
data class Common(
|
||||
|
@ -2129,6 +2130,7 @@ data class VaultAddEditState(
|
|||
val availableFolders: List<Folder> = emptyList(),
|
||||
val selectedOwnerId: String? = null,
|
||||
val availableOwners: List<Owner> = emptyList(),
|
||||
val hasOrganizations: Boolean = false,
|
||||
) : Parcelable {
|
||||
|
||||
/**
|
||||
|
|
|
@ -106,6 +106,7 @@ fun CipherView.toViewState(
|
|||
masterPasswordReprompt = this.reprompt == CipherRepromptType.PASSWORD,
|
||||
notes = this.notes.orEmpty(),
|
||||
availableOwners = emptyList(),
|
||||
hasOrganizations = false,
|
||||
customFieldData = this.fields.orEmpty().map { it.toCustomField() },
|
||||
),
|
||||
isIndividualVaultDisabled = isIndividualVaultDisabled,
|
||||
|
@ -139,6 +140,7 @@ fun VaultAddEditState.ViewState.appendFolderAndOwnerData(
|
|||
isIndividualVaultDisabled = isIndividualVaultDisabled,
|
||||
),
|
||||
isUnlockWithPasswordEnabled = activeAccount.hasMasterPassword,
|
||||
hasOrganizations = activeAccount.organizations.isNotEmpty(),
|
||||
),
|
||||
)
|
||||
} ?: this
|
||||
|
|
|
@ -2361,6 +2361,31 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ownership section should not be displayed when no organizations present`() {
|
||||
updateStateWithOwners(selectedOwnerId = "mockOwnerId-2")
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithTextAfterScroll(text = "mockCollectionName-2")
|
||||
.assertIsDisplayed()
|
||||
|
||||
updateStateWithOwners(
|
||||
selectedOwnerId = null,
|
||||
availableOwners = listOf(
|
||||
VaultAddEditState.Owner(
|
||||
id = null,
|
||||
name = "placeholder@email.com",
|
||||
collections = DEFAULT_COLLECTIONS,
|
||||
),
|
||||
),
|
||||
hasOrganizations = false,
|
||||
)
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "mockCollectionName-2")
|
||||
.assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Collection list should display according to state`() {
|
||||
updateStateWithOwners(selectedOwnerId = "mockOwnerId-2")
|
||||
|
@ -3482,12 +3507,14 @@ class VaultAddEditScreenTest : BaseComposeTest() {
|
|||
private fun updateStateWithOwners(
|
||||
selectedOwnerId: String? = null,
|
||||
availableOwners: List<VaultAddEditState.Owner> = DEFAULT_OWNERS,
|
||||
hasOrganizations: Boolean = true,
|
||||
) {
|
||||
mutableStateFlow.update { currentState ->
|
||||
updateCommonContent(currentState) {
|
||||
copy(
|
||||
selectedOwnerId = selectedOwnerId,
|
||||
availableOwners = availableOwners,
|
||||
hasOrganizations = hasOrganizations,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4026,6 +4026,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
|
|||
),
|
||||
availableOwners: List<VaultAddEditState.Owner> = createOwnerList(),
|
||||
selectedOwnerId: String? = null,
|
||||
hasOrganizations: Boolean = true,
|
||||
): VaultAddEditState.ViewState.Content.Common =
|
||||
VaultAddEditState.ViewState.Content.Common(
|
||||
name = name,
|
||||
|
@ -4038,6 +4039,7 @@ class VaultAddEditViewModelTest : BaseViewModelTest() {
|
|||
originalCipher = originalCipher,
|
||||
availableFolders = availableFolders,
|
||||
availableOwners = availableOwners,
|
||||
hasOrganizations = hasOrganizations,
|
||||
)
|
||||
|
||||
@Suppress("LongParameterList")
|
||||
|
|
|
@ -505,6 +505,7 @@ class CipherViewExtensionsTest {
|
|||
name = "mockName-1",
|
||||
),
|
||||
),
|
||||
hasOrganizations = true,
|
||||
availableOwners = listOf(
|
||||
VaultAddEditState.Owner(
|
||||
id = null,
|
||||
|
|
Loading…
Reference in a new issue