Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self-hosted user UI #21275

Merged
merged 71 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b877d80
First pass at copying users from rs example app
nbradbury Sep 25, 2024
7ecfd02
First pass at user list screen
nbradbury Sep 25, 2024
d51bc76
First pass at user list screen
nbradbury Sep 25, 2024
e2d80b2
Minor tweaks
nbradbury Sep 25, 2024
027adcf
Changed to FeatureConfig
nbradbury Sep 25, 2024
876f567
Use isEnabled
nbradbury Sep 25, 2024
14d6da5
Added activity to manifest
nbradbury Sep 25, 2024
cc4e2c7
Added test account
nbradbury Sep 25, 2024
5c8da51
Updated from prior branch
nbradbury Sep 26, 2024
eb703ed
Fleshed out viewModel and user list screen
nbradbury Sep 26, 2024
05caacf
Fleshed out viewModel and user list screen
nbradbury Sep 26, 2024
5dffecc
Temporarily removed test account data
nbradbury Sep 26, 2024
b6f083e
Added user icon
nbradbury Sep 26, 2024
0d2c70b
Renamed val
nbradbury Sep 26, 2024
09b88e8
Expand sample user list
nbradbury Sep 26, 2024
defb4b1
Mimic existing people layour
nbradbury Sep 26, 2024
6feee8b
Added dividers
nbradbury Sep 26, 2024
0fafc7b
Moved avatar to it's own composable
nbradbury Sep 26, 2024
c9fe06a
Converted to use LazyRow
nbradbury Sep 26, 2024
ba74377
Added even more sample users
nbradbury Sep 27, 2024
a59abb3
Reworked sample users to resolve SonarCloud warnings
nbradbury Sep 27, 2024
d3ef147
Added third sample user with multiple roles
nbradbury Sep 27, 2024
7434664
Merge branch 'trunk' into issue/self-hosted-userlist
nbradbury Sep 27, 2024
9e85e4a
Merge remote-tracking branch 'origin/issue/self-hosted-userlist' into…
nbradbury Sep 27, 2024
16e28ae
Fixed detekt warnings
nbradbury Sep 27, 2024
1e1ba0e
Fixed failing test
nbradbury Sep 27, 2024
fdc882e
Assign unique IDs
nbradbury Sep 27, 2024
80111cb
Added getSampleUserById
nbradbury Sep 27, 2024
a307286
Simplified onCloseClick
nbradbury Sep 27, 2024
10c9a0b
Added onUserClick
nbradbury Sep 27, 2024
2079e24
Refined onUserClick
nbradbury Sep 27, 2024
1f87535
Created UserComposables for re-using Composables
nbradbury Sep 27, 2024
374aeb6
Minor tweaks
nbradbury Sep 27, 2024
224f6ee
Merge branch 'issue/self-hosted-userlist' of https://github.com/wordp…
nbradbury Sep 27, 2024
d5f646b
Resolved conflicts
nbradbury Sep 27, 2024
8b5414c
Reworked self hosted user screen to make future screens easier to add
nbradbury Sep 30, 2024
54469ea
Updated manifest
nbradbury Sep 30, 2024
f87c7b4
Merge branch 'issue/self-hosted-userlist' of https://github.com/wordp…
nbradbury Sep 30, 2024
3835a7b
Added user click event
nbradbury Sep 30, 2024
68d12ee
Handle onUserClick
nbradbury Sep 30, 2024
fc5422d
Use separate close icon for detail, go back to user list when leaving…
nbradbury Sep 30, 2024
4f5adeb
First pass at detail
nbradbury Sep 30, 2024
fb003fb
Second pass at detail
nbradbury Sep 30, 2024
5cc702d
Third pass at detail
nbradbury Sep 30, 2024
ae58458
Merge branch 'trunk' into issue/self-hosted-user-detail
nbradbury Oct 1, 2024
6207191
Added offline view
nbradbury Oct 1, 2024
6355c5e
Added large avatar view
nbradbury Oct 1, 2024
aeab663
Don't handle avatar clicks in list view
nbradbury Oct 1, 2024
e918bf2
Enable scrolling detail screen
nbradbury Oct 2, 2024
282e451
Don't enable scrolling empty list screen
nbradbury Oct 2, 2024
a6d9dec
Merge branch 'issue/self-hosted-user-avatar' of https://github.com/wo…
nbradbury Oct 2, 2024
55be759
Show large avatar when clicked
nbradbury Oct 2, 2024
ef49726
Added comments to view model
nbradbury Oct 2, 2024
8b2f1b3
Moved var
nbradbury Oct 2, 2024
b528d7c
Imported SelfHostedUsersViewModel.SelfHostedUserState to shorten refe…
nbradbury Oct 2, 2024
4f54cbc
Don't pass user to avatar composables
nbradbury Oct 2, 2024
48b4a5b
Simplified empty/offline views
nbradbury Oct 2, 2024
5eed1ac
Simplified modifier on composable Screen
nbradbury Oct 2, 2024
093c07c
Don't handle clicks on empty avatar
nbradbury Oct 2, 2024
7e8dbe4
Make full list row clickable
nbradbury Oct 2, 2024
59585ca
Added comments
nbradbury Oct 3, 2024
1dfd403
Merge branch 'trunk' into issue/self-hosted-user-ui
nbradbury Oct 3, 2024
8564766
Renamed & removed composable functions for better re-usability
nbradbury Oct 3, 2024
c7e3017
Made previews private, added offline preview
nbradbury Oct 3, 2024
0ea0d7e
Make content the last param on ScreenWithTopBar
nbradbury Oct 3, 2024
79e3246
Added crossfade animation
nbradbury Oct 3, 2024
8db998b
Merge branch 'trunk' into issue/self-hosted-user-ui
nbradbury Oct 4, 2024
452106d
Increased crossfade animation duration
nbradbury Oct 4, 2024
5bc4ea5
Fixed logic for showing empty list
nbradbury Oct 4, 2024
2575d0e
Merge branch 'trunk' into issue/self-hosted-user-ui
nbradbury Oct 7, 2024
f53dcf6
Removed avatar from preview
nbradbury Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@
android:label="@string/people"
android:launchMode="singleTop"
android:theme="@style/WordPress.NoActionBar"/>
<activity
android:name=".ui.selfhostedusers.SelfHostedUsersActivity"
android:label="@string/users"
android:launchMode="singleTop"
android:theme="@style/WordPress.NoActionBar"/>

<!--Plugins-->
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
import org.wordpress.android.ui.qrcodeauth.QRCodeAuthActivity;
import org.wordpress.android.ui.reader.ReaderActivityLauncher;
import org.wordpress.android.ui.reader.ReaderConstants;
import org.wordpress.android.ui.selfhostedusers.SelfHostedUsersActivity;
import org.wordpress.android.ui.sitecreation.SiteCreationActivity;
import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource;
import org.wordpress.android.ui.stats.StatsConnectJetpackActivity;
Expand Down Expand Up @@ -724,6 +725,13 @@
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.OPENED_PEOPLE_MANAGEMENT, site);
}

public static void viewSelfHostedUsers(Context context, SiteModel site) {

Check notice

Code scanning / Android Lint

Nullable/NonNull annotation missing on method parameter Note

Missing null annotation

Check notice

Code scanning / Android Lint

Nullable/NonNull annotation missing on method parameter Note

Missing null annotation
// TODO tracks
Intent intent = new Intent(context, SelfHostedUsersActivity.class);
intent.putExtra(WordPress.SITE, site);
context.startActivity(intent);
}

public static void viewPluginBrowser(Context context, SiteModel site) {
if (PluginUtils.isPluginFeatureAvailable(site)) {
AnalyticsUtils.trackWithSiteDetails(AnalyticsTracker.Stat.OPENED_PLUGIN_DIRECTORY, site);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,12 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment),
action.isNewSite
)
is SiteNavigationAction.OpenAdmin -> ActivityLauncher.viewBlogAdmin(activity, action.site)
is SiteNavigationAction.OpenPeople -> ActivityLauncher.viewCurrentBlogPeople(activity, action.site)
is SiteNavigationAction.OpenPeople -> {
ActivityLauncher.viewCurrentBlogPeople(activity, action.site)
}
is SiteNavigationAction.OpenSelfHostedUsers -> {
ActivityLauncher.viewSelfHostedUsers(activity, action.site)
}
is SiteNavigationAction.OpenSharing -> ActivityLauncher.viewBlogSharing(activity, action.site)
is SiteNavigationAction.OpenSiteSettings -> ActivityLauncher.viewBlogSettingsForResult(activity, action.site)
is SiteNavigationAction.OpenThemes -> ActivityLauncher.viewCurrentBlogThemes(activity, action.site)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ sealed class SiteNavigationAction {

data class OpenAdmin(val site: SiteModel) : SiteNavigationAction()
data class OpenPeople(val site: SiteModel) : SiteNavigationAction()
data class OpenSelfHostedUsers(val site: SiteModel) : SiteNavigationAction()
data class OpenSharing(val site: SiteModel) : SiteNavigationAction()
data class OpenDomains(val site: SiteModel) : SiteNavigationAction()
data class OpenSiteSettings(val site: SiteModel) : SiteNavigationAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ListItemActionHandler @Inject constructor(
ListItemAction.PAGES -> SiteNavigationAction.OpenPages(selectedSite)
ListItemAction.ADMIN -> SiteNavigationAction.OpenAdmin(selectedSite)
ListItemAction.PEOPLE -> SiteNavigationAction.OpenPeople(selectedSite)
ListItemAction.SELF_HOSTED_USERS -> SiteNavigationAction.OpenSelfHostedUsers(selectedSite)
ListItemAction.SHARING -> SiteNavigationAction.OpenSharing(selectedSite)
ListItemAction.DOMAINS -> SiteNavigationAction.OpenDomains(selectedSite)
ListItemAction.ME -> SiteNavigationAction.OpenMeScreen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ enum class ListItemAction (val trackingLabel: String) {
PAGES("pages"),
ADMIN("admin"),
PEOPLE("people"),
SELF_HOSTED_USERS("self_hosted_users"),
SHARING("sharing"),
DOMAINS("domains"),
SITE_SETTINGS("site_settings"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class SiteItemsBuilder @Inject constructor(
return if (!jetpackFeatureRemovalOverlayUtil.shouldHideJetpackFeatures()) {
listOfNotNull(
siteListItemBuilder.buildPeopleItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildSelfHostedUserListItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildPluginItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildShareItemIfAvailable(
params.site,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.PEOPLE
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.PLAN
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.PLUGINS
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.SCAN
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.SELF_HOSTED_USERS
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.SHARING
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.SITE_SETTINGS
import org.wordpress.android.ui.mysite.items.listitem.ListItemAction.THEMES
Expand All @@ -29,6 +30,7 @@ import org.wordpress.android.ui.utils.UiString.UiStringText
import org.wordpress.android.util.BuildConfigWrapper
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.SiteUtilsWrapper
import org.wordpress.android.util.config.SelfHostedUsersFeatureConfig
import org.wordpress.android.util.config.SiteMonitoringFeatureConfig
import java.util.GregorianCalendar
import java.util.TimeZone
Expand All @@ -41,7 +43,8 @@ class SiteListItemBuilder @Inject constructor(
private val buildConfigWrapper: BuildConfigWrapper,
private val themeBrowserUtils: ThemeBrowserUtils,
private val jetpackFeatureRemovalPhaseHelper: JetpackFeatureRemovalPhaseHelper,
private val siteMonitoringFeatureConfig: SiteMonitoringFeatureConfig
private val siteMonitoringFeatureConfig: SiteMonitoringFeatureConfig,
private val selfHostedUsersFeatureConfig: SelfHostedUsersFeatureConfig,
) {
fun buildActivityLogItemIfAvailable(site: SiteModel, onClick: (ListItemAction) -> Unit): ListItem? {
val isWpComOrJetpack = siteUtilsWrapper.isAccessedViaWPComRest(
Expand Down Expand Up @@ -138,6 +141,20 @@ class SiteListItemBuilder @Inject constructor(
onClick = ListItemInteraction.create(PEOPLE, onClick),
listItemAction = PEOPLE
)
} else {
null
}
}

fun buildSelfHostedUserListItemIfAvailable(site: SiteModel, onClick: (ListItemAction) -> Unit): ListItem? {
dcalhoun marked this conversation as resolved.
Show resolved Hide resolved
// TODO Should this excluded JetPack users?
return if (selfHostedUsersFeatureConfig.isEnabled() && site.selfHostedSiteId > 0) {
ListItem(
R.drawable.ic_user_white_24dp,
UiStringRes(R.string.users),
onClick = ListItemInteraction.create(SELF_HOSTED_USERS, onClick),
listItemAction = SELF_HOSTED_USERS
)
} else null
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package org.wordpress.android.ui.selfhostedusers

import uniffi.wp_api.UserWithEditContext

/**
* This is a temporary object to supply a list of users for the self-hosted user list.
* It will be removed once the network request to retrieve users is implemented.
*/
@Suppress("MaxLineLength")
object SampleUsers {
private val sampleUserList = ArrayList<UserWithEditContext>()

private val sampleUser1 = UserWithEditContext(
id = 1,
username = "@sampleUser",
avatarUrls = emptyMap(),
capabilities = emptyMap(),
email = "[email protected]",
extraCapabilities = emptyMap(),
firstName = "Sample",
lastName = "User",
link = "example.com",
locale = "en-US",
name = "Sample User",
nickname = "User nickname",
registeredDate = "2023-01-01",
roles = listOf("admin"),
slug = "sample-user",
url = "example.com",
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam non quam viverra, viverra est vel, interdum felis. Pellentesque interdum libero quis metus pharetra ullamcorper. Morbi nec libero ligula. Quisque consectetur, purus sit amet lobortis porttitor, ligula ex imperdiet massa, in ullamcorper augue odio sit amet metus. In sollicitudin mauris et risus mollis commodo. Aliquam vel vehicula ante, nec blandit erat. Aenean non turpis porttitor orci fringilla fringilla nec ac nunc. Nulla ultrices urna ut ipsum posuere blandit. Phasellus mauris nulla, tincidunt at leo at, auctor interdum felis. Sed pharetra risus a ullamcorper dictum. Suspendisse pharetra justo molestie risus lobortis facilisis.",
)

// TODO remove the avatar url
private val sampleUser2 = UserWithEditContext(
id = 2,
username = "@sampleUserWithALongUserName",
avatarUrls = mapOf("sampleUserTwo" to "https://nickbradbury.com/wp-content/uploads/2022/03/1394-2.jpg"),
capabilities = emptyMap(),
description = "User description",
email = "[email protected]",
extraCapabilities = emptyMap(),
firstName = "Sample",
lastName = "User",
link = "example.com",
locale = "en-US",
name = "Sample User",
nickname = "User nickname",
registeredDate = "2023-01-01",
roles = listOf("contributor"),
slug = "sample-user",
url = "example.com",
)

private val sampleUser3 = UserWithEditContext(
id = 3,
username = "@sampleUser",
avatarUrls = emptyMap(),
capabilities = emptyMap(),
description = "User description",
email = "[email protected]",
extraCapabilities = emptyMap(),
firstName = "Sample",
lastName = "User",
link = "example.com",
locale = "en-US",
name = "Sample User",
nickname = "User nickname",
registeredDate = "2023-01-01",
roles = listOf("contributor", "editor", "subscriber"),
slug = "sample-user",
url = "example.com",
)

@Suppress("MagicNumber")
fun getSampleUsers(): ArrayList<UserWithEditContext> {
fun addWithId(user: UserWithEditContext) {
sampleUserList.add(
user.copy(id = sampleUserList.size)
)
}
if (sampleUserList.isEmpty()) {
repeat(25) {
addWithId(sampleUser1)
addWithId(sampleUser2)
addWithId(sampleUser3)
}
}
return sampleUserList
}
}
Loading
Loading