Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Domain Management] Add My Domains to Me Screen #21701

Merged
merged 8 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ enum RemoteFeatureFlag: Int, CaseIterable {
case .jetpackSocialImprovements:
return AppConfiguration.isJetpack
case .domainManagement:
return false
return false // TODO: Update as `AppConfiguration.isJetpack`
case .plansInSiteCreation:
return false
case .readerImprovements:
Expand Down
43 changes: 33 additions & 10 deletions WordPress/Classes/ViewRelated/Me/Me Main/MeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,8 @@ class MeViewController: UITableViewController {

let shouldShowQRLoginRow = AppConfiguration.qrLoginEnabled && !(account?.settings?.twoStepEnabled ?? false)

return ImmuTable(sections: [
// first section
.init(rows: {
var sections: [ImmuTableSection] = [
ImmuTableSection(rows: {
var rows: [ImmuTableRow] = [appSettingsRow]
if loggedIn {
var loggedInRows = [myProfile, accountSettings]
Expand All @@ -196,9 +195,8 @@ class MeViewController: UITableViewController {
}
return rows
}()),

// middle section
.init(rows: {
ImmuTableSection(rows: {
var rows: [ImmuTableRow] = [helpAndSupportIndicator]

rows.append(NavigationItemRow(title: ShareAppContentPresenter.RowConstants.buttonTitle,
Expand All @@ -214,13 +212,33 @@ class MeViewController: UITableViewController {
accessibilityIdentifier: "About"))

return rows
}()),
}())
]

#if JETPACK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Why are we using macros here? Have you considered using AppConfiguration.isJetpack?

Copy link
Contributor

@salimbraksa salimbraksa Oct 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can answer this question as it was my suggestion @hassaanelgarem.

Without the macro, the MyDomainsViewController files and all the files that depend on it would have to be added to WordPress target too. Even though the My Domains screen is for Jetpack only.

And if we remove those files from WordPress target, then the WordPress app won't build.

@alpavanoglu considered using isJetpack flag but that doesn't fix this problem.

if RemoteFeatureFlag.domainManagement.enabled() {
sections.append(.init(headerText: HeaderTitles.products, rows: {
return [
ButtonRow(title: MyDomainsViewController.Strings.title) { action in
let controller = MyDomainsViewController()
let navigationController = UINavigationController(rootViewController: controller)
self.present(navigationController, animated: true) {
self.tableView.deselectSelectedRowWithAnimation(true)
}
}
]
}()))
}
#endif

// last section
// last section
sections.append(
.init(headerText: wordPressComAccount, rows: {
return [loggedIn ? logOut : logIn]
}())
])
)

return ImmuTable(sections: sections)
}

// MARK: - UITableViewDelegate
Expand Down Expand Up @@ -374,8 +392,8 @@ class MeViewController: UITableViewController {
}

if let sections = handler?.viewModel.sections,
let section = sections.firstIndex(where: { $0.rows.contains(where: matchRow) }),
let row = sections[section].rows.firstIndex(where: matchRow) {
let section = sections.firstIndex(where: { $0.rows.contains(where: matchRow) }),
let row = sections[section].rows.firstIndex(where: matchRow) {
let indexPath = IndexPath(row: row, section: section)

tableView.selectRow(at: indexPath, animated: true, scrollPosition: .middle)
Expand Down Expand Up @@ -574,6 +592,11 @@ private extension MeViewController {

enum HeaderTitles {
static let wpAccount = NSLocalizedString("WordPress.com Account", comment: "WordPress.com sign-in/sign-out section header title")
static let products = NSLocalizedString(
"me.products.header",
value: "Products",
comment: "Products header text in Me Screen."
)
}

enum LogoutAlert {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import UIKit

final class MyDomainsViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
title = Strings.title

WPStyleGuide.configureColors(view: view, tableView: nil)
let action = UIAction { _ in
// Present add domain screen.
}
navigationItem.rightBarButtonItem = .init(systemItem: .add, primaryAction: action)
}
}

extension MyDomainsViewController {
enum Strings {
static let title = NSLocalizedString(
"domain.management.title",
value: "My Domains",
comment: "Domain Management Screen Title"
)
}
}
12 changes: 12 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@
03216ECD27995F3500D444CA /* SchedulingViewControllerPresenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03216ECB27995F3500D444CA /* SchedulingViewControllerPresenter.swift */; };
069A4AA62664448F00413FA9 /* GutenbergFeaturedImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069A4AA52664448F00413FA9 /* GutenbergFeaturedImageHelper.swift */; };
069A4AA72664448F00413FA9 /* GutenbergFeaturedImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 069A4AA52664448F00413FA9 /* GutenbergFeaturedImageHelper.swift */; };
080544722AD06667001E1A36 /* MyDomainsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08D61F202AD0635100BF3D00 /* MyDomainsViewController.swift */; };
0807CB721CE670A800CDBDAC /* WPContentSearchHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0807CB711CE670A800CDBDAC /* WPContentSearchHelper.swift */; };
080C44A91CE14A9F00B3A02F /* MenuDetailsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 080C449E1CE14A9F00B3A02F /* MenuDetailsViewController.m */; };
0815CF461E96F22600069916 /* MediaImportService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0815CF451E96F22600069916 /* MediaImportService.swift */; };
Expand Down Expand Up @@ -6018,6 +6019,7 @@
08D499661CDD20450004809A /* Menus.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Menus.storyboard; sourceTree = "<group>"; };
08D4C0E61C76F14E002E5BF6 /* WordPress 47.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "WordPress 47.xcdatamodel"; sourceTree = "<group>"; };
08D553652821286300AA1E8D /* Tooltip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tooltip.swift; sourceTree = "<group>"; };
08D61F202AD0635100BF3D00 /* MyDomainsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyDomainsViewController.swift; sourceTree = "<group>"; };
08D9784B1CD2AF7D0054F19A /* Menu+ViewDesign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Menu+ViewDesign.h"; sourceTree = "<group>"; };
08D9784C1CD2AF7D0054F19A /* Menu+ViewDesign.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "Menu+ViewDesign.m"; sourceTree = "<group>"; };
08D9784D1CD2AF7D0054F19A /* MenuItem+ViewDesign.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MenuItem+ViewDesign.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -10108,6 +10110,14 @@
name = "View Models";
sourceTree = "<group>";
};
08D61F1F2AD0633600BF3D00 /* MyDomains */ = {
isa = PBXGroup;
children = (
08D61F202AD0635100BF3D00 /* MyDomainsViewController.swift */,
);
path = MyDomains;
sourceTree = "<group>";
};
08D978491CD2AF7D0054F19A /* Menus */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -10983,6 +10993,7 @@
3F29EB6F2404218E005313DE /* Help & Support */,
3F29EB6B24041FFC005313DE /* Me Main */,
3F29EB6D24042093005313DE /* My Profile */,
08D61F1F2AD0633600BF3D00 /* MyDomains */,
);
path = Me;
sourceTree = "<group>";
Expand Down Expand Up @@ -24128,6 +24139,7 @@
FABB21FD2602FC2C00C8785C /* ActivityUtils.swift in Sources */,
FABB21FE2602FC2C00C8785C /* WPLogger.m in Sources */,
FABB21FF2602FC2C00C8785C /* JetpackBackupStatusCoordinator.swift in Sources */,
080544722AD06667001E1A36 /* MyDomainsViewController.swift in Sources */,
3F720C222889B65B00519938 /* JetpackBrandingVisibility.swift in Sources */,
0C35FFF729CBB5DE00D224EB /* BlogDashboardEmptyStateCell.swift in Sources */,
FABB22012602FC2C00C8785C /* RevisionDiff.swift in Sources */,
Expand Down