Skip to content

Commit

Permalink
Merge pull request #108 from IBM/development
Browse files Browse the repository at this point in the history
Version 2.8.0 Build 87
  • Loading branch information
Johny authored Aug 2, 2022
2 parents 5e9e8a1 + 2aa8077 commit 4c21747
Show file tree
Hide file tree
Showing 26 changed files with 581 additions and 153 deletions.
4 changes: 2 additions & 2 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Python version (for python projects only)
sonar.python.version=3
# Project Version to be used as Code Definition
sonar.projectVersion=2.7.1.83
sonar.projectVersion=2.7.1.84
# Folders excluded from the scan
sonar.exclusions=**/Notification Agent Core Tests/**,**/Notification Agent Alert Tests/**,**/Notification Agent Banner Tests/**,**/Notification Agent Popup Tests/**,**/Notification Agent Onboarding Tests/**,**/Notification Agent Popup UI Tests/**,**/Notification Agent Onboarding UI Tests/**
sonar.exclusions=**/Notification Agent Core Tests/**,**/Notification Agent Alert Tests/**,**/Notification Agent Banner Tests/**,**/Notification Agent Popup Tests/**,**/Notification Agent Onboarding Tests/**,**/Notification Agent Popup UI Tests/**,**/Notification Agent Onboarding UI Tests/**,**/Notification Agent Core/Controllers/HelpBuilder.swift**
Binary file modified Images/Popup/popup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Images/Popup/popup_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion Notification Agent Alert Tests/NAATriggersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class NAATriggersTests: XCTestCase {
let worker = TestWorker()
let parserUseCases = [["type" : "alert", "title" : "This is a title"],
["type" : "alert", "subtitle" : "This is a subtitle"],
["type" : "alert", "title" : "This is a title", "subtitle" : "This is a subtitle"]]
["type" : "alert", "title" : "This is a title", "subtitle" : "This is a subtitle"],
["type" : "alert", "workflow" : "resetAlerts"]]

override func setUpWithError() throws {
worker.startObservation()
Expand Down
3 changes: 2 additions & 1 deletion Notification Agent Banner Tests/NABTriggersTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class NABTriggersTests: XCTestCase {
let worker = TestWorker()
let parserUseCases = [["type" : "banner", "title" : "This is a title"],
["type" : "banner", "subtitle" : "This is a subtitle"],
["type" : "banner", "title" : "This is a title", "subtitle" : "This is a subtitle"]]
["type" : "banner", "title" : "This is a title", "subtitle" : "This is a subtitle"],
["type" : "banner", "workflow" : "resetBanners"]]

override func setUpWithError() throws {
worker.startObservation()
Expand Down
12 changes: 11 additions & 1 deletion Notification Agent Core/Controllers/HelpBuilder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public final class HelpBuilder {
"-tertiary_button_cta_payload".yellow(),
"-help_button_cta_type".yellow(),
"-help_button_cta_payload".yellow(),
"-warning_button_cta_type".yellow(),
"-warning_button_cta_payload".yellow(),
"-warning_button_visibility".yellow(),
"-timeout".yellow(),
"-always_on_top".yellow(),
"-silent".yellow(),
Expand Down Expand Up @@ -76,7 +79,7 @@ public final class HelpBuilder {
"- Text with the format " + "\"/placeholder TEXT /title TEXT /value TEXT /required\" ".green() + "for the " + "[ input | secureinput ]".red() + " view type.\n " +
"- Text with the format " + "\"/list ITEM\\nITEM\\nITEM /selected INT /placeholder TEXT /title TEXT\" ".green() + "for " + "[ dropdown ]".red() + " view type;\n " +
"- Text with HTML format for " + "[ html | htmlwhitebox ]".red() + " view type;\n " +
"- Text with the format " + "\"/list ITEM\\nITEM\\nITEM /required /complete /title TEXT /radio\" ".green() + "for " + "[ checklist ]".red() + " view type. To read more about the usage of /complete and /required look at the project wiki;\n " +
"- Text with the format " + "\"/list ITEM\\nITEM\\nITEM /preselection ITEM_INDEX ITEM_INDEX ITEM_INDEX /required /complete /title TEXT /radio\" ".green() + "for " + "[ checklist ]".red() + " view type. To read more about the usage of /complete and /required look at the project wiki;\n " +
"Example 1: -accessory_view_payload \"This is the time left: %@\"\n " +
"Example 2: -accessory_view_payload \"/percent 0 /top_message This is the top message /bottom_message This is the bottom message\";\n " +
"Example 3: -accessory_view_payload \"/percent indeterminate /top_message This is the top message /bottom_message This is the bottom message\";\n " +
Expand All @@ -94,6 +97,9 @@ public final class HelpBuilder {
"\n A mandatory URL if " + "[ link ]".red() + " cta type defined, optional if " + "[ exitlink ]".red() + " cta defined.\n Example: -tertiary_button_cta_payload \"URL\"",
"[ link | infopopup ]".red() + "\n The call to action type for the help button.\n Example: -help_button_cta_type link",
"\n An URL for " + "[ link ]".red() + " cta type or text for " + "[ infopopup ]".red() + " cta type.\n Example: -help_button_cta_payload \"URL\"",
"\n Same as for help_button_cta_type argument.",
"\n Same as for help_button_cta_payload argument.",
"[ hidden | visible ]".red() + "\n Since the warning button visibility is interactive it needs an initial state.\n Example: -help_button_cta_type hidden",
"\n The timeout for the notification. After this amount of seconds the agent exit with the timeout exit code.\n Example: -timeout 300",
"\n Flag that tells the agent to keep the pop-up always on top of the window hierarchy.\n Example: -always_on_top",
"\n Flag that tells the agent to not reproduce any sound when the pop-up appear.\n Example: -silent",
Expand Down Expand Up @@ -130,11 +136,15 @@ public final class HelpBuilder {
"--version".blue(),
"--terms".blue(),
"--privacy".blue(),
"--resetBanners".blue(),
"--resetAlerts".blue(),
"--v".blue()]
static let specialArgumentsDescriptions: [String] = ["Show help's page",
"Show app's version",
"Shows the Terms & Conditions",
"Shows the Privacy Policy",
"Delete all the app's banners from Notification Center",
"Delete all the app's alerts from Notification Center",
"Verbose mode"]
static let configurableParameters: [String] = ["-default_popup_bar_title".yellow(),
"-default_popup_icon_path".yellow(),
Expand Down
26 changes: 26 additions & 0 deletions Notification Agent Core/Extensions/EFCLController-Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,32 @@ extension EFCLController {
applicationExit(withReason: .untrackedSuccess)
return
}
guard !arguments.contains("--resetBanners") else {
guard let notificationObject = try? NotificationObject(from: ["type" : "banner", "workflow" : "resetBanners"]) else {
return
}
let object = TaskObject(notification: notificationObject, settings: Context.main.sharedSettings)
guard let jsonData = try? JSONEncoder().encode(object) else {
EFCLController.shared.applicationExit(withReason: .internalError)
return
}
TaskManager().runUntrackedTaskOnComponent(.banner, with: jsonData)
applicationExit(withReason: .untrackedSuccess)
return
}
guard !arguments.contains("--resetAlerts") else {
guard let notificationObject = try? NotificationObject(from: ["type" : "alert", "workflow" : "resetAlerts"]) else {
return
}
let object = TaskObject(notification: notificationObject, settings: Context.main.sharedSettings)
guard let jsonData = try? JSONEncoder().encode(object) else {
EFCLController.shared.applicationExit(withReason: .internalError)
return
}
TaskManager().runUntrackedTaskOnComponent(.alert, with: jsonData)
applicationExit(withReason: .untrackedSuccess)
return
}
context.sharedSettings.isVerboseModeEnabled = arguments.contains("--v")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extension NotificationDispatch {
int = true
}
})
int = int || object.notification.warningButton != nil
return int
}
taskManager.runAsyncTaskOnComponent(.popup, with: jsonData, isInteractive: isInteractive) { terminationStatus in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// OnboardingInteractiveEFCLController.swift
// Notification Agent
//
// Created by Simone Martorelli on 24/06/22.
// Copyright © 2022 IBM. All rights reserved.
// SPDX-License-Identifier: Apache2.0
//

import Foundation

final class OnboardingInteractiveEFCLController: InteractiveEFCLController {
override func processInput(_ notification: Notification) {
let inputData = inputPipe.availableData
if !inputData.isEmpty {
guard let strData = String(data: inputData, encoding: String.Encoding.utf8)?.trimmingCharacters(in: CharacterSet.newlines) else { return }
let splittedStrings = strData.split(separator: "/")
for string in splittedStrings {
guard let argument = string.split(separator: " ", maxSplits: 1).first?.lowercased(),
var value = string.split(separator: " ", maxSplits: 1).last else { continue }
if value.last == " " {
value.removeLast()
}
switch argument {
case "percent", "top_message", "bottom_message", "user_interaction_enabled", "user_interruption_allowed", "exit_on_completion":
NotificationCenter.default.post(name: Notification.Name("progressbar_interactive_updates"), object: ["data" : inputData])
default:
continue
}
}
}
inputPipe.waitForDataInBackgroundAndNotify()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class OnboardingViewController: NSViewController {
private var presentedVC: NSViewController?
private var presentedPageIndex: Int = 0
private var commonProgressBar: ProgressBarAccessoryView!
private var interactiveUpdatesObserver: OnboardingInteractiveEFCLController?
let context = Context.main
let logger = NALogger.shared
var isClosable: Bool = true
Expand Down Expand Up @@ -96,6 +97,8 @@ class OnboardingViewController: NSViewController {
commonProgressBar.delegate = self
isClosable = false
self.view.addSubview(commonProgressBar)
interactiveUpdatesObserver = OnboardingInteractiveEFCLController()
interactiveUpdatesObserver?.startObservingStandardInput()
}

/// Write the saved store on a file on the user device.
Expand Down
Loading

0 comments on commit 4c21747

Please sign in to comment.