Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun CipherView.toOverflowActions(
cipherId = cipherId,
requiresPasswordReprompt = hasMasterPassword,
)
.takeUnless { this.deletedDate != null },
.takeUnless { this.deletedDate != null || !this.edit },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanna add a test for this in CipherViewExtensionsTest

this.login?.username?.let {
ListingItemOverflowAction.VaultAction.CopyUsernameClick(username = it)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down