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

Add editor onboarding capability #16406

Merged
merged 10 commits into from
May 13, 2021
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ abstract_target 'Apps' do
## Gutenberg (React Native)
## =====================
##
gutenberg :tag => 'v1.52.0'
gutenberg :commit => '214e7b5314c4a30fc662493597a166aa00a957e2'


## Third party libraries
Expand Down
166 changes: 83 additions & 83 deletions Podfile.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/// This structs helps encapsulate logic related to Gutenberg editor onboarding rollout phases.
///
struct GutenbergOnboardingRollout {
private let phasePercentage = 0

func isUserIdInPhaseRolloutPercentage(_ userId: Int) -> Bool {
return userId % 100 >= (100 - phasePercentage) || BuildConfiguration.current ~= [.localDeveloper, .a8cBranchTest]
}
}
18 changes: 18 additions & 0 deletions WordPress/Classes/Utility/Editor/GutenbergSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class GutenbergSettings {
return "kShowGutenbergPhase2Dialog-" + url
}
static let focalPointPickerTooltipShown = "kGutenbergFocalPointPickerTooltipShown"
static let hasLaunchedGutenbergEditor = "kHasLaunchedGutenbergEditor"

private static func urlStringFrom(_ blog: Blog) -> String {
return (blog.url ?? "")
Expand Down Expand Up @@ -168,6 +169,23 @@ class GutenbergSettings {
}
}

func canViewEditorOnboarding() -> Bool {
guard
ReachabilityUtils.isInternetReachable(),
let account = AccountService(managedObjectContext: context).defaultWordPressComAccount()
else {
return false
}

let rollout = GutenbergOnboardingRollout()
let hasLaunchedGutenbergEditor = database.bool(forKey: Key.hasLaunchedGutenbergEditor)
return rollout.isUserIdInPhaseRolloutPercentage(account.userID.intValue) && !hasLaunchedGutenbergEditor
}

func setHasLaunchedGutenbergEditor(_ hasLaunched: Bool) {
database.set(hasLaunched, forKey: Key.hasLaunchedGutenbergEditor)
}

// MARK: - Gutenberg Choice Logic

func isSimpleWPComSite(_ blog: Blog) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,8 @@ extension GutenbergViewController: GutenbergBridgeDelegate {
// is still reflecting the actual startup time of the editor
editorSession.start(unsupportedBlocks: unsupportedBlockNames)
}

gutenbergSettings.setHasLaunchedGutenbergEditor(true)
}

func gutenbergDidEmitLog(message: String, logLevel: LogLevel) {
Expand Down Expand Up @@ -1052,7 +1054,8 @@ extension GutenbergViewController: GutenbergBridgeDataSource {
.unsupportedBlockEditor: isUnsupportedBlockEditorEnabled,
.canEnableUnsupportedBlockEditor: post.blog.jetpack?.isConnected ?? false,
.audioBlock: !isFreeWPCom, // Disable audio block until it's usable on free sites via "Insert from URL" capability
.mediaFilesCollectionBlock: FeatureFlag.stories.enabled && post.blog.supports(.stories) && !UIDevice.isPad()
.mediaFilesCollectionBlock: FeatureFlag.stories.enabled && post.blog.supports(.stories) && !UIDevice.isPad(),
.canViewEditorOnboarding: gutenbergSettings.canViewEditorOnboarding()
]
}

Expand Down
6 changes: 6 additions & 0 deletions WordPress/WordPress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@
2F08ECFC2283A4FB000F8E11 /* PostService+UnattachedMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F08ECFB2283A4FB000F8E11 /* PostService+UnattachedMedia.swift */; };
2F09D134245223D300956257 /* HeaderDetailsContentStyles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F09D133245223D300956257 /* HeaderDetailsContentStyles.swift */; };
2F161B0622CC2DC70066A5C5 /* LoadingStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F161B0522CC2DC70066A5C5 /* LoadingStatusView.swift */; };
2F54D0A52633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */; };
2F54D0A62633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */; };
2F605FA8251430C200F99544 /* PostCategoriesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F605FA7251430C200F99544 /* PostCategoriesViewController.swift */; };
2F605FAA25145F7200F99544 /* WPCategoryTree.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F605FA925145F7200F99544 /* WPCategoryTree.swift */; };
2F668B61255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F668B5E255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift */; };
Expand Down Expand Up @@ -4740,6 +4742,7 @@
2F08ECFB2283A4FB000F8E11 /* PostService+UnattachedMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostService+UnattachedMedia.swift"; sourceTree = "<group>"; };
2F09D133245223D300956257 /* HeaderDetailsContentStyles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HeaderDetailsContentStyles.swift; sourceTree = "<group>"; };
2F161B0522CC2DC70066A5C5 /* LoadingStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingStatusView.swift; sourceTree = "<group>"; };
2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GutenbergOnboardingRollout.swift; sourceTree = "<group>"; };
2F605FA7251430C200F99544 /* PostCategoriesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCategoriesViewController.swift; sourceTree = "<group>"; };
2F605FA925145F7200F99544 /* WPCategoryTree.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WPCategoryTree.swift; sourceTree = "<group>"; };
2F668B5E255DD11400D0038A /* JetpackSpeedUpSiteSettingsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JetpackSpeedUpSiteSettingsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -13521,6 +13524,7 @@
F115308021B17E65002F1D65 /* EditorFactory.swift */,
FF54D4631D6F3FA900A0DC4D /* GutenbergSettings.swift */,
1E9D544C23C4C56300F6A9E0 /* GutenbergRollout.swift */,
2F54D0A42633424E0045F409 /* GutenbergOnboardingRollout.swift */,
);
path = Editor;
sourceTree = "<group>";
Expand Down Expand Up @@ -17123,6 +17127,7 @@
B5DBE4FE1D21A700002E81D3 /* NotificationsViewController.swift in Sources */,
E1B84F001E02E94D00BF6434 /* PingHubManager.swift in Sources */,
086103961EE09C91004D7C01 /* MediaVideoExporter.swift in Sources */,
2F54D0A52633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */,
E126C81F1F95FC1B00A5F464 /* PluginViewController.swift in Sources */,
E61084C11B9B47BA008050C5 /* ReaderSiteTopic.swift in Sources */,
FAB8004925AEDC2300D5D54A /* JetpackBackupCompleteViewController.swift in Sources */,
Expand Down Expand Up @@ -18844,6 +18849,7 @@
FABB23172602FC2C00C8785C /* ShadowView.swift in Sources */,
FABB23182602FC2C00C8785C /* Wizard.swift in Sources */,
FABB23192602FC2C00C8785C /* Media+WPMediaAsset.m in Sources */,
2F54D0A62633424E0045F409 /* GutenbergOnboardingRollout.swift in Sources */,
FABB231A2602FC2C00C8785C /* GutenbergImgUploadProcessor.swift in Sources */,
FABB231B2602FC2C00C8785C /* PluginListViewModel.swift in Sources */,
FABB231C2602FC2C00C8785C /* WPStyleGuide+People.swift in Sources */,
Expand Down