Skip to content

Commit bff58f6

Browse files
authored
Merge pull request #17902 from wordpress-mobile/fix/msd-quick-actions-cell
My Site Dashboard: Hide Quick Actions cell for Jetpack App
2 parents 468fa76 + cce0906 commit bff58f6

7 files changed

Lines changed: 50 additions & 179 deletions

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+DomainCredit.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,15 @@ extension BlogDetailsViewController {
3333
private func presentDomainCreditRedemptionSuccess(domain: String) {
3434
let controller = DomainCreditRedemptionSuccessViewController(domain: domain, delegate: self)
3535
present(controller, animated: true) { [weak self] in
36-
self?.updateTableViewAndHeader()
36+
self?.updateTableView {
37+
guard
38+
let parent = self?.parent as? MySiteViewController,
39+
let blog = self?.blog
40+
else {
41+
return
42+
}
43+
parent.sitePickerViewController?.blogDetailHeaderView.blog = blog
44+
}
3745
}
3846
}
3947
}

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+Header.swift

Lines changed: 0 additions & 121 deletions
This file was deleted.

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+QuickActions.swift

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import UIKit
22

33
extension BlogDetailsViewController {
4+
45
@objc func quickActionsSectionViewModel() -> BlogDetailsSection {
56
let row = BlogDetailsRow()
67
row.callback = {}
@@ -13,6 +14,35 @@ extension BlogDetailsViewController {
1314
@objc func isAccessibilityCategoryEnabled() -> Bool {
1415
tableView.traitCollection.preferredContentSizeCategory.isAccessibilityCategory
1516
}
17+
18+
@objc func configureQuickActions(cell: QuickActionsCell) {
19+
let actionItems = createActionItems()
20+
21+
cell.configure(with: actionItems)
22+
}
23+
24+
private func createActionItems() -> [ActionRow.Item] {
25+
let actionItems: [ActionRow.Item] = [
26+
.init(image: .gridicon(.statsAlt), title: NSLocalizedString("Stats", comment: "Noun. Abbv. of Statistics. Links to a blog's Stats screen.")) { [weak self] in
27+
self?.tableView.deselectSelectedRowWithAnimation(false)
28+
self?.showStats(from: .button)
29+
},
30+
.init(image: .gridicon(.posts), title: NSLocalizedString("Posts", comment: "Noun. Title. Links to the blog's Posts screen.")) { [weak self] in
31+
self?.tableView.deselectSelectedRowWithAnimation(false)
32+
self?.showPostList(from: .button)
33+
},
34+
.init(image: .gridicon(.image), title: NSLocalizedString("Media", comment: "Noun. Title. Links to the blog's Media library.")) { [weak self] in
35+
self?.tableView.deselectSelectedRowWithAnimation(false)
36+
self?.showMediaLibrary(from: .button)
37+
},
38+
.init(image: .gridicon(.pages), title: NSLocalizedString("Pages", comment: "Noun. Title. Links to the blog's Pages screen.")) { [weak self] in
39+
self?.tableView.deselectSelectedRowWithAnimation(false)
40+
self?.showPageList(from: .button)
41+
}
42+
]
43+
44+
return actionItems
45+
}
1646
}
1747

1848
@objc class QuickActionsCell: UITableViewCell {

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController+Swift.swift

Lines changed: 0 additions & 26 deletions
This file was deleted.

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) {
139139
@property (nonatomic, strong) id<ScenePresenter> _Nonnull meScenePresenter;
140140
@property (nonatomic, strong, readonly) CreateButtonCoordinator * _Nullable createButtonCoordinator;
141141
@property (nonatomic, strong, readwrite) UITableView * _Nonnull tableView;
142-
@property (nonatomic, strong, readonly) BlogDetailHeaderView * _Nonnull headerView;
143142
@property (nonatomic) BOOL shouldScrollToViewSite;
144143

145144
- (id _Nonnull)initWithMeScenePresenter:(id<ScenePresenter> _Nonnull)meScenePresenter;
@@ -154,11 +153,7 @@ typedef NS_ENUM(NSUInteger, BlogDetailsNavigationSource) {
154153
- (void)showPageListFromSource:(BlogDetailsNavigationSource)source;
155154
- (void)showMediaLibraryFromSource:(BlogDetailsNavigationSource)source;
156155
- (void)showStatsFromSource:(BlogDetailsNavigationSource)source;
157-
- (void)refreshSiteIcon;
158-
- (void)toggleSpotlightForSiteTitle;
159-
- (void)toggleSpotlightOnHeaderView;
160-
- (void)uploadDroppedSiteIcon:(nonnull UIImage *)image onCompletion:(nullable void(^)(void))completion;
161-
- (void)updateTableViewAndHeader;
156+
- (void)updateTableView:(nullable void(^)(void))completion;
162157
- (void)preloadMetadata;
163158
- (void)pulledToRefreshWith:(nonnull UIRefreshControl *)refreshControl onCompletion:(nullable void(^)(void))completion;
164159
@end

WordPress/Classes/ViewRelated/Blog/Blog Details/BlogDetailsViewController.m

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,8 @@ - (instancetype)initWithTitle:(NSString *)title
211211

212212
#pragma mark -
213213

214-
@interface BlogDetailsViewController () <UIActionSheetDelegate, UIAlertViewDelegate, WPSplitViewControllerDetailProvider, BlogDetailHeaderViewDelegate, UITableViewDelegate, UITableViewDataSource>
214+
@interface BlogDetailsViewController () <UIActionSheetDelegate, UIAlertViewDelegate, WPSplitViewControllerDetailProvider, UITableViewDelegate, UITableViewDataSource>
215215

216-
@property (nonatomic, strong, readwrite) BlogDetailHeaderView *headerView;
217216
@property (nonatomic, strong) NSArray *headerViewHorizontalConstraints;
218217
@property (nonatomic, strong) NSArray<BlogDetailsSection *> *tableSections;
219218
@property (nonatomic, strong) BlogService *blogService;
@@ -407,8 +406,6 @@ - (void)viewWillAppear:(BOOL)animated
407406

408407
self.navigationItem.title = NSLocalizedString(@"My Site", @"Title of My Site tab");
409408

410-
[self.headerView setBlog:self.blog];
411-
412409
// Configure and reload table data when appearing to ensure pending comment count is updated
413410
[self configureTableViewData];
414411

@@ -744,8 +741,10 @@ - (UITableViewScrollPosition)optimumScrollPositionForIndexPath:(NSIndexPath *)in
744741
- (void)configureTableViewData
745742
{
746743
NSMutableArray *marr = [NSMutableArray array];
747-
748-
[marr addObject:[self quickActionsSectionViewModel]];
744+
745+
if (AppConfiguration.showsQuickActions) {
746+
[marr addObject:[self quickActionsSectionViewModel]];
747+
}
749748
if ([DomainCreditEligibilityChecker canRedeemDomainCreditWithBlog:self.blog]) {
750749
if (!self.hasLoggedDomainCreditPromptShownEvent) {
751750
[WPAnalytics track:WPAnalyticsStatDomainCreditPromptShown];
@@ -1077,7 +1076,6 @@ - (BOOL)shouldDisplayLinkToWPAdmin
10771076

10781077
- (void)switchToBlog:(Blog*)blog
10791078
{
1080-
self.headerView.blog = blog;
10811079
self.blog = blog;
10821080
[self showInitialDetailsForBlog];
10831081
[self.tableView reloadData];
@@ -1713,21 +1711,20 @@ - (UIPresentationController *)presentationControllerForPresentedViewController:(
17131711

17141712
- (void)updateTableViewAndHeader
17151713
{
1716-
[self updateTableViewAndHeader:^{}];
1714+
[self updateTableView:^{}];
17171715
}
17181716

1719-
/// This method syncs the blog and its metadata, then reloads the table view and updates the header with the synced blog.
1717+
/// This method syncs the blog and its metadata, then reloads the table view.
17201718
///
1721-
- (void)updateTableViewAndHeader:(void(^)(void))onComplete
1719+
- (void)updateTableView:(void(^)(void))completion
17221720
{
17231721
__weak __typeof(self) weakSelf = self;
17241722
[self.blogService syncBlogAndAllMetadata:self.blog
17251723
completionHandler:
17261724
^{
17271725
[weakSelf configureTableViewData];
17281726
[weakSelf reloadTableViewPreservingSelection];
1729-
[weakSelf.headerView setBlog:weakSelf.blog];
1730-
onComplete();
1727+
completion();
17311728
}];
17321729
}
17331730

@@ -1738,7 +1735,7 @@ - (void)pulledToRefresh {
17381735

17391736
- (void)pulledToRefreshWith:(UIRefreshControl *)refreshControl onCompletion:( void(^)(void))completion {
17401737

1741-
[self updateTableViewAndHeader: ^{
1738+
[self updateTableView: ^{
17421739
// WORKAROUND: if we don't dispatch this asynchronously, the refresh end animation is clunky.
17431740
// To recognize if we can remove this, simply remove the dispatch_async call and test pulling
17441741
// down to refresh the site.

0 commit comments

Comments
 (0)