Skip to content

Commit

Permalink
Updates cell settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Sep 15, 2024
1 parent 25027fc commit ed4993b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
9 changes: 6 additions & 3 deletions Sources/PulseUI/Extensions/Pulse+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ extension NetworkTaskEntity {
guard let url else {
return nil
}
let displayed = options.content.components
if displayed.count == ConsoleListDisplaySettings.URLComponent.allCases.count {
return url
return NetworkTaskEntity.formattedURL(url, components: options.content.components)
}

static func formattedURL(_ url: String, components displayed: Set<ConsoleListDisplaySettings.URLComponent>) -> String? {
guard !displayed.isEmpty else {
return nil
}
guard var components = URLComponents(string: url) else {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
/// If task description is available, show it instead of the `URL`.
public var showTaskDescription = false

/// Show HTTP method when available.
public var showMethod = true

/// Defines what components to display in the list. By default, shows
/// only path.
public var components: Set<URLComponent> = [.path]
Expand All @@ -59,13 +62,11 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
public var lineLimit: Int = 1
}

public enum URLComponent: String, Identifiable, CaseIterable, Codable {
public enum URLComponent: String, CaseIterable, Codable {
case scheme, user, password, host, port, path, query, fragment

public var id: URLComponent { self }
}

public enum TaskField: Sendable, Codable, Hashable, Identifiable {
public enum TaskField: Sendable, Codable, Hashable {
case method
case requestSize
case responseSize
Expand All @@ -75,10 +76,8 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
case statusCode
case taskType
case taskDescription
case requestHeaderField(key: String)
case responseHeaderField(key: String)

public var id: TaskField { self }
case requestHeaderField(String)
case responseHeaderField(String)
}

public init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ struct ConsoleTaskCell: View {

private var content: some View {
var method: Text? {
guard let method = task.httpMethod else {
guard settings.listDisplayOptions.content.showMethod, let method = task.httpMethod else {
return nil
}
return Text(method.appending(" "))
Expand Down

0 comments on commit ed4993b

Please sign in to comment.