Skip to content

Commit ff906e0

Browse files
authored
Merge pull request #232 from chadmorales/add_output_file
Add output_file parameter for type -onboarding
2 parents 2fbaec1 + 7f5c7fc commit ff906e0

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

Notification Agent Core/Controllers/HelpBuilder.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ public final class HelpBuilder {
7070
"-background_panel".yellow(),
7171
"-unmovable".yellow(),
7272
"-timeout".yellow(),
73-
"-disable_quit".yellow()]
73+
"-disable_quit".yellow(),
74+
"-output_file".yellow()]
7475
static let systemAlertArguments: [String] = ["-type".green(),
7576
"-title".yellow(),
7677
"-subtitle".yellow(),
@@ -162,7 +163,8 @@ public final class HelpBuilder {
162163
"[ opaque | translucent ]".red() + "\n The style for the background panel that will cover all the screens.\n Example: -background_panel opaque",
163164
"\n Flag that make the UI unmovable for the user.\n Example: -unmovable",
164165
"\n The timeout for the onboarding. After this amount of seconds the agent exit with the timeout exit code.\n Example: -timeout 300",
165-
"\n Flag that tells the agent to ignore cmd+q shortcut.\n Example: -disable_quit"]
166+
"\n Flag that tells the agent to ignore cmd+q shortcut.\n Example: -disable_quit",
167+
"[ filename.plist ]".red() + "\n Flag that tells the agent the filename used to store onboarding output.\n Example: -output_file custom.plist"]
166168
static let systemAlertDescriptions: [String] = ["[ systemAlert ]".red() + "\n The UI type of the notification.\n Example: -type systemAlert",
167169
"\n The title of the notification.\n Example: -title \"Title\"",
168170
"\n The subtitle of the notification.\n Example: -subtitle \"Subtitle\"",

Notification Agent Onboarding UI Tests/NAOUITests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class NAOUITests: XCTestCase {
1414
/// Testing simple Onboarding UI
1515
func testA1Onboarding() throws {
1616
let useCase = """
17-
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"pages":[{"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"hideTitleBar":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
17+
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"outputFile":"custom.plist","pages":[{"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"hideTitleBar":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
1818
""" // pragma: allowlist-secret
1919
if let useCaseData = useCase.data(using: .utf8) {
2020
let app = XCUIApplication()
@@ -54,7 +54,7 @@ class NAOUITests: XCTestCase {
5454
/// Testing simple Onboarding UI with accessory views.
5555
func testA2Onboarding() throws {
5656
let useCase = """
57-
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"pages":[{"accessoryViews":[[{"type":"image","payload":"https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif?crop=780%2C520%2Cx0%2Cy0&width=2200"},{"type":"image","payload":"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg"}]],"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"hideTitleBar":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
57+
{"notification":{"retainValues":false,"isMovable":true,"type":"onboarding","mainButton":{"label":"OK","callToActionType":"none","callToActionPayload":""},"barTitle":"IBM Notifier","alwaysOnTop":false,"showSuppressionButton":false,"hideTitleBarButtons":false,"accessoryViews":[],"payload":{"outputFile":"custom.plist","pages":[{"accessoryViews":[[{"type":"image","payload":"https://compote.slate.com/images/697b023b-64a5-49a0-8059-27b963453fb1.gif?crop=780%2C520%2Cx0%2Cy0&width=2200"},{"type":"image","payload":"https://cdn.pixabay.com/photo/2015/04/23/22/00/tree-736885_1280.jpg"}]],"infoSection":{"fields":[{"id":"BE8ACDC6-1159-421E-8ECA-F84B6B6785ED","label":"Some Description Some"},{"id":"4C045585-72C2-428B-B574-F55CF86E5DCA","label":"Some Description Some"},{"id":"EF546A45-64CA-473D-8BEA-4BF18C3D624F","label":"Some Description Some"}]},"topIcon":"square.and.arrow.up","subtitle":"First page's subtitle","title":"First page's title","body":"First page's body"},{"singleChange":true,"infoSection":{"fields":[{"label":"First label only","id":"031F8516-F122-4A7D-A53C-4F41C9A6C86A"},{"id":"9A2DE192-E512-484E-B42B-2215C84A0B97","label":"Second label only"},{"label":"Third label only","id":"B9F441F5-E55D-4C71-B0BC-53347A4CE6A4"}]},"tertiaryButton":{"callToActionPayload":"https:\\/\\/www.google.com","label":"Tertiary","callToActionType":"link"},"title":"Second page's title","body":"Second page's body","primaryButtonLabel":"Some","subtitle":"Second page's subtitle"},{"title":"Third page's title","body":"Third page's body","singleChange":true,"subtitle":"Third page's subtitle"},{"body":"Fourth page's body","subtitle":"Fourth page's subtitle","title":"Fourth page's title"}],"progressBarPayload":"automatic"},"silent":false,"forceLightMode":false,"disableQuit":false,"buttonless":false,"hideTitleBar":false,"miniaturizable":false,"topicID":"untracked","notificationID":"untracked"},"settings":{"isVerboseModeEnabled":false,"environment":"prod"}}
5858
""" // pragma: allowlist-secret
5959
if let useCaseData = useCase.data(using: .utf8) {
6060
let app = XCUIApplication()

Notification Agent Onboarding/Views/OnboardingViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class OnboardingViewModel: NSObject, ObservableObject {
198198
plistDictionary[index.description] = pageDictionary
199199
}
200200
let dictionaryResult = NSDictionary(dictionary: plistDictionary)
201-
Utils.write(dictionaryResult, to: Constants.storeFileName)
201+
Utils.write(dictionaryResult, to: onboardingData.outputFile!)
202202
}
203203

204204
/// Update the state of the progress bar if it's set to automatic.

Shared/Model/UIObjects/NotificationObject.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ public final class NotificationObject: NSObject, Codable, NSSecureCoding {
145145
switch type {
146146
case .onboarding:
147147
self.payload = try Self.loadOnboardingPayload(payloadRawData)
148+
self.payload?.outputFile = dict["output_file"] as? String ?? Constants.storeFileName
148149
default:
149150
break
150151
}

Shared/Model/UIObjects/OnboardingData.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ public final class OnboardingData: Codable {
1616
/// An array of pages.
1717
var pages: [InteractiveOnboardingPage]
1818
var progressBarPayload: String?
19+
var outputFile: String!
1920

2021
// MARK: - Codable protocol conformity - START
2122

2223
enum ODCodingKeys: String, CodingKey {
2324
case pages
2425
case progressBarPayload
26+
case outputFile
2527
}
2628

2729
required public init(from decoder: Decoder) throws {
@@ -34,12 +36,16 @@ public final class OnboardingData: Codable {
3436
if let payload = try? container.decodeIfPresent(String.self, forKey: .progressBarPayload) {
3537
self.progressBarPayload = payload
3638
}
39+
if let outputFile = try? container.decode(String.self, forKey: .outputFile) {
40+
self.outputFile = outputFile
41+
}
3742
}
3843

3944
public func encode(to encoder: Encoder) throws {
4045
var container = encoder.container(keyedBy: ODCodingKeys.self)
4146

4247
try container.encodeIfPresent(progressBarPayload, forKey: .progressBarPayload)
48+
try container.encode(outputFile, forKey: .outputFile)
4349
try container.encode(pages, forKey: .pages)
4450
}
4551

0 commit comments

Comments
 (0)