mirror of
https://github.com/bitwarden/android.git
synced 2025-02-17 04:19:54 +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(
|
fun AddSendContent(
|
||||||
state: AddSendState.ViewState.Content,
|
state: AddSendState.ViewState.Content,
|
||||||
policyDisablesSend: Boolean,
|
policyDisablesSend: Boolean,
|
||||||
|
policySendOptionsInEffect: Boolean,
|
||||||
isAddMode: Boolean,
|
isAddMode: Boolean,
|
||||||
isShared: Boolean,
|
isShared: Boolean,
|
||||||
addSendHandlers: AddSendHandlers,
|
addSendHandlers: AddSendHandlers,
|
||||||
|
@ -85,6 +86,17 @@ fun AddSendContent(
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
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(
|
BitwardenTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.semantics { testTag = "SendNameEntry" }
|
.semantics { testTag = "SendNameEntry" }
|
||||||
|
|
|
@ -198,6 +198,7 @@ fun AddSendScreen(
|
||||||
is AddSendState.ViewState.Content -> AddSendContent(
|
is AddSendState.ViewState.Content -> AddSendContent(
|
||||||
state = viewState,
|
state = viewState,
|
||||||
policyDisablesSend = state.policyDisablesSend,
|
policyDisablesSend = state.policyDisablesSend,
|
||||||
|
policySendOptionsInEffect = state.shouldDisplayPolicyWarning,
|
||||||
isAddMode = state.isAddMode,
|
isAddMode = state.isAddMode,
|
||||||
isShared = state.isShared,
|
isShared = state.isShared,
|
||||||
addSendHandlers = addSendHandlers,
|
addSendHandlers = addSendHandlers,
|
||||||
|
|
|
@ -713,6 +713,13 @@ data class AddSendState(
|
||||||
is AddSendType.EditItem -> R.string.edit_send.asText()
|
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.
|
* Helper to determine if the UI should display the content in add send mode.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -987,6 +987,37 @@ class AddSendScreenTest : BaseComposeTest() {
|
||||||
.assert(hasAnyAncestor(isDialog()))
|
.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 {
|
companion object {
|
||||||
private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common(
|
private val DEFAULT_COMMON_STATE = AddSendState.ViewState.Content.Common(
|
||||||
name = "",
|
name = "",
|
||||||
|
|
Loading…
Add table
Reference in a new issue