Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Say why Forget Receipt waits for the helper, without a promise

Țugui Dragoșfbc8c8d18f84
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 487c4d73..9b89e006 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -85857,112 +85857,6 @@
}
}
},
- "Needs Peel’s helper. Settings says why it can’t act yet." : {
- "localizations" : {
- "cs" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Vyžaduje pomocníka Peelu. Proč zatím nemůže jednat, se dozvíte v Nastavení."
- }
- },
- "de" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Benötigt das Hilfsprogramm von Peel. In den Einstellungen steht, warum es noch nicht einsatzbereit ist."
- }
- },
- "es" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Necesita el asistente de Peel. En Ajustes se indica por qué aún no puede actuar."
- }
- },
- "fr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Nécessite l’utilitaire de Peel. Les Réglages indiquent pourquoi il ne peut pas encore agir."
- }
- },
- "it" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Richiede l’assistente di Peel. Le Impostazioni spiegano perché non può ancora agire."
- }
- },
- "ja" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Peelのヘルパーが必要です。まだ動作できない理由は“設定”に表示されています。"
- }
- },
- "ko" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Peel 보조 프로그램이 필요합니다. 아직 작동할 수 없는 이유는 설정에서 확인할 수 있습니다."
- }
- },
- "nl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Vereist het hulpprogramma van Peel. In Instellingen staat waarom het nog niets kan doen."
- }
- },
- "pl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Wymaga pomocnika Peel. W Ustawieniach sprawdzisz, dlaczego nie może jeszcze działać."
- }
- },
- "pt" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Requer o auxiliar do Peel. Os Ajustes dizem por que ele ainda não pode agir."
- }
- },
- "ro" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Necesită instrumentul de ajutor Peel. În Configurări vedeți de ce nu poate acționa încă."
- }
- },
- "ru" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Нужен помощник Peel. В Настройках указано, почему он пока не может действовать."
- }
- },
- "sv" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Kräver Peels hjälpprogram. I Inställningar ser du varför det inte kan göra något än."
- }
- },
- "tr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Peel’in yardımcısı gerekiyor. Yardımcının neden henüz işlem yapamadığını Ayarlar açıklar."
- }
- },
- "uk" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Потрібен помічник Peel. У Параметрах сказано, чому він ще не може діяти."
- }
- },
- "zh-Hans" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "需要Peel的帮助程序。“设置”中会说明它为何暂时无法执行操作。"
- }
- },
- "zh-Hant" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "需要Peel的輔助程式。「設定」中會說明它目前為何還無法執行。"
- }
- }
- }
- },
"Needs Terminal" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swift
index 735ca5bc..1d46764e 100644
--- a/Peel/Views/AppDetailView.swift
+++ b/Peel/Views/AppDetailView.swift
@@ -175,7 +175,8 @@ struct AppDetailView: View {
) {}
.listRowSeparator(.hidden)
}
- if plan.requiresHelper, !helper.canAct {
+ // A receipt's Forget needs the helper as well.
+ if plan.requiresHelper || !plan.packageReceipts.isEmpty, !helper.canAct {
HelperRequiredBanner()
}
diff --git a/Peel/Views/HelperRequiredBanner.swift b/Peel/Views/HelperRequiredBanner.swift
index 0c43a456..9e7be692 100644
--- a/Peel/Views/HelperRequiredBanner.swift
+++ b/Peel/Views/HelperRequiredBanner.swift
@@ -24,14 +24,21 @@ struct HelperRequiredBanner: View {
}
private var detail: Text {
- switch helper.standing {
+ Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy))
+ }
+}
+
+extension PrivilegedHelper.Standing {
+ /// Why Peel's helper can't act, for a page or a control that needs it.
+ func whyItCannotAct(registeredByAnotherCopy: Bool) -> LocalizedStringResource {
+ switch self {
case .ready, .notInstalled:
- helper.isRegisteredByAnotherCopy
- ? Text("Peel’s helper was installed by another copy of Peel, and this copy can’t use it.")
- : Text("Install Peel’s helper to remove the items in the system folders it serves.")
- case .waitingForApproval: Text("Peel’s helper is waiting to be allowed in System Settings, under Login Items & Extensions.")
- case .notThisAccount: Text("Only an administrator can use Peel’s helper, so Peel can’t remove these from this account.")
- case .notAnswering: Text("Peel’s helper isn’t answering. Repair it in Settings.")
+ registeredByAnotherCopy
+ ? "Peel’s helper was installed by another copy of Peel, and this copy can’t use it."
+ : "Install Peel’s helper to remove the items in the system folders it serves."
+ case .waitingForApproval: "Peel’s helper is waiting to be allowed in System Settings, under Login Items & Extensions."
+ case .notThisAccount: "Only an administrator can use Peel’s helper, so Peel can’t remove these from this account."
+ case .notAnswering: "Peel’s helper isn’t answering. Repair it in Settings."
}
}
}
diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swift
index ab75a592..0d7fc51d 100644
--- a/Peel/Views/Packages/PackageDetailView.swift
+++ b/Peel/Views/Packages/PackageDetailView.swift
@@ -16,7 +16,8 @@ struct PackageDetailView: View {
.listRowSeparator(.hidden)
RemovalsHeldBanner()
- if receipt.items.contains(where: { $0.requiresPrivileges && !$0.isLeftAlone }), !helper.canAct {
+ // Forget Receipt always needs the helper, whatever the items need.
+ if !helper.canAct {
HelperRequiredBanner()
}
@@ -65,7 +66,7 @@ struct PackageDetailView: View {
}
.buttonStyle(.borderless)
.disabled(!helper.canAct || !history.mayMove)
- .help(helper.canAct ? Text("The receipt goes to the Trash. Files stay where they are.") : Text("Needs Peel’s helper. Settings says why it can’t act yet."))
+ .help(forgetHelp)
}
}
}
@@ -114,6 +115,12 @@ struct PackageDetailView: View {
.forgetReceiptDialog(for: $receiptToForget, forget: packages.forget)
}
+ private var forgetHelp: Text {
+ helper.canAct
+ ? Text("The receipt goes to the Trash. Files stay where they are.")
+ : Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy))
+ }
+
/// What an app that uninstalls itself once it moves does then, as its own page warns.
private var removalNote: Text? {
let warnings = selectedItems.compactMap(\.uninstallsItself).map(\.warning)
diff --git a/Peel/Views/VendorNotes.swift b/Peel/Views/VendorNotes.swift
index cd1e3609..54e1637a 100644
--- a/Peel/Views/VendorNotes.swift
+++ b/Peel/Views/VendorNotes.swift
@@ -75,6 +75,13 @@ struct PackageReceiptSection: View {
.forgetReceiptDialog(for: $receiptToForget, forget: forget)
}
+ private var forgetHelp: Text {
+ if plan.isExcluded { return Text(.excludedApp) }
+ return helper.canAct
+ ? Text("The receipt goes to the Trash. Files stay where they are.")
+ : Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy))
+ }
+
@ViewBuilder
private func rows(for receipt: PackageReceipt) -> some View {
let files = plan.filesOutside[receipt.id] ?? []
@@ -94,7 +101,7 @@ struct PackageReceiptSection: View {
.buttonStyle(.borderless)
// The page promises that an excluded app's files are left alone, its receipt included.
.disabled(isForgetting || !helper.canAct || plan.isExcluded || !history.mayMove)
- .help(plan.isExcluded ? Text(.excludedApp) : helper.canAct ? Text("The receipt goes to the Trash. Files stay where they are.") : Text("Needs Peel’s helper. Settings says why it can’t act yet."))
+ .help(forgetHelp)
}
if files.isEmpty {
Text("Outside the app, Peel found nothing that belongs to this package alone.")
diff --git a/PeelTests/HelperReasonTests.swift b/PeelTests/HelperReasonTests.swift
new file mode 100644
index 00000000..fafe5f1a
--- /dev/null
+++ b/PeelTests/HelperReasonTests.swift
@@ -0,0 +1,19 @@
+import Foundation
+@testable import Peel
+import PeelCore
+import Testing
+
+@MainActor
+struct HelperReasonTests {
+ @Test func saysWhyTheHelperCannotActWithoutPromisingItWillSoon() {
+ let reason = { (standing: PrivilegedHelper.Standing, anotherCopy: Bool) in
+ String(localized: standing.whyItCannotAct(registeredByAnotherCopy: anotherCopy))
+ }
+
+ #expect(reason(.notThisAccount, false) == String(localized: "Only an administrator can use Peel’s helper, so Peel can’t remove these from this account."))
+ #expect(reason(.notInstalled, false) == String(localized: "Install Peel’s helper to remove the items in the system folders it serves."))
+ #expect(reason(.notInstalled, true) == String(localized: "Peel’s helper was installed by another copy of Peel, and this copy can’t use it."))
+ #expect(reason(.waitingForApproval, false) == String(localized: "Peel’s helper is waiting to be allowed in System Settings, under Login Items & Extensions."))
+ #expect(reason(.notAnswering, false) == String(localized: "Peel’s helper isn’t answering. Repair it in Settings."))
+ }
+}