Skip to content

Commit

Permalink
Merge pull request #15222 from wordpress-mobile/fix/8224-add_edit_pag…
Browse files Browse the repository at this point in the history
…e_option

Pages: add Edit to options menu
  • Loading branch information
ScoutHarris authored Nov 5, 2020
2 parents e137b36 + 1a3f4df commit 6a945ed
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions WordPress/Classes/ViewRelated/Pages/PageListViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
//
Expand Down

0 comments on commit 6a945ed

Please sign in to comment.