Skip to content

Commit ed4993b

Browse files
committed
Updates cell settings
1 parent 25027fc commit ed4993b

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

Sources/PulseUI/Extensions/Pulse+Extensions.swift

+6-3
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,12 @@ extension NetworkTaskEntity {
140140
guard let url else {
141141
return nil
142142
}
143-
let displayed = options.content.components
144-
if displayed.count == ConsoleListDisplaySettings.URLComponent.allCases.count {
145-
return url
143+
return NetworkTaskEntity.formattedURL(url, components: options.content.components)
144+
}
145+
146+
static func formattedURL(_ url: String, components displayed: Set<ConsoleListDisplaySettings.URLComponent>) -> String? {
147+
guard !displayed.isEmpty else {
148+
return nil
146149
}
147150
guard var components = URLComponents(string: url) else {
148151
return nil

Sources/PulseUI/Features/Console/Views/ConsoleListDisplaySettings.swift

+7-8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
3939
/// If task description is available, show it instead of the `URL`.
4040
public var showTaskDescription = false
4141

42+
/// Show HTTP method when available.
43+
public var showMethod = true
44+
4245
/// Defines what components to display in the list. By default, shows
4346
/// only path.
4447
public var components: Set<URLComponent> = [.path]
@@ -59,13 +62,11 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
5962
public var lineLimit: Int = 1
6063
}
6164

62-
public enum URLComponent: String, Identifiable, CaseIterable, Codable {
65+
public enum URLComponent: String, CaseIterable, Codable {
6366
case scheme, user, password, host, port, path, query, fragment
64-
65-
public var id: URLComponent { self }
6667
}
6768

68-
public enum TaskField: Sendable, Codable, Hashable, Identifiable {
69+
public enum TaskField: Sendable, Codable, Hashable {
6970
case method
7071
case requestSize
7172
case responseSize
@@ -75,10 +76,8 @@ public struct ConsoleListDisplaySettings: Hashable, Codable {
7576
case statusCode
7677
case taskType
7778
case taskDescription
78-
case requestHeaderField(key: String)
79-
case responseHeaderField(key: String)
80-
81-
public var id: TaskField { self }
79+
case requestHeaderField(String)
80+
case responseHeaderField(String)
8281
}
8382

8483
public init() {}

Sources/PulseUI/Features/Console/Views/ConsoleTaskCell.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct ConsoleTaskCell: View {
102102

103103
private var content: some View {
104104
var method: Text? {
105-
guard let method = task.httpMethod else {
105+
guard settings.listDisplayOptions.content.showMethod, let method = task.httpMethod else {
106106
return nil
107107
}
108108
return Text(method.appending(" "))

0 commit comments

Comments
 (0)