PM-43342, PM-43343, PM-43373: bug: Hide copy and share options from disabled Send (#7377)

This commit is contained in:
David Perez authored and GitHub committed 2026-09-11 14:03:54 +00:00
1 parent 74c0e04bc7
commit 8cc022daf5
4 files changed
+60 -42

No files matched your search

@@ -39,19 +39,17 @@ fun SendView.toOverflowActions(
this
.id
?.let { sendId ->
val sendUrl = toSendUrl(baseWebSendUrl = baseWebSendUrl)
listOfNotNull(
ListingItemOverflowAction.SendAction.CopyUrlClick(
sendUrl = toSendUrl(baseWebSendUrl = baseWebSendUrl),
),
ListingItemOverflowAction.SendAction.ShareUrlClick(
sendUrl = toSendUrl(baseWebSendUrl = baseWebSendUrl),
),
ListingItemOverflowAction.SendAction.CopyUrlClick(sendUrl = sendUrl)
.takeUnless { this.disabled },
ListingItemOverflowAction.SendAction.ShareUrlClick(sendUrl = sendUrl)
.takeUnless { this.disabled },
ListingItemOverflowAction.SendAction.ViewClick(sendId = sendId, sendType = type),
ListingItemOverflowAction.SendAction.EditClick(sendId = sendId, sendType = type)
.takeUnless { this.disabled },
ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = sendId).takeIf {
hasPassword
},
ListingItemOverflowAction.SendAction.RemovePasswordClick(sendId = sendId)
.takeIf { this.hasPassword && !this.disabled },
ListingItemOverflowAction.SendAction.DeleteClick(sendId = sendId),
)
}
@@ -212,6 +212,7 @@ private fun ViewSendScreenContent(
ViewStateContent(
state = viewState,
policyRestriction = state.policyRestriction,
isSendDisabled = state.isSendDisabled,
onCopyClick = onCopyClick,
onCopyNotesClick = onCopyNotesClick,
onDeleteClick = onDeleteClick,
@@ -239,6 +240,7 @@ private fun ViewSendScreenContent(
private fun ViewStateContent(
state: ViewSendState.ViewState.Content,
policyRestriction: SendPolicyRestriction?,
isSendDisabled: Boolean,
onCopyClick: () -> Unit,
onCopyNotesClick: () -> Unit,
onDeleteClick: () -> Unit,
@@ -273,37 +275,39 @@ private fun ViewStateContent(
)
Spacer(modifier = Modifier.height(height = 16.dp))
}
ShareLinkSection(
shareLink = state.shareLink,
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin(),
)
BitwardenFilledButton(
label = stringResource(id = BitwardenString.copy),
onClick = onCopyClick,
icon = rememberVectorPainter(id = BitwardenDrawable.ic_copy_small),
cardStyle = CardStyle.Middle(hasDivider = false),
cardInsets = PaddingValues(top = 16.dp, bottom = 6.dp, start = 16.dp, end = 16.dp),
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin()
.testTag(tag = "ViewSendCopyButton"),
)
BitwardenOutlinedButton(
label = stringResource(id = BitwardenString.share),
onClick = onShareClick,
icon = rememberVectorPainter(id = BitwardenDrawable.ic_share_small),
isExternalLink = true,
cardStyle = CardStyle.Bottom,
cardInsets = PaddingValues(top = 6.dp, bottom = 16.dp, start = 16.dp, end = 16.dp),
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin()
.testTag(tag = "ViewSendShareButton"),
)
if (!isSendDisabled) {
ShareLinkSection(
shareLink = state.shareLink,
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin(),
)
BitwardenFilledButton(
label = stringResource(id = BitwardenString.copy),
onClick = onCopyClick,
icon = rememberVectorPainter(id = BitwardenDrawable.ic_copy_small),
cardStyle = CardStyle.Middle(hasDivider = false),
cardInsets = PaddingValues(top = 16.dp, bottom = 6.dp, start = 16.dp, end = 16.dp),
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin()
.testTag(tag = "ViewSendCopyButton"),
)
BitwardenOutlinedButton(
label = stringResource(id = BitwardenString.share),
onClick = onShareClick,
icon = rememberVectorPainter(id = BitwardenDrawable.ic_share_small),
isExternalLink = true,
cardStyle = CardStyle.Bottom,
cardInsets = PaddingValues(top = 6.dp, bottom = 16.dp, start = 16.dp, end = 16.dp),
modifier = Modifier
.fillMaxWidth()
.standardHorizontalMargin()
.testTag(tag = "ViewSendShareButton"),
)
Spacer(modifier = Modifier.height(height = 16.dp))
}
Spacer(modifier = Modifier.height(height = 16.dp))
BitwardenListHeaderText(
label = stringResource(id = BitwardenString.send_details),
modifier = Modifier
@@ -103,11 +103,11 @@ class SendViewExtensionsTest {
@Suppress("MaxLineLength")
@Test
fun `toOverflowActions should return overflow options without Edit when the send is disabled`() {
fun `toOverflowActions should return overflow options without Copy, Share, Edit, and RemovePassword when the send is disabled`() {
val baseWebSendUrl = "www.test.com"
val sendView = createMockSendView(
number = 1,
// Make sure the send is disabled to remove the edit action
// Make sure the Send is disabled to remove the edit action
disabled = true,
)
@@ -115,7 +115,10 @@ class SendViewExtensionsTest {
assertEquals(
ALL_SEND_OVERFLOW_OPTIONS.filter {
it !is ListingItemOverflowAction.SendAction.EditClick
it !is ListingItemOverflowAction.SendAction.CopyUrlClick &&
it !is ListingItemOverflowAction.SendAction.ShareUrlClick &&
it !is ListingItemOverflowAction.SendAction.EditClick &&
it !is ListingItemOverflowAction.SendAction.RemovePasswordClick
},
result,
)
@@ -446,6 +446,19 @@ class ViewSendScreenTest : BitwardenComposeTest() {
.assertIsDisplayed()
}
@Test
fun `copy, share, and send link should be hidden when the send is disabled`() {
composeTestRule.onNodeWithText(text = "Copy").performScrollTo().assertIsDisplayed()
composeTestRule.onNodeWithText(text = "Share").performScrollTo().assertIsDisplayed()
composeTestRule.onNodeWithText(text = "Send link").performScrollTo().assertIsDisplayed()
mutableStateFlow.update { it.copy(isSendDisabled = true) }
composeTestRule.onNodeWithText(text = "Copy").assertDoesNotExist()
composeTestRule.onNodeWithText(text = "Share").assertDoesNotExist()
composeTestRule.onNodeWithText(text = "Send link").assertDoesNotExist()
}
@Test
fun `on copy notes click should send CopyNotesClick`() {
composeTestRule