mirror of
https://github.com/bitwarden/android.git
synced 2024-11-22 17:36:01 +03:00
BIT-1701 Add the policy notice to the add send screen. (#963)
This commit is contained in:
parent
390411ded7
commit
1334c98b1f
4 changed files with 51 additions and 0 deletions
|
@ -60,6 +60,7 @@ import com.x8bit.bitwarden.ui.tools.feature.send.addsend.handlers.AddSendHandler
|
|||
fun AddSendContent(
|
||||
state: AddSendState.ViewState.Content,
|
||||
policyDisablesSend: Boolean,
|
||||
policySendOptionsInEffect: Boolean,
|
||||
isAddMode: Boolean,
|
||||
isShared: Boolean,
|
||||
addSendHandlers: AddSendHandlers,
|
||||
|
@ -85,6 +86,17 @@ fun AddSendContent(
|
|||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
|
||||
if (policySendOptionsInEffect) {
|
||||
BitwardenPolicyWarningText(
|
||||
text = stringResource(id = R.string.send_options_policy_in_effect),
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp)
|
||||
.fillMaxWidth(),
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
}
|
||||
|
||||
BitwardenTextField(
|
||||
modifier = Modifier
|
||||
.semantics { testTag = "SendNameEntry" }
|
||||
|
|
|
@ -198,6 +198,7 @@ fun AddSendScreen(
|
|||
is AddSendState.ViewState.Content -> AddSendContent(
|
||||
state = viewState,
|
||||
policyDisablesSend = state.policyDisablesSend,
|
||||
policySendOptionsInEffect = state.shouldDisplayPolicyWarning,
|
||||
isAddMode = state.isAddMode,
|
||||
isShared = state.isShared,
|
||||
addSendHandlers = addSendHandlers,
|
||||
|
|
|
@ -713,6 +713,13 @@ data class AddSendState(
|
|||
is AddSendType.EditItem -> R.string.edit_send.asText()
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to determine if the policy notice should be displayed.
|
||||
*/
|
||||
val shouldDisplayPolicyWarning: Boolean
|
||||
get() = !policyDisablesSend &&
|
||||
(viewState as? ViewState.Content)?.common?.isHideEmailAddressEnabled != true
|
||||
|
||||
/**
|
||||
* Helper to determine if the UI should display the content in add send mode.
|
||||
*/
|
||||
|
|
|
@ -987,6 +987,37 @@ class AddSendScreenTest : BaseComposeTest() {
|
|||
.assert(hasAnyAncestor(isDialog()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `policy send options text should be displayed based on state`() {
|
||||
val text = "One or more organization policies are affecting your Send options."
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = DEFAULT_VIEW_STATE,
|
||||
policyDisablesSend = true,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text)
|
||||
.assertIsNotDisplayed()
|
||||
|
||||
mutableStateFlow.update {
|
||||
it.copy(
|
||||
viewState = DEFAULT_VIEW_STATE.copy(
|
||||
common = DEFAULT_COMMON_STATE.copy(
|
||||
isHideEmailAddressEnabled = false,
|
||||
),
|
||||
),
|
||||
policyDisablesSend = false,
|
||||
)
|
||||
}
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text)
|
||||
.assertIsDisplayed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common(
|
||||
name = "",
|
||||
|
|
Loading…
Reference in a new issue