Skip to content

Commit

Permalink
[PM-15149] Remove ssh feature flag (#4761)
Browse files Browse the repository at this point in the history
  • Loading branch information
quexten authored Feb 25, 2025
1 parent 30a1bba commit 675cbb7
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 236 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ sealed class FlagKey<out T : Any> {
OnboardingFlow,
OnboardingCarousel,
ImportLoginsFlow,
SshKeyCipherItems,
VerifiedSsoDomainEndpoint,
CredentialExchangeProtocolImport,
CredentialExchangeProtocolExport,
Expand Down Expand Up @@ -94,15 +93,6 @@ sealed class FlagKey<out T : Any> {
override val isRemotelyConfigured: Boolean = true
}

/**
* Data object holding the feature flag key for the SSH key cipher items feature.
*/
data object SshKeyCipherItems : FlagKey<Boolean>() {
override val keyName: String = "ssh-key-vault-item"
override val defaultValue: Boolean = false
override val isRemotelyConfigured: Boolean = true
}

/**
* Data object holding the feature flag key for the new verified SSO domain endpoint feature.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ fun <T : Any> FlagKey<T>.ListItemContent(
FlagKey.OnboardingCarousel,
FlagKey.OnboardingFlow,
FlagKey.ImportLoginsFlow,
FlagKey.SshKeyCipherItems,
FlagKey.VerifiedSsoDomainEndpoint,
FlagKey.CredentialExchangeProtocolImport,
FlagKey.CredentialExchangeProtocolExport,
Expand Down Expand Up @@ -87,7 +86,6 @@ private fun <T : Any> FlagKey<T>.getDisplayLabel(): String = when (this) {
FlagKey.OnboardingCarousel -> stringResource(R.string.onboarding_carousel)
FlagKey.OnboardingFlow -> stringResource(R.string.onboarding_flow)
FlagKey.ImportLoginsFlow -> stringResource(R.string.import_logins_flow)
FlagKey.SshKeyCipherItems -> stringResource(R.string.ssh_key_cipher_item_types)
FlagKey.VerifiedSsoDomainEndpoint -> stringResource(R.string.verified_sso_domain_verified)
FlagKey.CredentialExchangeProtocolImport -> stringResource(R.string.cxp_import)
FlagKey.CredentialExchangeProtocolExport -> stringResource(R.string.cxp_export)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ fun VaultContent(
state: VaultState.ViewState.Content,
vaultHandlers: VaultHandlers,
onOverflowOptionClick: (action: ListingItemOverflowAction.VaultAction) -> Unit,
showSshKeys: Boolean,
modifier: Modifier = Modifier,
) {
LazyColumn(
Expand Down Expand Up @@ -192,34 +191,28 @@ fun VaultContent(
supportingLabel = state.secureNoteItemsCount.toString(),
onClick = vaultHandlers.secureNoteGroupClick,
showDivider = false,
cardStyle = if (showSshKeys) {
CardStyle.Middle(dividerPadding = 56.dp)
} else {
CardStyle.Bottom
},
cardStyle = CardStyle.Middle(dividerPadding = 56.dp),
modifier = Modifier
.fillMaxWidth()
.testTag("SecureNoteFilter")
.standardHorizontalMargin(),
)
}

if (showSshKeys) {
item {
BitwardenGroupItem(
startIcon = rememberVectorPainter(id = R.drawable.ic_ssh_key),
startIconTestTag = "SshKeyCipherIcon",
label = stringResource(id = R.string.type_ssh_key),
supportingLabel = state.sshKeyItemsCount.toString(),
onClick = vaultHandlers.sshKeyGroupClick,
showDivider = false,
cardStyle = CardStyle.Bottom,
modifier = Modifier
.fillMaxWidth()
.testTag("SshKeyFilter")
.standardHorizontalMargin(),
)
}
item {
BitwardenGroupItem(
startIcon = rememberVectorPainter(id = R.drawable.ic_ssh_key),
startIconTestTag = "SshKeyCipherIcon",
label = stringResource(id = R.string.type_ssh_key),
supportingLabel = state.sshKeyItemsCount.toString(),
onClick = vaultHandlers.sshKeyGroupClick,
showDivider = false,
cardStyle = CardStyle.Bottom,
modifier = Modifier
.fillMaxWidth()
.testTag("SshKeyFilter")
.standardHorizontalMargin(),
)
}

item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,6 @@ private fun VaultScreenScaffold(
when (val viewState = state.viewState) {
is VaultState.ViewState.Content -> VaultContent(
state = viewState,
showSshKeys = state.showSshKeys,
vaultHandlers = vaultHandlers,
onOverflowOptionClick = { masterPasswordRepromptAction = it },
modifier = Modifier.fillMaxSize(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class VaultViewModel @Inject constructor(
.any(),
)
val appBarTitle = vaultFilterData.toAppBarTitle()
val showSshKeys = featureFlagManager.getFeatureFlag(FlagKey.SshKeyCipherItems)
VaultState(
appBarTitle = appBarTitle,
initials = activeAccountSummary.initials,
Expand All @@ -113,7 +112,6 @@ class VaultViewModel @Inject constructor(
hasMasterPassword = userState.activeAccount.hasMasterPassword,
isRefreshing = false,
showImportActionCard = false,
showSshKeys = showSshKeys,
)
},
) {
Expand Down Expand Up @@ -141,15 +139,9 @@ class VaultViewModel @Inject constructor(
.onEach(::sendAction)
.launchIn(viewModelScope)

combine(
vaultRepository.vaultDataStateFlow,
featureFlagManager.getFeatureFlagFlow(FlagKey.SshKeyCipherItems),
) { vaultData, sshKeyCipherItemsEnabled ->
VaultAction.Internal.VaultDataReceive(
vaultData = vaultData,
showSshKeys = sshKeyCipherItemsEnabled,
)
}
vaultRepository
.vaultDataStateFlow
.map { VaultAction.Internal.VaultDataReceive(it) }
.onEach(::sendAction)
.launchIn(viewModelScope)

Expand Down Expand Up @@ -266,7 +258,6 @@ class VaultViewModel @Inject constructor(

updateViewState(
vaultData = vaultRepository.vaultDataStateFlow.value,
showSshKeys = state.showSshKeys,
)
}

Expand Down Expand Up @@ -405,7 +396,6 @@ class VaultViewModel @Inject constructor(
// Re-process the current vault data with the new filter
updateViewState(
vaultData = vaultRepository.vaultDataStateFlow.value,
showSshKeys = state.showSshKeys,
)
}

Expand Down Expand Up @@ -694,22 +684,19 @@ class VaultViewModel @Inject constructor(

updateViewState(
vaultData = action.vaultData,
showSshKeys = action.showSshKeys,
)
}

private fun updateViewState(vaultData: DataState<VaultData>, showSshKeys: Boolean) {
private fun updateViewState(vaultData: DataState<VaultData>) {
when (vaultData) {
is DataState.Error -> vaultErrorReceive(vaultData = vaultData)
is DataState.Loaded -> vaultLoadedReceive(
vaultData = vaultData,
showSshKeys = showSshKeys,
)

is DataState.Loading -> vaultLoadingReceive()
is DataState.NoNetwork -> vaultNoNetworkReceive(
vaultData = vaultData,
showSshKeys = showSshKeys,
)

is DataState.Pending -> vaultPendingReceive(vaultData = vaultData)
Expand All @@ -730,20 +717,19 @@ class VaultViewModel @Inject constructor(
)
}

private fun vaultLoadedReceive(vaultData: DataState.Loaded<VaultData>, showSshKeys: Boolean) {
private fun vaultLoadedReceive(vaultData: DataState.Loaded<VaultData>) {
if (state.dialog == VaultState.DialogState.Syncing) {
sendEvent(
VaultEvent.ShowToast(
message = R.string.syncing_complete.asText(),
),
)
}
updateVaultState(vaultData.data, showSshKeys)
updateVaultState(vaultData.data)
}

private fun updateVaultState(
vaultData: VaultData,
showSshKeys: Boolean,
) {
mutableStateFlow.update {
it.copy(
Expand All @@ -753,11 +739,9 @@ class VaultViewModel @Inject constructor(
isPremium = state.isPremium,
hasMasterPassword = state.hasMasterPassword,
vaultFilterType = vaultFilterTypeOrDefault,
showSshKeys = showSshKeys,
),
dialog = null,
isRefreshing = false,
showSshKeys = showSshKeys,
)
}
}
Expand All @@ -768,7 +752,6 @@ class VaultViewModel @Inject constructor(

private fun vaultNoNetworkReceive(
vaultData: DataState.NoNetwork<VaultData>,
showSshKeys: Boolean,
) {
val data = vaultData.data ?: VaultData(
cipherViewList = emptyList(),
Expand All @@ -778,7 +761,6 @@ class VaultViewModel @Inject constructor(
)
updateVaultState(
vaultData = data,
showSshKeys = showSshKeys,
)
}

Expand All @@ -791,7 +773,6 @@ class VaultViewModel @Inject constructor(
isPremium = state.isPremium,
hasMasterPassword = state.hasMasterPassword,
vaultFilterType = vaultFilterTypeOrDefault,
showSshKeys = state.showSshKeys,
),
)
}
Expand Down Expand Up @@ -862,7 +843,6 @@ data class VaultState(
val isIconLoadingDisabled: Boolean,
val isRefreshing: Boolean,
val showImportActionCard: Boolean,
val showSshKeys: Boolean,
) : Parcelable {

/**
Expand Down Expand Up @@ -1486,7 +1466,6 @@ sealed class VaultAction {
*/
data class VaultDataReceive(
val vaultData: DataState<VaultData>,
val showSshKeys: Boolean,
) : Internal()

/**
Expand Down Expand Up @@ -1527,7 +1506,6 @@ private fun MutableStateFlow<VaultState>.updateToErrorStateOrDialog(
hasMasterPassword = hasMasterPassword,
vaultFilterType = vaultFilterType,
isIconLoadingDisabled = isIconLoadingDisabled,
showSshKeys = it.showSshKeys,
),
dialog = VaultState.DialogState.Error(
title = errorTitle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ fun VaultData.toViewState(
isIconLoadingDisabled: Boolean,
baseIconUrl: String,
vaultFilterType: VaultFilterType,
showSshKeys: Boolean,
): VaultState.ViewState {

val filteredCipherViewListWithDeletedItems =
cipherViewList.toFilteredList(vaultFilterType)

val filteredCipherViewList = filteredCipherViewListWithDeletedItems
.filter { it.deletedDate == null }
.filterSshKeysIfNecessary(showSshKeys)

val filteredFolderViewList = folderViewList
.toFilteredList(
Expand All @@ -63,12 +61,7 @@ fun VaultData.toViewState(
val noFolderItems = filteredCipherViewList
.filter { it.folderId.isNullOrBlank() }

val itemTypesCount: Int = if (showSshKeys) {
CipherType.entries
} else {
CipherType.entries.filterNot { it == CipherType.SSH_KEY }
}
.size
val itemTypesCount: Int = CipherType.entries.size

return if (filteredCipherViewListWithDeletedItems.isEmpty()) {
VaultState.ViewState.NoItems
Expand Down Expand Up @@ -355,16 +348,3 @@ fun List<CollectionView>.toFilteredList(
}
}
}

/**
* Filters out all [CipherView]s that are of type [CipherType.SSH_KEY] if [showSshKeys] is false.
*
* @param showSshKeys Whether to show SSH keys in the vault.
*/
@JvmName("filterSshKeysIfNecessary")
fun List<CipherView>.filterSshKeysIfNecessary(showSshKeys: Boolean): List<CipherView> =
if (showSshKeys) {
this
} else {
filter { it.type != CipherType.SSH_KEY }
}
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,6 @@ Do you want to switch to this account?</string>
<string name="save_the_exported_file_somewhere_on_your_computer_you_can_find_easily"><annotation emphasis="bold">Save the exported file</annotation> somewhere on your computer you can find easily.</string>
<string name="this_is_not_a_recognized_bitwarden_server_you_may_need_to_check_with_your_provider_or_update_your_server">This is not a recognized Bitwarden server. You may need to check with your provider or update your server.</string>
<string name="syncing_logins_loading_message">Syncing logins...</string>
<string name="ssh_key_cipher_item_types">SSH Key Cipher Item Types</string>
<string name="download_the_browser_extension">Download the browser extension</string>
<string name="go_to_bitwarden_com_download_to_integrate_bitwarden_into_browser">Go to bitwarden.com/download to integrate Bitwarden into your favorite browser for a seamless experience.</string>
<string name="use_the_web_app">Use the web app</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ class FlagKeyTest {
FlagKey.ImportLoginsFlow.keyName,
"import-logins-flow",
)
assertEquals(
FlagKey.SshKeyCipherItems.keyName,
"ssh-key-vault-item",
)
assertEquals(
FlagKey.VerifiedSsoDomainEndpoint.keyName,
"pm-12337-refactor-sso-details-endpoint",
Expand Down Expand Up @@ -96,7 +92,6 @@ class FlagKeyTest {
FlagKey.OnboardingCarousel,
FlagKey.OnboardingFlow,
FlagKey.ImportLoginsFlow,
FlagKey.SshKeyCipherItems,
FlagKey.VerifiedSsoDomainEndpoint,
FlagKey.CredentialExchangeProtocolImport,
FlagKey.CredentialExchangeProtocolExport,
Expand Down Expand Up @@ -124,7 +119,6 @@ class FlagKeyTest {
FlagKey.OnboardingCarousel,
FlagKey.OnboardingFlow,
FlagKey.ImportLoginsFlow,
FlagKey.SshKeyCipherItems,
FlagKey.VerifiedSsoDomainEndpoint,
FlagKey.CredentialExchangeProtocolImport,
FlagKey.CredentialExchangeProtocolExport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ private val DEFAULT_MAP_VALUE: Map<FlagKey<Any>, Any> = mapOf(
FlagKey.OnboardingCarousel to true,
FlagKey.OnboardingFlow to true,
FlagKey.ImportLoginsFlow to true,
FlagKey.SshKeyCipherItems to true,
FlagKey.VerifiedSsoDomainEndpoint to true,
FlagKey.CredentialExchangeProtocolImport to true,
FlagKey.CredentialExchangeProtocolExport to true,
Expand All @@ -145,7 +144,6 @@ private val UPDATED_MAP_VALUE: Map<FlagKey<Any>, Any> = mapOf(
FlagKey.OnboardingCarousel to true,
FlagKey.OnboardingFlow to false,
FlagKey.ImportLoginsFlow to false,
FlagKey.SshKeyCipherItems to false,
FlagKey.VerifiedSsoDomainEndpoint to false,
FlagKey.CredentialExchangeProtocolImport to false,
FlagKey.CredentialExchangeProtocolExport to false,
Expand Down
Loading

0 comments on commit 675cbb7

Please sign in to comment.