From 1a3f4dfa9c58b6d70974008628f8c49b8cb0ce1f Mon Sep 17 00:00:00 2001 From: Stephenie Harris Date: Wed, 4 Nov 2020 16:35:38 -0700 Subject: [PATCH] Show edit menu option for all but trashed page types. --- .../Pages/PageListViewController.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift index 64ee8009c44a..adb66136b5f7 100644 --- a/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift +++ b/WordPress/Classes/ViewRelated/Pages/PageListViewController.swift @@ -610,6 +610,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe strongSelf.retryPage(page) }) } else { + addEditAction(to: alertController, for: page) + alertController.addActionWithTitle(viewButtonTitle, style: .default, handler: { [weak self] (action) in guard let strongSelf = self, let page = strongSelf.pageForObjectID(objectID) else { @@ -652,6 +654,8 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe strongSelf.retryPage(page) }) } else { + addEditAction(to: alertController, for: page) + alertController.addActionWithTitle(viewButtonTitle, style: .default, handler: { [weak self] (action) in guard let strongSelf = self, let page = strongSelf.pageForObjectID(objectID) else { @@ -695,6 +699,19 @@ class PageListViewController: AbstractPostListViewController, UIViewControllerRe } } + private func addEditAction(to controller: UIAlertController, for page: AbstractPost) { + if page.status == .trash { + return + } + + let buttonTitle = NSLocalizedString("Edit", comment: "Label for a button that opens the Edit Page view controller") + controller.addActionWithTitle(buttonTitle, style: .default, handler: { [weak self] _ in + if let page = self?.pageForObjectID(page.objectID) { + self?.editPage(page) + } + }) + } + private func addSetParentAction(to controller: UIAlertController, for page: AbstractPost, at index: IndexPath?) { /// This button is disabled for trashed pages //