[PM-13349] Hide Edit option in cipher list item overflow when editing not permitted (#4539)

This commit is contained in:
mpbw2
2025-01-09 15:29:08 -05:00
committed by GitHub
parent 0493710cb4
commit 2f2db1a03f
2 changed files with 59 additions and 1 deletions

View File

@@ -22,7 +22,7 @@ fun CipherView.toOverflowActions(
cipherId = cipherId,
requiresPasswordReprompt = hasMasterPassword,
)
.takeUnless { this.deletedDate != null },
.takeUnless { this.deletedDate != null || !this.edit },
this.login?.username?.let {
ListingItemOverflowAction.VaultAction.CopyUsernameClick(username = it)
},

View File

@@ -277,6 +277,64 @@ class CipherViewExtensionsTest {
)
}
@Test
fun `toOverflowActions should not return Edit action when cipher cannot be edited`() {
val cipher = createMockCipherView(
number = 1,
isDeleted = false,
cipherType = CipherType.LOGIN,
)
.copy(
id = id,
edit = false,
login = createMockLoginView(number = 1).copy(
username = null,
password = null,
uris = null,
totp = null,
),
)
val result = cipher.toOverflowActions(hasMasterPassword = true, isPremiumUser = false)
assertEquals(
listOf(ListingItemOverflowAction.VaultAction.ViewClick(cipherId = id)),
result,
)
}
@Test
fun `toOverflowActions should return Edit action when cipher can be edited`() {
val cipher = createMockCipherView(
number = 1,
isDeleted = false,
cipherType = CipherType.LOGIN,
)
.copy(
id = id,
edit = true,
login = createMockLoginView(number = 1).copy(
username = null,
password = null,
uris = null,
totp = null,
),
)
val result = cipher.toOverflowActions(hasMasterPassword = true, isPremiumUser = false)
assertEquals(
listOf(
ListingItemOverflowAction.VaultAction.ViewClick(cipherId = id),
ListingItemOverflowAction.VaultAction.EditClick(
cipherId = id,
requiresPasswordReprompt = true,
),
),
result,
)
}
@Test
fun `toTrailingIcons should return collection icon if collectionId is not empty`() {
val cipher = createMockCipherView(1).copy(