Skip to content

Commit

Permalink
[Gutenberg] - Remove Gallery V1 and experimental flags (#23411)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkmassel authored Jul 12, 2024
2 parents 13a2405 + cc36e3e commit beb4fd6
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 87 deletions.
2 changes: 1 addition & 1 deletion Gutenberg/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#
# LOCAL_GUTENBERG=../my-gutenberg-fork bundle exec pod install
ref:
tag: v1.120.1
tag: v1.121.0-alpha2
github_org: wordpress-mobile
repo_name: gutenberg-mobile
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PODS:
- WordPress-Aztec-iOS (= 1.19.11)

DEPENDENCIES:
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.120.1.podspec`)
- Gutenberg (from `https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.121.0-alpha2.podspec`)
- SwiftLint (= 0.54.0)
- WordPress-Editor-iOS (~> 1.19.11)

Expand All @@ -19,10 +19,10 @@ SPEC REPOS:

EXTERNAL SOURCES:
Gutenberg:
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.120.1.podspec
:podspec: https://cdn.a8c-ci.services/gutenberg-mobile/Gutenberg-v1.121.0-alpha2.podspec

SPEC CHECKSUMS:
Gutenberg: 0699e7dd207afb591ccd5e81252a92e6e7781391
Gutenberg: ff2d4988d208440f35c1554ef457fca86abf99a9
SwiftLint: c1de071d9d08c8aba837545f6254315bc900e211
WordPress-Aztec-iOS: 3732c6d865a5c9f35788377bdeda8a80ea10d0a1
WordPress-Editor-iOS: 453345420ced3d3ef20f0051b3df46ff10281e0c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ enum BlockEditorSettingElementTypes: String {
}
}

enum BlockEditorExperimentalFeatureKeys: String {
case galleryWithImageBlocks
case quoteBlockV2
case listBlockV2
}

extension BlockEditorSettingElement {

@nonobjc public class func fetchRequest() -> NSFetchRequest<BlockEditorSettingElement> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,6 @@ extension BlockEditorSettings: GutenbergEditorSettings {
elementsByType(.gradient)
}

public var galleryWithImageBlocks: Bool {
// If site is using WP 5.9+ then return true as galleryWithImageBlocks is supported in WP 5.9+.
// Once support for WP 5.8 is dropped, this can be removed.
// https://github.com/WordPress/gutenberg/issues/47782
if blog.hasRequiredWordPressVersion("5.9") {
return true
} else {
return experimentalFeature(.galleryWithImageBlocks)
}
}

public var quoteBlockV2: Bool {
return experimentalFeature(.quoteBlockV2)
}

public var listBlockV2: Bool {
return experimentalFeature(.listBlockV2)
}

private func elementsByType(_ type: BlockEditorSettingElementTypes) -> [[String: String]]? {
return elements?.sorted(by: { (lhs, rhs) -> Bool in
return lhs.order >= rhs.order
Expand All @@ -38,15 +19,6 @@ extension BlockEditorSettings: GutenbergEditorSettings {
return element.rawRepresentation
})
}

private func experimentalFeature(_ feature: BlockEditorExperimentalFeatureKeys) -> Bool {
guard let experimentalFeature = elements?.first(where: { (element) -> Bool in
guard element.type == BlockEditorSettingElementTypes.experimentalFeatures.rawValue else { return false }
return element.slug == feature.rawValue
}) else { return false }

return Bool(experimentalFeature.value) ?? false
}
}

extension BlockEditorSettings {
Expand Down Expand Up @@ -88,32 +60,6 @@ extension BlockEditorSettings {
parsedElements.insert(BlockEditorSettingElement(fromRawRepresentation: gradient, type: .gradient, order: index, context: context))
})

// Experimental Features
let galleryKey = BlockEditorExperimentalFeatureKeys.galleryWithImageBlocks.rawValue
let galleryRefactor = BlockEditorSettingElement(name: galleryKey,
value: "\(remoteSettings.galleryWithImageBlocks)",
slug: galleryKey,
type: .experimentalFeatures,
order: 0,
context: context)
let quoteKey = BlockEditorExperimentalFeatureKeys.quoteBlockV2.rawValue
let quoteRefactor = BlockEditorSettingElement(name: quoteKey,
value: "\(remoteSettings.quoteBlockV2)",
slug: quoteKey,
type: .experimentalFeatures,
order: 1,
context: context)
let listKey = BlockEditorExperimentalFeatureKeys.listBlockV2.rawValue
let listRefactor = BlockEditorSettingElement(name: listKey,
value: "\(remoteSettings.listBlockV2)",
slug: listKey,
type: .experimentalFeatures,
order: 2,
context: context)
parsedElements.insert(galleryRefactor)
parsedElements.insert(quoteRefactor)
parsedElements.insert(listRefactor)

self.elements = parsedElements
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -874,13 +874,11 @@ extension GutenbergViewController: GutenbergBridgeDelegate {

func gutenbergDidMount(unsupportedBlockNames: [String]) {
if !editorSession.started {
let galleryWithImageBlocks = gutenbergEditorSettings()?.galleryWithImageBlocks

// Note that this method is also used to track startup performance
// It assumes this is being called when the editor has finished loading
// If you need to refactor this, please ensure that the startup_time_ms property
// is still reflecting the actual startup time of the editor
editorSession.start(unsupportedBlocks: unsupportedBlockNames, galleryWithImageBlocks: galleryWithImageBlocks)
editorSession.start(unsupportedBlocks: unsupportedBlockNames)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ struct PostEditorAnalyticsSession {
contentType = ContentType(post: post).rawValue
}

mutating func start(unsupportedBlocks: [String] = [], galleryWithImageBlocks: Bool? = nil) {
mutating func start(unsupportedBlocks: [String] = []) {
assert(!started, "An editor session was attempted to start more than once")
hasUnsupportedBlocks = !unsupportedBlocks.isEmpty

let properties = startEventProperties(with: unsupportedBlocks, galleryWithImageBlocks: galleryWithImageBlocks)
let properties = startEventProperties(with: unsupportedBlocks)

WPAppAnalytics.track(.editorSessionStart, withProperties: properties)
started = true
}

private func startEventProperties(with unsupportedBlocks: [String], galleryWithImageBlocks: Bool?) -> [String: Any] {
private func startEventProperties(with unsupportedBlocks: [String]) -> [String: Any] {
// On Android, we are tracking this in milliseconds, which seems like a good enough time scale
// Let's make sure to round the value and send an integer for consistency
let startupTimeNanoseconds = DispatchTime.now().uptimeNanoseconds - startTime
Expand All @@ -44,12 +44,6 @@ struct PostEditorAnalyticsSession {
properties[Property.unsupportedBlocks] = blocksJSON
}

if let galleryWithImageBlocks = galleryWithImageBlocks {
properties[Property.unstableGalleryWithImageBlocks] = "\(galleryWithImageBlocks)"
} else {
properties[Property.unstableGalleryWithImageBlocks] = "unknown"
}

properties[Property.entryPoint] = (entryPoint ?? .unknown).rawValue

return properties.merging(commonProperties, uniquingKeysWith: { $1 })
Expand Down Expand Up @@ -84,7 +78,6 @@ private extension PostEditorAnalyticsSession {
static let sessionId = "session_id"
static let template = "template"
static let startupTime = "startup_time_ms"
static let unstableGalleryWithImageBlocks = "unstable_gallery_with_image_blocks"
static let entryPoint = "entry_point"
}

Expand Down
2 changes: 1 addition & 1 deletion WordPress/UITests/Tests/EditorGutenbergTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class EditorGutenbergTests: XCTestCase {
.enterTextInTitle(text: postTitle)
.addParagraphBlock(withText: postContent)
.addImageGallery()
.verifyContentStructure(blocks: 2, words: postContent.components(separatedBy: " ").count, characters: postContent.count)
.verifyContentStructure(blocks: 5, words: postContent.components(separatedBy: " ").count, characters: postContent.count)
}

func testAddMediaBlocks() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ import Foundation
public class RemoteBlockEditorSettings: Codable {
enum CodingKeys: String, CodingKey {
case isFSETheme = "__unstableIsBlockBasedTheme"
case galleryWithImageBlocks = "__unstableGalleryWithImageBlocks"
case quoteBlockV2 = "__experimentalEnableQuoteBlockV2"
case listBlockV2 = "__experimentalEnableListBlockV2"
case rawStyles = "__experimentalStyles"
case rawFeatures = "__experimentalFeatures"
case colors
case gradients
}

public let isFSETheme: Bool
public let galleryWithImageBlocks: Bool
public let quoteBlockV2: Bool
public let listBlockV2: Bool
public let rawStyles: String?
public let rawFeatures: String?
public let colors: [[String: String]]?
Expand All @@ -40,9 +34,6 @@ public class RemoteBlockEditorSettings: Codable {
required public init(from decoder: Decoder) throws {
let map = try decoder.container(keyedBy: CodingKeys.self)
self.isFSETheme = (try? map.decode(Bool.self, forKey: .isFSETheme)) ?? false
self.galleryWithImageBlocks = (try? map.decode(Bool.self, forKey: .galleryWithImageBlocks)) ?? false
self.quoteBlockV2 = (try? map.decode(Bool.self, forKey: .quoteBlockV2)) ?? false
self.listBlockV2 = (try? map.decode(Bool.self, forKey: .listBlockV2)) ?? false
self.rawStyles = RemoteBlockEditorSettings.parseToString(map, .rawStyles)
self.rawFeatures = RemoteBlockEditorSettings.parseToString(map, .rawFeatures)
self.colors = try? map.decode([[String: String]].self, forKey: .colors)
Expand Down

0 comments on commit beb4fd6

Please sign in to comment.