Skip to content

Commit

Permalink
Rework showManagePlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 16, 2024
1 parent 9edd5d2 commit f44b164
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ extension MySitesRoute: Route {

extension MySitesRoute: NavigationAction {
func perform(_ values: [String: String], source: UIViewController? = nil, router: LinkRouter) {
let coordinator = RootViewCoordinator.sharedPresenter.mySitesCoordinator
let campaign = AppBannerCampaign.getCampaign(from: values)

guard let blog = blog(from: values) else {
Expand Down Expand Up @@ -127,7 +126,9 @@ extension MySitesRoute: NavigationAction {
case .plugins:
presenter.showBlogDetails(for: blog, then: .plugins)
case .managePlugins:
coordinator.showManagePlugins(for: blog)
presenter.showBlogDetails(for: blog, then: .plugins, userInfo: [
BlogDetailsViewController.userInfoShowManagemenetScreenKey(): true
])
case .siteMonitoring:
presenter.showSiteMonitoring(for: blog, selectedTab: .metrics)
case .phpLogs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,14 @@ extension BlogDetailsViewController {
let viewController = UIHostingController(rootView: ApplicationTokenListView(viewModel: viewModel))
presentationDelegate.presentBlogDetailsViewController(viewController)
}
}

@objc func showManagePluginsScreen() {
guard blog.supports(.pluginManagement),
let site = JetpackSiteRef(blog: blog) else {
return
}
let query = PluginQuery.all(site: site)
let listViewController = PluginListViewController(site: site, query: query)
presentationDelegate?.presentBlogDetailsViewController(listViewController)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) {

+ (nonnull NSString *)userInfoShowPickerKey;
+ (nonnull NSString *)userInfoSiteMonitoringTabKey;
+ (nonnull NSString *)userInfoShowManagemenetScreenKey;
+ (nonnull NSString *)userInfoSourceKey;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,12 @@ - (void)showDetailViewForSubsection:(BlogDetailsSubsection)section userInfo:(NSD
[self.tableView selectRowAtIndexPath:indexPath
animated:NO
scrollPosition:[self optimumScrollPositionForIndexPath:indexPath]];
[self showPlugins];
BOOL showManagemnet = userInfo[[BlogDetailsViewController userInfoShowManagemenetScreenKey]] ?: NO;
if (showManagemnet) {
[self showManagePluginsScreen];
} else {
[self showPlugins];
}
}
break;
case BlogDetailsSubsectionSiteMonitoring:
Expand Down Expand Up @@ -2159,6 +2164,10 @@ + (NSString *)userInfoSiteMonitoringTabKey {
return @"site-monitoring-tab";
}

+ (NSString *)userInfoShowManagemenetScreenKey {
return @"show-manage-plugins";
}

+ (NSString *)userInfoSourceKey {
return @"source";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,29 +165,6 @@ class MySitesCoordinator: NSObject {
return mySiteViewController.showBlogDetailsMeSubsection()
}

func showManagePlugins(for blog: Blog) {
guard blog.supports(.pluginManagement) else {
return
}

// PerformWithoutAnimation is required here, otherwise the view controllers
// potentially get added to the navigation controller out of order
// (ShowDetailViewController, used by BlogDetailsViewController is animated)
UIView.performWithoutAnimation {
showBlogDetails(for: blog, then: .plugins)
}

guard let site = JetpackSiteRef(blog: blog),
let navigationController = splitViewController.topDetailViewController?.navigationController else {
return
}

let query = PluginQuery.all(site: site)
let listViewController = PluginListViewController(site: site, query: query)

navigationController.pushViewController(listViewController, animated: false)
}

// MARK: Notifications Handling

private func addSignInObserver() {
Expand Down

0 comments on commit f44b164

Please sign in to comment.