Skip to content

Commit

Permalink
fix actions for a homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
Momo Ozawa committed Nov 3, 2023
1 parent bd77fc9 commit 72b44d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,9 @@ final class PageMenuViewModelTests: CoreDataTestCase {
.map { $0.buttons }
let expectedButtons: [[AbstractPostButton]] = [
[.view],
[.moveToDraft, .duplicate],
[.duplicate],
[.blaze],
[.setParent, .setPostsPage],
[.trash]
[.setParent, .setPostsPage]
]
expect(buttons).to(equal(expectedButtons))
}
Expand Down
6 changes: 5 additions & 1 deletion WordPress/Classes/ViewRelated/Post/PageMenuViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class PageMenuViewModel: AbstractPostMenuViewModel {
private func createSecondarySection() -> AbstractPostButtonSection {
var buttons = [AbstractPostButton]()

if page.status != .draft {
if page.status != .draft && isSiteHomepage {
buttons.append(.moveToDraft)
}

Expand Down Expand Up @@ -106,6 +106,10 @@ final class PageMenuViewModel: AbstractPostMenuViewModel {
}

private func createTrashSection() -> AbstractPostButtonSection {
guard !isSiteHomepage else {
return AbstractPostButtonSection(buttons: [])
}

return AbstractPostButtonSection(buttons: [.trash])
}
}

0 comments on commit 72b44d1

Please sign in to comment.