Skip to content

Commit

Permalink
Adds new edit sites button to site picker
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Dec 13, 2024
1 parent 113223d commit 9eeb1e2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,21 @@ class SitePickerFragment :
true
}

R.id.menu_edit_store_list -> {
TODO()
}

else -> false
}
}

override fun onPrepareMenu(menu: Menu) {
menu.findItem(R.id.menu_help).isVisible =
viewModel.sitePickerViewStateData.liveData.value?.isHelpBtnVisible ?: false
viewModel.sitePickerViewStateData.liveData.value?.isHelpBtnVisible == true
menu.findItem(R.id.menu_close_account).isVisible =
viewModel.sitePickerViewStateData.liveData.value?.showCloseAccountMenuItem ?: false
viewModel.sitePickerViewStateData.liveData.value?.showCloseAccountMenuItem == true
menu.findItem(R.id.menu_edit_store_list).isVisible =
viewModel.sitePickerViewStateData.liveData.value?.editStoreListEnabled == true
}

override fun onDestroyView() {
Expand Down Expand Up @@ -197,6 +203,9 @@ class SitePickerFragment :
SimpleWPComState -> updateSimpleWPComView()
}
}
new.editStoreListEnabled.takeIfNotEqualTo(old?.editStoreListEnabled) {
activity?.invalidateMenu()
}
}

viewModel.sites.observe(viewLifecycleOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.woocommerce.android.ui.sitepicker.SitePickerViewModel.SitePickerEvent
import com.woocommerce.android.ui.sitepicker.SitePickerViewModel.SitesListItem.Header
import com.woocommerce.android.ui.sitepicker.SitePickerViewModel.SitesListItem.NonWooSiteUiModel
import com.woocommerce.android.ui.sitepicker.SitePickerViewModel.SitesListItem.WooSiteUiModel
import com.woocommerce.android.util.FeatureFlag
import com.woocommerce.android.util.WooLog
import com.woocommerce.android.viewmodel.LiveDataDelegate
import com.woocommerce.android.viewmodel.MultiLiveEvent
Expand Down Expand Up @@ -242,7 +243,8 @@ class SitePickerViewModel @Inject constructor(
hasConnectedStores = sites.isNotEmpty(),
isPrimaryBtnVisible = wooSites.isNotEmpty(),
isNoStoresViewVisible = false,
currentSitePickerState = SitePickerState.StoreListState
currentSitePickerState = SitePickerState.StoreListState,
editStoreListEnabled = FeatureFlag.HIDE_SITES_FROM_SITE_PICKER.isEnabled() && wooSites.size > 1
)
loginSiteAddress?.let {
processLoginSiteAddress(it)
Expand Down Expand Up @@ -666,7 +668,8 @@ class SitePickerViewModel @Inject constructor(
val isSecondaryBtnVisible: Boolean = false,
val isNoStoresBtnVisible: Boolean = false,
val showCloseAccountMenuItem: Boolean = false,
val currentSitePickerState: SitePickerState = SitePickerState.StoreListState
val currentSitePickerState: SitePickerState = SitePickerState.StoreListState,
val editStoreListEnabled: Boolean = false
) : Parcelable

@Parcelize
Expand Down
6 changes: 6 additions & 0 deletions WooCommerce/src/main/res/menu/menu_site_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@
android:visible="false"
app:showAsAction="never" />

<item
android:id="@+id/menu_edit_store_list"
android:title="@string/site_picker_edit_store_list"
android:visible="false"
app:showAsAction="always" />

</menu>
14 changes: 9 additions & 5 deletions WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,7 @@
<string name="user_role_access_error_link">Learn more about roles and permissions</string>
<string name="user_role_access_error_retry">You don\'t have the correct user role</string>
<string name="user_access_verifying">Verifying role…</string>
<string name="login_site_picker_enter_site_address">Enter a site address</string>
<string name="login_site_picker_add_a_store">Connect another store</string>
<string name="site_discovery_postlogin_failure">A failure occurred, please contact support</string>
<string name="login_site_picker_new_to_woo">New to WooCommerce</string>
<string name="login_simple_wpcom_site">The site %1$s is currently on a WordPress.com plan that does not support plugin installation. Please upgrade your plan to use WooCommerce.</string>
<string name="login_jetpack_connection_verification_failed">Cannot verify your Jetpack connection. Please try again.</string>
<string name="login_jetpack_verify_connection">Verifying Jetpack connection…</string>

Check warning

Code scanning / Android Lint

Unused resources Warning

The resource R.string.login_site_picker_new_to_woo appears to be unused
Expand All @@ -305,8 +302,6 @@
<string name="login_account_mismatch_connect_wpcom_dialog_title">Connecting to a WordPress.com site</string>
<string name="login_account_mismatch_connect_wpcom_dialog_message">Please contact the site owner for an invitation to the site as a shop manager or administrator to use the app.</string>
<string name="login_jetpack_connection_consent">By tapping the Connect Jetpack button, you agree to our &lt;a href=\'terms\'&gt;Terms of Service&lt;/a&gt; and to &lt;a href=\'sync\'&gt;share details&lt;/a&gt; with WordPress.com.</string>
<string name="site_picker_create_new_store">Create a new store</string>
<string name="site_picker_connect_existing_store">Connect an existing store</string>
<string name="login_jetpack_installation_screen_title">Connect store</string>
<string name="login_jetpack_installation_explanation">Please install the free Jetpack plugin to access your store on this app.</string>
<string name="login_jetpack_connection_explanation">Please connect your store to Jetpack to access it on this app.</string>
Expand Down Expand Up @@ -367,6 +362,15 @@
<string name="login_app_login_malformed_link">We couldn\'t process your app login request</string>
<string name="login_jetpack_connection_create_account">If you don\'t have an account, we\'ll use this email to create one.</string>

<!--
Site picker
-->
<string name="login_site_picker_enter_site_address">Enter a site address</string>
<string name="login_site_picker_add_a_store">Connect another store</string>
<string name="site_picker_create_new_store">Create a new store</string>
<string name="site_picker_connect_existing_store">Connect an existing store</string>
<string name="login_site_picker_new_to_woo">New to WooCommerce</string>
<string name="site_picker_edit_store_list">Edit Stores</string>
<!--
My Store View
-->
Expand Down

0 comments on commit 9eeb1e2

Please sign in to comment.