Skip to content

Commit

Permalink
allowLaterDeferralButton
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Dec 29, 2022
1 parent d1089d2 commit e868c34
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions Example Assets/com.github.macadmins.Nudge.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
],
"userExperience": {
"allowGracePeriods": false,
"allowLaterDeferralButton": true,
"allowUserQuitDeferrals": true,
"allowedDeferrals": 1000000,
"allowedDeferralsUntilForcedSecondaryQuitButton": 14,
Expand Down
2 changes: 2 additions & 0 deletions Example Assets/com.github.macadmins.Nudge.mobileconfig
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
<dict>
<key>allowGracePeriods</key>
<false/>
<key>allowLaterDeferralButton</key>
<true/>
<key>allowUserQuitDeferrals</key>
<true/>
<key>allowedDeferrals</key>
Expand Down
1 change: 1 addition & 0 deletions Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ let aboutUpdateURL = getAboutUpdateURL(OSVerReq: osVersionRequirementsProfile) ?
let userExperienceProfile = getUserExperienceProfile()
let userExperienceJSON = getUserExperienceJSON()
let allowGracePeriods = PrefsWrapper.allowGracePeriods
let allowLaterDeferralButton = userExperienceProfile?["allowLaterDeferralButton"] as? Bool ?? userExperienceJSON?.allowLaterDeferralButton ?? true
let allowUserQuitDeferrals = userExperienceProfile?["allowUserQuitDeferrals"] as? Bool ?? userExperienceJSON?.allowUserQuitDeferrals ?? true
let allowedDeferrals = userExperienceProfile?["allowedDeferrals"] as? Int ?? userExperienceJSON?.allowedDeferrals ?? 1000000
let allowedDeferralsUntilForcedSecondaryQuitButton = userExperienceProfile?["allowedDeferralsUntilForcedSecondaryQuitButton"] as? Int ?? userExperienceJSON?.allowedDeferralsUntilForcedSecondaryQuitButton ?? 14
Expand Down
4 changes: 3 additions & 1 deletion Nudge/Preferences/PreferencesStructure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ extension AboutUpdateURL {

// MARK: - UserExperience
struct UserExperience: Codable {
var allowGracePeriods, allowUserQuitDeferrals: Bool?
var allowGracePeriods, allowLaterDeferralButton, allowUserQuitDeferrals: Bool?
var allowedDeferrals, allowedDeferralsUntilForcedSecondaryQuitButton, approachingRefreshCycle, approachingWindowTime: Int?
var elapsedRefreshCycle, gracePeriodInstallDelay, gracePeriodLaunchDelay: Int?
var gracePeriodPath: String?
Expand Down Expand Up @@ -298,6 +298,7 @@ extension UserExperience {

func with(
allowGracePeriods: Bool?? = nil,
allowLaterDeferralButton: Bool?? = nil,
allowUserQuitDeferrals: Bool?? = nil,
allowedDeferrals: Int?? = nil,
allowedDeferralsUntilForcedSecondaryQuitButton: Int?? = nil,
Expand All @@ -317,6 +318,7 @@ extension UserExperience {
) -> UserExperience {
return UserExperience(
allowGracePeriods: allowGracePeriods ?? self.allowGracePeriods,
allowLaterDeferralButton: allowLaterDeferralButton ?? self.allowLaterDeferralButton,
allowUserQuitDeferrals: allowUserQuitDeferrals ?? self.allowUserQuitDeferrals,
allowedDeferrals: allowedDeferrals ?? self.allowedDeferrals,
allowedDeferralsUntilForcedSecondaryQuitButton: allowedDeferralsUntilForcedSecondaryQuitButton ?? self.allowedDeferralsUntilForcedSecondaryQuitButton,
Expand Down
14 changes: 8 additions & 6 deletions Nudge/UI/Common/QuitButtons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ struct QuitButtons: View {
HStack {
if allowUserQuitDeferrals {
Menu {
Button {
Utils().setDeferralTime(deferralTime: nudgeEventDate)
updateDeferralUI()
} label: {
Text(primaryQuitButtonText)
.frame(minWidth: buttonTextMinWidth)
if allowLaterDeferralButton {
Button {
Utils().setDeferralTime(deferralTime: nudgeEventDate)
updateDeferralUI()
} label: {
Text(primaryQuitButtonText)
.frame(minWidth: buttonTextMinWidth)
}
}
if Utils().allow1HourDeferral() {
Button {
Expand Down
14 changes: 14 additions & 0 deletions Schema/jamf/com.github.macadmins.Nudge.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,20 @@
}
]
},
"allowLaterDeferralButton": {
"description": "Allows the user to press the `Later` button through the custom deferrals UI",
"anyOf": [
{
"title": "Not Configured",
"type": "null"
},
{
"title": "Configured",
"default": true,
"type": "boolean"
}
]
},
"allowUserQuitDeferrals": {
"description": "Allows the user to specify when they will next be prompted by Nudge. (Set to `False` to maintain v1.0.0 behavior.) When using this feature, Nudge will no longer adhere to your LaunchAgent logic as the user is specifying their own execution time for the next Nudge event.(See: `~/Library/Preferences/com.github.macadmins.Nudge.plist`.)",
"anyOf": [
Expand Down

0 comments on commit e868c34

Please sign in to comment.