mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
BIT-2131: Display folders when filtering by org in vault (#1170)
This commit is contained in:
parent
9144bae079
commit
25ceaf8c0b
4 changed files with 27 additions and 10 deletions
|
@ -672,9 +672,7 @@ class VaultItemListingViewModel @Inject constructor(
|
||||||
itemListingType = currentState
|
itemListingType = currentState
|
||||||
.itemListingType
|
.itemListingType
|
||||||
.updateWithAdditionalDataIfNecessary(
|
.updateWithAdditionalDataIfNecessary(
|
||||||
folderList = vaultData
|
folderList = vaultData.folderViewList,
|
||||||
.folderViewList
|
|
||||||
.toFilteredList(state.vaultFilterType),
|
|
||||||
collectionList = vaultData
|
collectionList = vaultData
|
||||||
.collectionViewList
|
.collectionViewList
|
||||||
.toFilteredList(state.vaultFilterType),
|
.toFilteredList(state.vaultFilterType),
|
||||||
|
|
|
@ -209,7 +209,9 @@ fun List<SendView>.toViewState(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** * Updates a [VaultItemListingState.ItemListingType] with the given data if necessary. */
|
/**
|
||||||
|
* Updates a [VaultItemListingState.ItemListingType] with the given data if necessary.
|
||||||
|
*/
|
||||||
fun VaultItemListingState.ItemListingType.updateWithAdditionalDataIfNecessary(
|
fun VaultItemListingState.ItemListingType.updateWithAdditionalDataIfNecessary(
|
||||||
folderList: List<FolderView>,
|
folderList: List<FolderView>,
|
||||||
collectionList: List<CollectionView>,
|
collectionList: List<CollectionView>,
|
||||||
|
|
|
@ -46,7 +46,12 @@ fun VaultData.toViewState(
|
||||||
val filteredCipherViewList = filteredCipherViewListWithDeletedItems
|
val filteredCipherViewList = filteredCipherViewListWithDeletedItems
|
||||||
.filter { it.deletedDate == null }
|
.filter { it.deletedDate == null }
|
||||||
|
|
||||||
val filteredFolderViewList = folderViewList.toFilteredList(vaultFilterType).getFilteredFolders()
|
val filteredFolderViewList = folderViewList
|
||||||
|
.toFilteredList(
|
||||||
|
cipherList = filteredCipherViewList,
|
||||||
|
vaultFilterType = vaultFilterType,
|
||||||
|
)
|
||||||
|
.getFilteredFolders()
|
||||||
|
|
||||||
val filteredCollectionViewList = collectionViewList
|
val filteredCollectionViewList = collectionViewList
|
||||||
.toFilteredList(vaultFilterType)
|
.toFilteredList(vaultFilterType)
|
||||||
|
@ -257,17 +262,20 @@ fun List<CipherView>.toFilteredList(
|
||||||
*/
|
*/
|
||||||
@JvmName("toFilteredFolderList")
|
@JvmName("toFilteredFolderList")
|
||||||
fun List<FolderView>.toFilteredList(
|
fun List<FolderView>.toFilteredList(
|
||||||
|
cipherList: List<CipherView>,
|
||||||
vaultFilterType: VaultFilterType,
|
vaultFilterType: VaultFilterType,
|
||||||
): List<FolderView> =
|
): List<FolderView> =
|
||||||
this
|
this
|
||||||
.filter {
|
.filter { folder ->
|
||||||
when (vaultFilterType) {
|
when (vaultFilterType) {
|
||||||
// Folders are only included when including the user's personal data.
|
|
||||||
VaultFilterType.AllVaults,
|
VaultFilterType.AllVaults,
|
||||||
VaultFilterType.MyVault,
|
VaultFilterType.MyVault,
|
||||||
-> true
|
-> true
|
||||||
|
|
||||||
is VaultFilterType.OrganizationVault -> false
|
// Only include folders containing an item associated with this organization.
|
||||||
|
is VaultFilterType.OrganizationVault -> {
|
||||||
|
cipherList.any { it.folderId == folder.id }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,10 @@ class VaultDataExtensionsTest {
|
||||||
createMockCollectionView(number = 1),
|
createMockCollectionView(number = 1),
|
||||||
createMockCollectionView(number = 2),
|
createMockCollectionView(number = 2),
|
||||||
),
|
),
|
||||||
folderViewList = listOf(createMockFolderView(number = 1)),
|
folderViewList = listOf(
|
||||||
|
createMockFolderView(number = 1),
|
||||||
|
createMockFolderView(number = 3),
|
||||||
|
),
|
||||||
sendViewList = listOf(createMockSendView(number = 1)),
|
sendViewList = listOf(createMockSendView(number = 1)),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -173,7 +176,13 @@ class VaultDataExtensionsTest {
|
||||||
identityItemsCount = 0,
|
identityItemsCount = 0,
|
||||||
secureNoteItemsCount = 0,
|
secureNoteItemsCount = 0,
|
||||||
favoriteItems = listOf(),
|
favoriteItems = listOf(),
|
||||||
folderItems = listOf(),
|
folderItems = listOf(
|
||||||
|
VaultState.ViewState.FolderItem(
|
||||||
|
id = "mockId-1",
|
||||||
|
name = "mockName-1".asText(),
|
||||||
|
itemCount = 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
collectionItems = listOf(
|
collectionItems = listOf(
|
||||||
VaultState.ViewState.CollectionItem(
|
VaultState.ViewState.CollectionItem(
|
||||||
id = "mockId-1",
|
id = "mockId-1",
|
||||||
|
|
Loading…
Reference in a new issue