From d572d0dcb7d255b415f4a28f43e19981bb7ab67b Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 23 Mar 2023 19:06:39 -0400 Subject: [PATCH 1/3] Make quick start cards personalizable --- .../BlogDashboardPersonalizeCardCell.swift | 2 +- .../Blog/Blog Dashboard/DashboardCard.swift | 1 + .../BlogDashboardPersonalizationService.swift | 4 ++- .../BlogDashboardPersonalizationView.swift | 2 +- ...logDashboardPersonalizationViewModel.swift | 29 ++++++++++++++----- ...DashboardPersonalizationServiceTests.swift | 8 +++++ ...shboardPersonalizationViewModelTests.swift | 21 +++++++++++++- 7 files changed, 56 insertions(+), 11 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/BlogDashboardPersonalizeCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/BlogDashboardPersonalizeCardCell.swift index ed11b9aa3543..15d1c343cee6 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/BlogDashboardPersonalizeCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/BlogDashboardPersonalizeCardCell.swift @@ -78,7 +78,7 @@ final class BlogDashboardPersonalizeCardCell: DashboardCollectionViewCell { } WPAnalytics.track(.dashboardCardItemTapped, properties: ["type": DashboardCard.personalize.rawValue], blog: blog) let viewController = UIHostingController(rootView: NavigationView { - BlogDashboardPersonalizationView(viewModel: .init(service: .init(siteID: siteID))) + BlogDashboardPersonalizationView(viewModel: .init(service: .init(siteID: siteID), quickStartType: blog.quickStartType)) }.navigationViewStyle(.stack)) // .stack is required for iPad if UIDevice.isPad() { viewController.modalPresentationStyle = .formSheet diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift index 054247c49345..070ea9e501c2 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift @@ -156,6 +156,7 @@ enum DashboardCard: String, CaseIterable { .prompts, .pages, .activityLog + .quickStart ] /// Includes all cards that should be fetched from the backend diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardPersonalizationService.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardPersonalizationService.swift index f90476fb037b..a5a9eed27e23 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardPersonalizationService.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Service/BlogDashboardPersonalizationService.swift @@ -62,7 +62,9 @@ private func makeKey(for card: DashboardCard) -> String? { return "activity-log-card-enabled-site-settings" case .pages: return "pages-card-enabled-site-settings" - case .quickStart, .jetpackBadge, .jetpackInstall, .nextPost, .createPost, .failure, .ghost, .personalize, .empty: + case .quickStart: + return "quick-start-card-enabled-site-settings" + case .jetpackBadge, .jetpackInstall, .nextPost, .createPost, .failure, .ghost, .personalize, .empty: return nil } } diff --git a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationView.swift b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationView.swift index 27101c564dcf..db45dfa0cd70 100644 --- a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationView.swift +++ b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationView.swift @@ -52,7 +52,7 @@ private extension BlogDashboardPersonalizationView { struct BlogDashboardPersonalizationView_Previews: PreviewProvider { static var previews: some View { NavigationView { - BlogDashboardPersonalizationView(viewModel: .init(service: .init(repository: UserDefaults.standard, siteID: 1))) + BlogDashboardPersonalizationView(viewModel: .init(service: .init(repository: UserDefaults.standard, siteID: 1), quickStartType: .newSite)) } } } diff --git a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift index 3b0e090e9bc3..66f1bd18711b 100644 --- a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift +++ b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift @@ -3,9 +3,13 @@ import SwiftUI final class BlogDashboardPersonalizationViewModel: ObservableObject { let cards: [BlogDashboardPersonalizationCardCellViewModel] - init(service: BlogDashboardPersonalizationService) { - self.cards = DashboardCard.personalizableCards.map { - BlogDashboardPersonalizationCardCellViewModel(card: $0, service: service) + init(service: BlogDashboardPersonalizationService, quickStartType: QuickStartType) { + self.cards = DashboardCard.personalizableCards.compactMap { + if $0 == .quickStart && quickStartType == .undefined { + return nil + } + let title = $0.getLocalizedTitle(quickStartType: quickStartType) + return BlogDashboardPersonalizationCardCellViewModel(card: $0, title: title, service: service) } } } @@ -15,7 +19,7 @@ final class BlogDashboardPersonalizationCardCellViewModel: ObservableObject, Ide private let service: BlogDashboardPersonalizationService var id: DashboardCard { card } - var title: String { card.localizedTitle } + let title: String var isOn: Bool { get { service.isEnabled(card) } @@ -25,14 +29,15 @@ final class BlogDashboardPersonalizationCardCellViewModel: ObservableObject, Ide } } - init(card: DashboardCard, service: BlogDashboardPersonalizationService) { + init(card: DashboardCard, title: String, service: BlogDashboardPersonalizationService) { self.card = card + self.title = title self.service = service } } private extension DashboardCard { - var localizedTitle: String { + func getLocalizedTitle(quickStartType: QuickStartType) -> String { switch self { case .prompts: return NSLocalizedString("personalizeHome.dashboardCard.prompts", value: "Blogging prompts", comment: "Card title for the pesonalization menu") @@ -48,7 +53,17 @@ private extension DashboardCard { return NSLocalizedString("personalizeHome.dashboardCard.activityLog", value: "Recent activity", comment: "Card title for the pesonalization menu") case .pages: return NSLocalizedString("personalizeHome.dashboardCard.pages", value: "Pages", comment: "Card title for the pesonalization menu") - case .quickStart, .nextPost, .createPost, .ghost, .failure, .personalize, .jetpackBadge, .jetpackInstall, .domainsDashboardCard, .freeToPaidPlansDashboardCard, .domainRegistration, .empty: + case .quickStart: + switch quickStartType { + case .undefined: + assertionFailure(".quickStart card should only appear in the personalization menu if there are remaining steps") + return "" + case .existingSite: + return NSLocalizedString("personalizeHome.dashboardCard.nextSteps", value: "Get to know the app", comment: "Card title for the pesonalization menu") + case .newSite: + return NSLocalizedString("personalizeHome.dashboardCard.nextSteps", value: "Next steps", comment: "Card title for the pesonalization menu") + } + case .nextPost, .createPost, .ghost, .failure, .personalize, .jetpackBadge, .jetpackInstall, .empty, .domainsDashboardCard: assertionFailure("\(self) card should not appear in the personalization menus") return "" // These cards don't appear in the personalization menus } diff --git a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationServiceTests.swift b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationServiceTests.swift index aaae265862df..fb20d0e08c61 100644 --- a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationServiceTests.swift +++ b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationServiceTests.swift @@ -44,4 +44,12 @@ final class BlogDashboardPersonalizationServiceTests: XCTestCase { // Then settings for site 1 are ignored XCTAssertTrue(service.isEnabled(.quickStart)) } + + func testThatUserDefaultsKeysAreSpecifiedForAllPersonalizableCards() { + let service = BlogDashboardPersonalizationService(repository: repository, siteID: 1) + for card in DashboardCard.personalizableCards { + service.setEnabled(false, for: card) + XCTAssertFalse(service.isEnabled(card)) + } + } } diff --git a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift index 4c8ea5bb8735..2d787dcbb6b2 100644 --- a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift +++ b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift @@ -12,7 +12,7 @@ final class BlogDashboardPersonalizationViewModelTests: XCTestCase { override func setUp() { super.setUp() - viewModel = BlogDashboardPersonalizationViewModel(service: service) + viewModel = BlogDashboardPersonalizationViewModel(service: service, quickStartType: .undefined) } func testThatCardStateIsToggled() throws { @@ -30,4 +30,23 @@ final class BlogDashboardPersonalizationViewModelTests: XCTestCase { XCTAssertFalse(cardViewModel.isOn) XCTAssertFalse(service.isEnabled(card), "Service wasn't updated") } + + func testThatAllCardsHaveTitles() { + for card in viewModel.cards { + XCTAssertTrue(!card.title.isEmpty) + } + } + + + func testThatQuickStartCardsIsNotDisplayedWhenTourIsActive() { + // Given + viewModel = BlogDashboardPersonalizationViewModel(service: service, quickStartType: .newSite) + + // Then + XCTAssertTrue(viewModel.cards.contains(where: { $0.id == .quickStart })) + } + + func testThatQuickStartCardsIsNotDisplayedWhenNoTourIsActive() { + XCTAssertFalse(viewModel.cards.contains(where: { $0.id == .quickStart })) + } } From 55865bbeede1480f9dfe8a0b1d5a9bb41b2e6a9e Mon Sep 17 00:00:00 2001 From: kean Date: Thu, 23 Mar 2023 19:54:11 -0400 Subject: [PATCH 2/3] Update the design of the hide this prompt for the quick start cards --- .../DashboardQuickStartCardCell.swift | 28 +++++++++++++------ ...logDashboardPersonalizationViewModel.swift | 2 +- ...shboardPersonalizationViewModelTests.swift | 1 - 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift index 9bd8c12aceb8..35284b8d9763 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift @@ -51,12 +51,12 @@ final class DashboardQuickStartCardCell: UICollectionViewCell, Reusable, BlogDas fallthrough case .newSite: - configureOnEllipsisButtonTap(sourceRect: cardFrameView.ellipsisButton.frame) + configureOnEllipsisButtonTap(sourceRect: cardFrameView.ellipsisButton.frame, blog: blog) cardFrameView.showHeader() case .existingSite: cardFrameView.configureButtonContainerStackView() - configureOnEllipsisButtonTap(sourceRect: cardFrameView.buttonContainerStackView.frame) + configureOnEllipsisButtonTap(sourceRect: cardFrameView.buttonContainerStackView.frame, blog: blog) cardFrameView.hideHeader() } @@ -64,14 +64,24 @@ final class DashboardQuickStartCardCell: UICollectionViewCell, Reusable, BlogDas cardFrameView.setTitle(Strings.title(for: blog.quickStartType)) } - private func configureOnEllipsisButtonTap(sourceRect: CGRect) { - cardFrameView.onEllipsisButtonTap = { [weak self] in - guard let self = self, - let viewController = self.viewController, - let blog = self.blog else { - return + private func configureOnEllipsisButtonTap(sourceRect: CGRect, blog: Blog) { + if FeatureFlag.personalizeHomeTab.enabled { + cardFrameView.onEllipsisButtonTap = { + BlogDashboardAnalytics.trackContextualMenuAccessed(for: .quickStart) + } + cardFrameView.ellipsisButton.showsMenuAsPrimaryAction = true + cardFrameView.ellipsisButton.menu = UIMenu(title: "", options: .displayInline, children: [ + BlogDashboardHelpers.makeHideCardAction(for: .quickStart, siteID: blog.dotComID?.intValue ?? 0) + ]) + } else { + cardFrameView.onEllipsisButtonTap = { [weak self] in + guard let self = self, + let viewController = self.viewController, + let blog = self.blog else { + return + } + viewController.removeQuickStart(from: blog, sourceView: self.cardFrameView, sourceRect: sourceRect) } - viewController.removeQuickStart(from: blog, sourceView: self.cardFrameView, sourceRect: sourceRect) } } } diff --git a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift index 66f1bd18711b..6254cfc56b0c 100644 --- a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift +++ b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift @@ -59,7 +59,7 @@ private extension DashboardCard { assertionFailure(".quickStart card should only appear in the personalization menu if there are remaining steps") return "" case .existingSite: - return NSLocalizedString("personalizeHome.dashboardCard.nextSteps", value: "Get to know the app", comment: "Card title for the pesonalization menu") + return NSLocalizedString("personalizeHome.dashboardCard.getToKnowTheApp", value: "Get to know the app", comment: "Card title for the pesonalization menu") case .newSite: return NSLocalizedString("personalizeHome.dashboardCard.nextSteps", value: "Next steps", comment: "Card title for the pesonalization menu") } diff --git a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift index 2d787dcbb6b2..083409e82a66 100644 --- a/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift +++ b/WordPress/WordPressTest/Dashboard/BlogDashboardPersonalizationViewModelTests.swift @@ -37,7 +37,6 @@ final class BlogDashboardPersonalizationViewModelTests: XCTestCase { } } - func testThatQuickStartCardsIsNotDisplayedWhenTourIsActive() { // Given viewModel = BlogDashboardPersonalizationViewModel(service: service, quickStartType: .newSite) From 81be4849eabcaa4a37b2a9d195d43643d4fee516 Mon Sep 17 00:00:00 2001 From: Alex Grebenyuk Date: Mon, 3 Apr 2023 07:25:26 -0400 Subject: [PATCH 3/3] Add convenience API for adding dashboard card menus --- .../Activity Log/DashboardActivityLogCardCell.swift | 3 +-- .../Cards/Pages/DashboardPagesListCardCell.swift | 12 ++++-------- .../Cards/Posts/BlogDashboardCardFrameView.swift | 9 +++++++++ .../Cards/Posts/DashboardPostsListCardCell.swift | 10 +++------- .../Quick Start/DashboardQuickStartCardCell.swift | 10 +++------- .../Cards/Stats/DashboardStatsCardCell.swift | 10 +++------- .../Blog/Blog Dashboard/DashboardCard.swift | 2 +- .../Helpers/BlogDashboardHelpers.swift | 4 ++-- .../BlogDashboardPersonalizationViewModel.swift | 2 +- 9 files changed, 27 insertions(+), 35 deletions(-) diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Activity Log/DashboardActivityLogCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Activity Log/DashboardActivityLogCardCell.swift index 631c11953b5f..1b2098a17dfa 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Activity Log/DashboardActivityLogCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Activity Log/DashboardActivityLogCardCell.swift @@ -107,8 +107,7 @@ final class DashboardActivityLogCardCell: DashboardCollectionViewCell { let activitySubmenu = UIMenu(title: String(), options: .displayInline, children: [activityAction]) - let hideThisAction = BlogDashboardHelpers.makeHideCardAction(for: .activityLog, - siteID: blog.dotComID?.intValue ?? 0) + let hideThisAction = BlogDashboardHelpers.makeHideCardAction(for: .activityLog, blog: blog) cardFrameView.ellipsisButton.menu = UIMenu(title: String(), options: .displayInline, children: [ activitySubmenu, diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Pages/DashboardPagesListCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Pages/DashboardPagesListCardCell.swift index a03c3178b07b..282765448b7b 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Pages/DashboardPagesListCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Pages/DashboardPagesListCardCell.swift @@ -103,7 +103,10 @@ extension DashboardPagesListCardCell { } cardFrameView.ellipsisButton.showsMenuAsPrimaryAction = true - let children = [makeAllPagesAction(), makeHideCardAction(blog: blog)].compactMap { $0 } + let children = [ + makeAllPagesAction(), + BlogDashboardHelpers.makeHideCardAction(for: .pages, blog: blog) + ].compactMap { $0 } cardFrameView.ellipsisButton.menu = UIMenu(title: String(), options: .displayInline, children: children) } @@ -119,13 +122,6 @@ extension DashboardPagesListCardCell { return allPagesSubmenu } - private func makeHideCardAction(blog: Blog) -> UIMenuElement? { - guard let siteID = blog.dotComID?.intValue else { - return nil - } - return BlogDashboardHelpers.makeHideCardAction(for: .pages, siteID: siteID) - } - // MARK: Actions private func showPagesList(source: PagesListSource) { diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/BlogDashboardCardFrameView.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/BlogDashboardCardFrameView.swift index 959f5620eb82..89c6319d17c1 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/BlogDashboardCardFrameView.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/BlogDashboardCardFrameView.swift @@ -183,6 +183,15 @@ class BlogDashboardCardFrameView: UIView { buttonContainerStackView.removeFromSuperview() } + /// Adds the "more" button with the given actions to the corner of the cell. + func addMoreMenu(items: [UIMenuElement], card: DashboardCard) { + onEllipsisButtonTap = { + BlogDashboardAnalytics.trackContextualMenuAccessed(for: card) + } + ellipsisButton.showsMenuAsPrimaryAction = true + ellipsisButton.menu = UIMenu(title: "", options: .displayInline, children: items) + } + private func updateEllipsisButtonState() { ellipsisButton.isHidden = onEllipsisButtonTap == nil let headerPadding = ellipsisButton.isHidden ? diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/DashboardPostsListCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/DashboardPostsListCardCell.swift index a82c1b4a7541..3fbacf3395c3 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/DashboardPostsListCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Posts/DashboardPostsListCardCell.swift @@ -110,13 +110,9 @@ extension DashboardPostsListCardCell { private func addContextMenu(card: DashboardCard, blog: Blog) { guard FeatureFlag.personalizeHomeTab.enabled else { return } - frameView.onEllipsisButtonTap = { - BlogDashboardAnalytics.trackContextualMenuAccessed(for: card) - } - frameView.ellipsisButton.showsMenuAsPrimaryAction = true - frameView.ellipsisButton.menu = UIMenu(title: "", options: .displayInline, children: [ - BlogDashboardHelpers.makeHideCardAction(for: card, siteID: blog.dotComID?.intValue ?? 0) - ]) + frameView.addMoreMenu(items: [ + BlogDashboardHelpers.makeHideCardAction(for: card, blog: blog) + ], card: card) } private func configureDraftsList(blog: Blog) { diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift index 35284b8d9763..556988fada68 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Quick Start/DashboardQuickStartCardCell.swift @@ -66,13 +66,9 @@ final class DashboardQuickStartCardCell: UICollectionViewCell, Reusable, BlogDas private func configureOnEllipsisButtonTap(sourceRect: CGRect, blog: Blog) { if FeatureFlag.personalizeHomeTab.enabled { - cardFrameView.onEllipsisButtonTap = { - BlogDashboardAnalytics.trackContextualMenuAccessed(for: .quickStart) - } - cardFrameView.ellipsisButton.showsMenuAsPrimaryAction = true - cardFrameView.ellipsisButton.menu = UIMenu(title: "", options: .displayInline, children: [ - BlogDashboardHelpers.makeHideCardAction(for: .quickStart, siteID: blog.dotComID?.intValue ?? 0) - ]) + cardFrameView.addMoreMenu(items: [ + BlogDashboardHelpers.makeHideCardAction(for: .quickStart, blog: blog) + ], card: .quickStart) } else { cardFrameView.onEllipsisButtonTap = { [weak self] in guard let self = self, diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Stats/DashboardStatsCardCell.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Stats/DashboardStatsCardCell.swift index 3ce37e690174..10745d10adf9 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Stats/DashboardStatsCardCell.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Stats/DashboardStatsCardCell.swift @@ -75,13 +75,9 @@ extension DashboardStatsCardCell: BlogDashboardCardConfigurable { } if FeatureFlag.personalizeHomeTab.enabled { - frameView.onEllipsisButtonTap = { - BlogDashboardAnalytics.trackContextualMenuAccessed(for: .todaysStats) - } - frameView.ellipsisButton.showsMenuAsPrimaryAction = true - frameView.ellipsisButton.menu = UIMenu(title: "", options: .displayInline, children: [ - BlogDashboardHelpers.makeHideCardAction(for: .todaysStats, siteID: blog.dotComID?.intValue ?? 0) - ]) + frameView.addMoreMenu(items: [ + BlogDashboardHelpers.makeHideCardAction(for: .todaysStats, blog: blog) + ], card: .todaysStats) } statsStackView?.views = viewModel?.todaysViews diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift index 070ea9e501c2..44aa5b4a8c74 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/DashboardCard.swift @@ -154,9 +154,9 @@ enum DashboardCard: String, CaseIterable { .scheduledPosts, .blaze, .prompts, + .quickStart, .pages, .activityLog - .quickStart ] /// Includes all cards that should be fetched from the backend diff --git a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Helpers/BlogDashboardHelpers.swift b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Helpers/BlogDashboardHelpers.swift index beb295506968..de06afc06bf8 100644 --- a/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Helpers/BlogDashboardHelpers.swift +++ b/WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Helpers/BlogDashboardHelpers.swift @@ -1,14 +1,14 @@ import Foundation struct BlogDashboardHelpers { - static func makeHideCardAction(for card: DashboardCard, siteID: Int) -> UIAction { + static func makeHideCardAction(for card: DashboardCard, blog: Blog) -> UIAction { UIAction( title: Strings.hideThis, image: UIImage(systemName: "minus.circle"), attributes: [.destructive], handler: { _ in BlogDashboardAnalytics.trackHideTapped(for: card) - BlogDashboardPersonalizationService(siteID: siteID) + BlogDashboardPersonalizationService(siteID: blog.dotComID?.intValue ?? 0) .setEnabled(false, for: card) }) } diff --git a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift index 6254cfc56b0c..a9187cfa314a 100644 --- a/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift +++ b/WordPress/Classes/ViewRelated/Blog/BlogPersonalization/BlogDashboardPersonalizationViewModel.swift @@ -63,7 +63,7 @@ private extension DashboardCard { case .newSite: return NSLocalizedString("personalizeHome.dashboardCard.nextSteps", value: "Next steps", comment: "Card title for the pesonalization menu") } - case .nextPost, .createPost, .ghost, .failure, .personalize, .jetpackBadge, .jetpackInstall, .empty, .domainsDashboardCard: + case .nextPost, .createPost, .ghost, .failure, .personalize, .jetpackBadge, .jetpackInstall, .empty, .domainsDashboardCard, .freeToPaidPlansDashboardCard, .domainRegistration: assertionFailure("\(self) card should not appear in the personalization menus") return "" // These cards don't appear in the personalization menus }