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

Enable site creation for WP users with no sites #22415

Merged
merged 21 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
61f0f31
Enable site creation for WP users with no sites
alpavanoglu Jan 18, 2024
75e8418
Pass in blog to check for domains
alpavanoglu Jan 18, 2024
8ebc238
Update passed blog values to fetch from core data
alpavanoglu Jan 18, 2024
da3ced6
Update release notes
alpavanoglu Jan 18, 2024
272ac13
Address change requests
alpavanoglu Jan 19, 2024
760e5b7
Remove unused blog instances
alpavanoglu Jan 19, 2024
151d3c4
Disable plan step for WordPress app
alpavanoglu Jan 19, 2024
5fce8cf
Fix tests
alpavanoglu Jan 19, 2024
2d9c826
Add `compliancePopoverCoordinator` to `PostSignUpInterstitialViewCont…
alpavanoglu Jan 28, 2024
1914910
Temp
alpavanoglu Jan 29, 2024
5cff94e
Fix overlay presentation on sign up
alpavanoglu Jan 30, 2024
3d1bb4e
Update for change request
alpavanoglu Jan 30, 2024
3dd9716
Apply change requests
alpavanoglu Jan 31, 2024
cf69359
Merge branch 'trunk' of github.com:wordpress-mobile/WordPress-iOS int…
alpavanoglu Jan 31, 2024
49c4920
Refactor popover display logic
alpavanoglu Jan 31, 2024
e0f7f63
Combine overlay logic in `MySiteOverlaysCoordinator`
alpavanoglu Jan 31, 2024
fed4475
Add `isSiteCreationActive` calls to site creation call sites
alpavanoglu Jan 31, 2024
d6ee40c
Set `isSiteCreationActive` to false on dismiss
alpavanoglu Jan 31, 2024
ffe97ce
Add refresh UI call to site creation cancellation
alpavanoglu Feb 1, 2024
56c1015
Remove `reloadPostSiteCreationCancellationIfNeeded`
alpavanoglu Feb 2, 2024
6ee4ae9
Add private access modifier back to `hasBlog`
alpavanoglu Feb 2, 2024
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
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* [**] Block Editor: Media uploads that failed due to lack of internet connectivity automatically retry once a connection is re-established [https://github.com/wordpress-mobile/WordPress-iOS/pull/22238]
* [**] Block Editor: Manually retrying a single failed media upload will retry all failed media uploads in a post [https://github.com/wordpress-mobile/WordPress-iOS/pull/22240]
* [*] [internal] Drop iOS 14 Support: Remove deprecated UIDocumentPickerViewController API [#22286]
* [**] [internal] Site creation is re-enabled for WordPress users with no sites. [#22415]

24.0
-----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="20037" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="22505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="20020"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -30,7 +30,7 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="w31-gj-Dsv">
<rect key="frame" x="20" y="124" width="374" height="586"/>
<rect key="frame" x="20" y="128" width="374" height="582"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="16" translatesAutoresizingMaskIntoConstraints="NO" id="wS6-OQ-uc5">
<rect key="frame" x="0.0" y="0.0" width="374" height="110"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ final class DomainSelectionViewController: CollapsableHeaderViewController {
return
}


trackDomainsSelection(selectedDomain)

let onFailure: () -> () = { [weak self] in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class JetpackFeaturesRemovalCoordinator: NSObject {
if RemoteFeatureFlag.jetpackFeaturesRemovalPhaseNewUsers.enabled(using: featureFlagStore)
|| RemoteFeatureFlag.jetpackFeaturesRemovalPhaseFour.enabled(using: featureFlagStore)
|| RemoteFeatureFlag.jetpackFeaturesRemovalStaticPosters.enabled(using: featureFlagStore) {
return .two
return Self.hasBlog() ? .two : .normal
}
if RemoteFeatureFlag.jetpackFeaturesRemovalPhaseThree.enabled(using: featureFlagStore)
|| RemoteFeatureFlag.jetpackFeaturesRemovalPhaseTwo.enabled(using: featureFlagStore)
Expand Down Expand Up @@ -290,12 +290,16 @@ class JetpackFeaturesRemovalCoordinator: NSObject {
presentOverlay(navigationViewController: navigationViewController, in: viewController)
}

private static func presentOverlay(navigationViewController: UINavigationController,
in viewController: UIViewController,
fullScreen: Bool = false) {
static func presentOverlay(navigationViewController: UINavigationController,
in viewController: UIViewController,
fullScreen: Bool = false) {
let shouldUseFormSheet = WPDeviceIdentification.isiPad() || !fullScreen
navigationViewController.modalPresentationStyle = shouldUseFormSheet ? .formSheet : .fullScreen

viewController.present(navigationViewController, animated: true)
}

private static func hasBlog() -> Bool {
Blog.count(in: ContextManager.sharedInstance().mainContext) > 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ final class SiteAssemblyWizardContent: UIViewController {

if configuration.dismissalActionHandler == nil {
configuration.dismissalActionHandler = { [weak self] in
guard let self = self else {
guard let self else {
return
}
self.dismissTapped()
Expand All @@ -255,6 +255,10 @@ final class SiteAssemblyWizardContent: UIViewController {

self.errorStateViewController = errorStateViewController
}

private func shouldPresentJetpackFeaturesRemovalOverlay() -> Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this should be removed?

AppConfiguration.isWordPress && Blog.count(in: ContextManager.sharedInstance().mainContext) == 1
}
}

// MARK: ErrorStateViewController support
Expand Down Expand Up @@ -309,6 +313,20 @@ extension SiteAssemblyWizardContent: NUXButtonViewControllerDelegate {
guard let self = self else {
return
}
if AppConfiguration.isWordPress && Blog.count(in: ContextManager.sharedInstance().mainContext) == 1 {
let viewModel = JetpackFullscreenOverlayGeneralViewModel(
phase: .four,
source: .phaseFourOverlay,
blog: blog,
coordinator: JetpackDefaultOverlayCoordinator()
)
let overlayViewController = JetpackFullscreenOverlayViewController(with: viewModel)
let navigationViewController = UINavigationController(rootViewController: overlayViewController)
JetpackFeaturesRemovalCoordinator.presentOverlay(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think there's a need to manually trigger an overlay.
Correctly configuring MySiteViewController.willDisplayPostSignupFlow before triggering the site creation flow should stop the overlay from being presented at the wrong time and should then automatically be displayed after the site is created.

navigationViewController: navigationViewController,
in: RootViewCoordinator.sharedPresenter.rootViewController
)
}
let completedSteps: [QuickStartTour] = self.siteCreator.hasSiteTitle ? [QuickStartSiteTitleTour(blog: blog)] : []
self.showQuickStartPrompt(for: blog, completedSteps: completedSteps)
}
Expand All @@ -319,6 +337,11 @@ extension SiteAssemblyWizardContent: NUXButtonViewControllerDelegate {
return
}

// Disable the prompt for WordPress when the blog has no domains.
guard AppConfiguration.isJetpack || isDashboardEnabled(for: blog) else {
return
}

let rootViewController = RootViewCoordinator.sharedPresenter.rootViewController
let quickstartPrompt = QuickStartPromptViewController(blog: blog)
quickstartPrompt.onDismiss = { blog, showQuickStart in
Expand All @@ -328,4 +351,8 @@ extension SiteAssemblyWizardContent: NUXButtonViewControllerDelegate {
}
rootViewController.present(quickstartPrompt, animated: true)
}

private func isDashboardEnabled(for blog: Blog) -> Bool {
return JetpackFeaturesRemovalCoordinator.jetpackFeaturesEnabled() && blog.isAccessibleThroughWPCom()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class SiteCreationWizardLauncher {
}()

let steps: [SiteCreationStep] = {
if RemoteFeatureFlag.plansInSiteCreation.enabled() {
if RemoteFeatureFlag.plansInSiteCreation.enabled() && !AppConfiguration.isWordPress {
Copy link
Contributor

Choose a reason for hiding this comment

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

[Nit] I think this is more readable:

Suggested change
if RemoteFeatureFlag.plansInSiteCreation.enabled() && !AppConfiguration.isWordPress {
if RemoteFeatureFlag.plansInSiteCreation.enabled() && AppConfiguration.isJetpack {

return [
.intent,
.design,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase {
override func setUp() {
contextManager.useAsSharedInstance(untilTestFinished: self)
mockUserDefaults = InMemoryUserDefaults()
let account = AccountBuilder(contextManager.mainContext).build()
let account = AccountBuilder(contextManager.mainContext).with(username: "test-account-JetpackFeaturesRemovalCoordinatorTests").build()
UserSettings.defaultDotComUUID = account.uuid
}

Expand Down Expand Up @@ -250,16 +250,17 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase {
XCTAssertEqual(phase, .one)
}

func testSiteCreationPhaseTwo() {
func testSiteCreationPhaseTwo() throws {
// Given
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults)

// When
var flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false)
let remote = MockFeatureFlagRemote(flags: flags)
store.update(using: remote, waitOn: self)
let blog = BlogBuilder(mainContext).build()
try mainContext.save()
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store)

// Then
XCTAssertEqual(phase, .two)

Expand All @@ -273,14 +274,38 @@ final class JetpackFeaturesRemovalCoordinatorTests: CoreDataTestCase {
XCTAssertEqual(phase, .two)
}

func testSiteCreationPhaseTwoPrecedence() {
func testSiteCreationPhaseNormalWhenUserHasNoBlog() throws {
// Given
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults)

// When
var flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false)
let remote = MockFeatureFlagRemote(flags: flags)
store.update(using: remote, waitOn: self)
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store)
// Then
XCTAssertEqual(phase, .normal)

// When
flags = generateFlags(phaseOne: false, phaseTwo: false, phaseThree: false, phaseFour: false, phaseNewUsers: true, phaseSelfHosted: false)
remote.flags = flags
store.update(using: remote, waitOn: self)
phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store)

// Then
XCTAssertEqual(phase, .normal)
}

func testSiteCreationPhaseTwoPrecedence() throws {
// Given
let store = RemoteFeatureFlagStore(persistenceStore: mockUserDefaults)

// When
var flags = generateFlags(phaseOne: true, phaseTwo: true, phaseThree: true, phaseFour: true, phaseNewUsers: false, phaseSelfHosted: false)
let remote = MockFeatureFlagRemote(flags: flags)
store.update(using: remote, waitOn: self)
let blog = BlogBuilder(mainContext).build()
try mainContext.save()
var phase = JetpackFeaturesRemovalCoordinator.siteCreationPhase(featureFlagStore: store)

// Then
Expand Down