Skip to content

Jetpack Mobile: Scan menu#13555

Merged
malinajirka merged 15 commits intodevelopfrom
issue/13326-scan-menu
Dec 17, 2020
Merged

Jetpack Mobile: Scan menu#13555
malinajirka merged 15 commits intodevelopfrom
issue/13326-scan-menu

Conversation

@ashiagr
Copy link
Copy Markdown
Contributor

@ashiagr ashiagr commented Dec 7, 2020

Parent #13326

It displays scan menu on My Site for sites with scan capability for a user.

To test

Prerequisite: Make sure both Scan feature flag and MySiteImprovements flag are set to on in the App settings.
(Changes applied only to MySiteImprovements flow)

Test that scan menu is shown on My Site only when the user has scan feature unlocked.

My Site Scan Menu
screnshot
Case Site Type Login Type Sub Type   User Role Show Scan Scan State API Response (Reason)
1a .com   simple unavailable (wpcom_site)
1b     atomic admin available - idle or scanning
1c       non admin error (authorization_required)
2a Jetpack wp.com login plan without scan feature unavailable (missing_scan_capability)
2b     plan with scan feature admin available - idle or scanning
2c       non admin error (authorization_required)
2d   self-hosted login plan without scan feature  error (authorization_required)
2e     plan with scan feature   error (authorization_required)

Questions

2d, 2e - Scan state rest API gives authorization_required error for self-hosted login for a Jetpack site. Should we always display scan menu via this flow? - Answered in #13555 (comment)

Not in scope
Scan menu icon fine-tuning
Click action

PR submission checklist:

  • I have considered adding unit tests where possible.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Currently used to fetch or get site's scan state from the ScanStore.
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
#	WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Dec 7, 2020

You can trigger optional UI/connected tests for these changes by visiting CircleCI here.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Dec 7, 2020

You can test the changes on this Pull Request by downloading the APK here.

@ashiagr ashiagr mentioned this pull request Dec 8, 2020
67 tasks
@ashiagr ashiagr requested review from malinajirka and zwarm December 8, 2020 06:21
@malinajirka
Copy link
Copy Markdown
Contributor

Scan state rest API gives authorization_required error for self-hosted login for a Jetpack site. Should we always display scan menu via this flow?

Great question! I'd consider asking this question on slack and share the summary of our discussion here. I'd personally vote for making a consistent change across all the jetpack features within the app. We might want to always redirect the user to the .com login flow when they access a jetpack feature and they are using a self-hosted login (if we are sure the site has jetpack installed). If the site doesn't have jetpack installed it's a bit more tricky, but I think it's a different discussion.

@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 8, 2020

Summary of our discussion from Slack:

2d, 2f - Since scan is accessible only with a paid plan and we don’t know what plan users are on if they're are not using wp.com login, we should keep scan menu hidden on My Site for self-hosted login.

Updated the table in the description.

@ashiagr ashiagr marked this pull request as ready for review December 8, 2020 13:48
@ashiagr ashiagr added this to the 16.4 milestone Dec 8, 2020
# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
#	WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
#	build.gradle
@ashiagr ashiagr modified the milestones: 16.4, 16.5 Dec 10, 2020
@malinajirka malinajirka self-assigned this Dec 15, 2020
@malinajirka malinajirka removed the request for review from zwarm December 15, 2020 08:49
@malinajirka
Copy link
Copy Markdown
Contributor

malinajirka commented Dec 15, 2020

Thanks @ashiagr for working on this PR. Sorry I didn't review it sooner. I marked the notification as read so it slipped through my filters.

I have a couple of points for discussion. I'm not sure which approach is better but I thought I'd share my thoughts.

💡 I'm wondering if we need a service for this task.

  • It's a simple one time request
  • Stateful singletons are imo always a bit tricky to work with
  • It seems the start() initiates the request, but when the request finishes the service doesn't do anything else, right? Until someone calls stop and start again?
  • Do we need start/stop methods? Have you considered passing the scope from the caller?
    To summarize: I'm a bit worried it might be an overkill, but I might be missing something crucial. Wdyt?

Update: This comment is related to this discussion. Let's continue the discussion there and come back here when we decide on an approach.

@malinajirka
Copy link
Copy Markdown
Contributor

malinajirka commented Dec 15, 2020

Thanks @ashiagr! As we discussed on the call you can ignore the above comment. I didn't realize the RewindStatusService uses this approach. I agree we should keep them consistent and refactor all of them later.

I tested all the cases described above and I noticed a possible issue.

When I

  1. select a site (plan with scan feature | admin)
  2. Go to web in the browser and remove admin privileges to the user
  3. Go back to the app and notice scan is still visible (expected)
  4. Click on switch site
  5. Select a different site
  6. Click on switch site
  7. Select site from step 1
  8. Notice the scan is still visible even though the API response is "{"code":"authorization_required","message":"Can't query information about the current state.","data":{"status":401}}"

There is also a version conflict with develop.

# Conflicts:
#	WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt
#	WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt
@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 16, 2020

I tested all the cases described above and I noticed a possible issue.

Great catch ! Fixed in 0603320. Also included unit test for it.
Since we don't update db on error, scan menu will be displayed briefly for scenarios like these (as it first displays last state in the db) before the request to get availability status fails. Is that ok?

@malinajirka
Copy link
Copy Markdown
Contributor

malinajirka commented Dec 16, 2020

Also included unit test for it.

❤️

Since we don't update db on error, scan menu will be displayed briefly for scenarios like these (as it first displays last state in the db) before the request to get availability status fails. Is that ok?

I think it'd be fine if we showed the "Scan" item once after you switch to the site. However, I noticed I can see the animation every time I select the site. It's not a huge issue, but feels weird. Could we perhaps delete the item from the database on Authorization Error?

@ashiagr
Copy link
Copy Markdown
Contributor Author

ashiagr commented Dec 17, 2020

Could we perhaps delete the item from the database on Authorization Error?

Yes I think we can do that. Added to backlog (#13326) as it will require fluxc changes:

Delete scan state from the database on Authorization Error

I'll link it here once it is done.

Can we merge this one as we've other PRs ready to merged built upon this one?

Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, thank you! ;)

@malinajirka malinajirka merged commit 0d3c6bd into develop Dec 17, 2020
@malinajirka malinajirka deleted the issue/13326-scan-menu branch December 17, 2020 08:06
@ashiagr ashiagr changed the title Jetpack Section: Scan menu Jetpack Mobile: Scan menu Dec 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants