Skip to content

Browse plugin details from WordPress.org plugin directory#24072

Merged
crazytonyli merged 5 commits intotrunkfrom
self-hosted-site-plugin-management-add-new-plugin
Feb 18, 2025
Merged

Browse plugin details from WordPress.org plugin directory#24072
crazytonyli merged 5 commits intotrunkfrom
self-hosted-site-plugin-management-add-new-plugin

Conversation

@crazytonyli
Copy link
Contributor

The plugin details view is now used to display all plugin details, regardless of whether it's installed.

I haven't implemented all actions (like installing new plugins) yet. I'll create follow-up PRs for that.

Regression Notes

  1. Potential unintended areas of impact

  2. What I did to test those areas of impact (or what existing automated tests I relied on)

  3. What automated tests I added (or what prevented me from doing so)

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • 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.

Testing checklist:

  • WordPress.com sites and self-hosted Jetpack sites.
  • Portrait and landscape orientations.
  • Light and dark modes.
  • Fonts: Larger, smaller and bold text.
  • High contrast.
  • VoiceOver.
  • Languages with large words or with letters/accents not frequently used in English.
  • Right-to-left languages. (Even if translation isn’t complete, formatting should still respect the right-to-left layout)
  • iPhone and iPad.
  • Multi-tasking: Split view and Slide over. (iPad)

@crazytonyli crazytonyli added this to the 25.8 milestone Feb 13, 2025
@crazytonyli crazytonyli requested review from jkmassel and kean February 13, 2025 00:19
@dangermattic
Copy link
Collaborator

dangermattic commented Feb 13, 2025

2 Warnings
⚠️ View files have been modified, but no screenshot or video is included in the pull request. Consider adding some for clarity.
⚠️ This PR is assigned to the milestone 25.8. This milestone is due in less than 4 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 13, 2025

WordPress Alpha📲 You can test the changes from this Pull Request in WordPress Alpha by scanning the QR code below to install the corresponding build.
App NameWordPress Alpha WordPress Alpha
ConfigurationRelease-Alpha
Build Numberpr24072-3fc30bf
Version25.7.1
Bundle IDorg.wordpress.alpha
Commit3fc30bf
App Center BuildWPiOS - One-Offs #11499
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 13, 2025

Jetpack Alpha📲 You can test the changes from this Pull Request in Jetpack Alpha by scanning the QR code below to install the corresponding build.
App NameJetpack Alpha Jetpack Alpha
ConfigurationRelease-Alpha
Build Numberpr24072-3fc30bf
Version25.7.1
Bundle IDcom.jetpack.alpha
Commit3fc30bf
App Center Buildjetpack-installable-builds #10531
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@crazytonyli
Copy link
Contributor Author

Hi @mokagio @iangmaia , the SwiftLint job failed. The error message just says the swiftlint command failed. I'm not sure it's because swiftlint found some issues or swiftlint the command not found?

@iangmaia
Copy link
Contributor

Hi @mokagio @iangmaia , the SwiftLint job failed. The error message just says the swiftlint command failed. I'm not sure it's because swiftlint found some issues or swiftlint the command not found?

Not sure why it didn't show on the first run. I see the agent later disconnected, so maybe it was about to be terminated or something like that? 🤔
Anyway, on a second attempt it reported an actual SwiftLint error:

- `WordPress/Classes/Plugins/Views/PluginDetailsView.swift:367:24`: Arguments can be omitted when matching enums with associated values if they are not used (empty_enum_arguments)

let button: AnyView
switch self {
case let .install(_, action):
button = AnyView(Button("Install", action: action)
Copy link
Contributor

Choose a reason for hiding this comment

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

l10n

}

var actionButton: ActionButton {
if let plugin = viewModel.installed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Create the buttons here directly? What's the point of ActionButton?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it'd be more apparent to see what buttons can be displayed on the screen (the enum cases). Using if-else statements may not be as clear.

self.pluginInfo = .init(name: plugin.name, author: plugin.author, shortDescription: plugin.shortDescription)
self.service = service
_viewModel = StateObject(wrappedValue: .init(slug: slug, service: service))
_viewModel = StateObject(wrappedValue: .init(slug: slug, plugin: nil, installed: plugin, service: service))
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to be careful with StateObject(wrappedValue:). If the view identity doesn't change, ti won't be re-created when you show a new slug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I didn't get what you meant. Can you talk more about it? What is "view identity"? By "show a new slug", do you mean showing another plugin by refreshing the current PluginDetailsView instead of presenting a new one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you talk more about it?

Apple explains it here. I tend to avoid using @StateObject this way because of that limitation.

What is "view identity"?

I'm not sure it's completely up to date, but there was a great video about in in WWDC21: Demystify SwiftUI. I highly recommend WWDC videos on SwiftUI in general as they are often the only source of official information. I don't think there is a quick way to fully explain it.

In short, if you have a view like SomeView that gets re-initialized every time when it's container view body is called, how does SwiftUI know that it's the "same" view that needs to keep its @State? It's based on the view identity, which is based on type of the view and its place in a view hierarchy (also based on types).

struct SomeView {
    @State var counter = 0
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha. I'll address this concern in a separate PR.

@kean kean self-requested a review February 18, 2025 14:43
@crazytonyli crazytonyli added this pull request to the merge queue Feb 18, 2025
Merged via the queue into trunk with commit bdb2563 Feb 18, 2025
25 checks passed
@crazytonyli crazytonyli deleted the self-hosted-site-plugin-management-add-new-plugin branch February 18, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants