Fixignoring bugs

This commit is contained in:
Max Goedjen
2020-11-12 23:48:56 -08:00
parent 8bbf489146
commit cd0a1b0a68
5 changed files with 74 additions and 23 deletions

View File

@@ -16,7 +16,9 @@ class PreviewUpdater: UpdaterProtocol {
self.update = Release(name: "10.10.10", html_url: URL(string: "https://example.com")!, body: "Critical Security Update")
}
}
func ignore(release: Release) {
}
}
extension PreviewUpdater {

View File

@@ -87,9 +87,13 @@ struct ContentView<UpdaterType: UpdaterProtocol, AgentStatusCheckerType: AgentSt
severity = .advisory
text = "Update Available"
}
return AnyView(NoticeView(text: text, severity: severity, actionTitle: "Update") {
NSWorkspace.shared.open(update.html_url)
})
let action = {
_ = NSWorkspace.shared.open(update.html_url)
}
let ignoreAction = {
updater.ignore(release: update)
}
return AnyView(NoticeView(text: text, severity: severity, actionTitle: "Update", action: action, secondaryActionTitle: "Ignore", secondaryAction: ignoreAction))
}
func agentNotice() -> some View {

View File

@@ -7,12 +7,28 @@ struct NoticeView: View {
let severity: Severity
let actionTitle: String?
let action: (() -> Void)?
let secondaryActionTitle: String?
let secondaryAction: (() -> Void)?
public init(text: String, severity: NoticeView.Severity, actionTitle: String?, action: (() -> Void)?, secondaryActionTitle: String? = nil, secondaryAction: (() -> Void)? = nil) {
self.text = text
self.severity = severity
self.actionTitle = actionTitle
self.action = action
self.secondaryActionTitle = secondaryActionTitle
self.secondaryAction = secondaryAction
}
var body: some View {
HStack {
Text(text).bold()
Spacer()
if action != nil {
if secondaryAction != nil {
Button(action: secondaryAction!) {
Text(secondaryActionTitle!)
}
}
Button(action: action!) {
Text(actionTitle!)
}