Skip to content

Commit

Permalink
add actionButtonPath to OSVersionRequirement (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Feb 22, 2022
1 parent e7c5f55 commit bf04912
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Example Assets/com.github.macadmins.Nudge.json
Expand Up @@ -29,6 +29,7 @@
"aboutUpdateURL": "https://support.apple.com/de-de/HT211896"
}
],
"actionButtonPath": "munki://updates",
"majorUpgradeAppPath": "/Applications/Install macOS Big Sur.app",
"requiredInstallationDate": "2021-08-28T00:00:00Z",
"requiredMinimumOSVersion": "11.5.2",
Expand Down
2 changes: 2 additions & 0 deletions Example Assets/com.github.macadmins.Nudge.mobileconfig
Expand Up @@ -66,6 +66,8 @@
<string>https://support.apple.com/de-de/HT211896</string>
</dict>
</array>
<key>actionButtonPath</key>
<string>munki://updates</string>
<key>majorUpgradeAppPath</key>
<string>/Applications/Install macOS Big Sur.app</string>
<key>requiredInstallationDate</key>
Expand Down
4 changes: 3 additions & 1 deletion Nudge/Preferences/DefaultPreferencesNudge.swift
Expand Up @@ -11,6 +11,9 @@ import Foundation
let currentOSVersion = OSVersion(ProcessInfo().operatingSystemVersion).description
var fetchMajorUpgradeSuccessful = false

// Features can be placed in multiple primary keys
let actionButtonPath = osVersionRequirementsProfile?.actionButtonPath ?? osVersionRequirementsJSON?.actionButtonPath ?? userInterfaceProfile?["actionButtonPath"] as? String ?? userInterfaceJSON?.actionButtonPath ?? nil

// optionalFeatures
let optionalFeaturesProfile = getOptionalFeaturesProfile()
let optionalFeaturesJSON = getOptionalFeaturesJSON()
Expand Down Expand Up @@ -54,7 +57,6 @@ let userInterfaceProfile = getUserInterfaceProfile()
let userInterfaceJSON = getUserInterfaceJSON()
let userInterfaceUpdateElementsProfile = getUserInterfaceUpdateElementsProfile()
let userInterfaceUpdateElementsJSON = getUserInterfaceUpdateElementsJSON()
let actionButtonPath = userInterfaceProfile?["actionButtonPath"] as? String ?? userInterfaceJSON?.actionButtonPath ?? nil
let fallbackLanguage = userInterfaceProfile?["fallbackLanguage"] as? String ?? userInterfaceJSON?.fallbackLanguage ?? "en"
let forceFallbackLanguage = userInterfaceProfile?["forceFallbackLanguage"] as? Bool ?? userInterfaceJSON?.forceFallbackLanguage ?? false
let iconDarkPath = userInterfaceProfile?["iconDarkPath"] as? String ?? userInterfaceJSON?.iconDarkPath ?? ""
Expand Down
4 changes: 4 additions & 0 deletions Nudge/Preferences/PreferencesStructure.swift
Expand Up @@ -115,6 +115,7 @@ extension OptionalFeatures {
struct OSVersionRequirement: Codable {
var aboutUpdateURL: String?
var aboutUpdateURLs: [AboutUpdateURL]?
var actionButtonPath: String?
var majorUpgradeAppPath: String?
var requiredInstallationDate: Date?
var requiredMinimumOSVersion: String?
Expand Down Expand Up @@ -144,6 +145,7 @@ extension OSVersionRequirement {
}
self.aboutUpdateURL = fromDictionary["aboutUpdateURL"] as? String
self.aboutUpdateURLs = generatedAboutUpdateURLs
self.actionButtonPath = fromDictionary["actionButtonPath"] as? String
self.majorUpgradeAppPath = fromDictionary["majorUpgradeAppPath"] as? String
self.requiredMinimumOSVersion = fromDictionary["requiredMinimumOSVersion"] as? String
self.targetedOSVersionsRule = fromDictionary["targetedOSVersionsRule"] as? String
Expand All @@ -167,6 +169,7 @@ extension OSVersionRequirement {
func with(
aboutUpdateURL: String?? = nil,
aboutUpdateURLs: [AboutUpdateURL]?? = nil,
actionButtonPath: String?? = nil,
majorUpgradeAppPath: String?? = nil,
requiredInstallationDate: Date?? = nil,
requiredMinimumOSVersion: String?? = nil,
Expand All @@ -175,6 +178,7 @@ extension OSVersionRequirement {
return OSVersionRequirement(
aboutUpdateURL: aboutUpdateURL ?? self.aboutUpdateURL,
aboutUpdateURLs: aboutUpdateURLs ?? self.aboutUpdateURLs,
actionButtonPath: actionButtonPath ?? self.actionButtonPath,
majorUpgradeAppPath: majorUpgradeAppPath ?? self.majorUpgradeAppPath,
requiredInstallationDate: requiredInstallationDate ?? self.requiredInstallationDate,
requiredMinimumOSVersion: requiredMinimumOSVersion ?? self.requiredMinimumOSVersion,
Expand Down

0 comments on commit bf04912

Please sign in to comment.