From f8e6aa988e18565a49a8412c4d51b09a8801ed5b Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Wed, 30 Aug 2023 20:20:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Mapping=20more=20PHP=20?= =?UTF-8?q?configuration=20values?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PHP Config Editor/UI/ByteLimitView.swift | 4 +- .../UI/ConfigManagerView.swift | 45 +++++++++++++------ phpmon/en.lproj/Localizable.strings | 10 +++++ 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/phpmon/Modules/PHP Config Editor/UI/ByteLimitView.swift b/phpmon/Modules/PHP Config Editor/UI/ByteLimitView.swift index 48d2122..dd1d09a 100644 --- a/phpmon/Modules/PHP Config Editor/UI/ByteLimitView.swift +++ b/phpmon/Modules/PHP Config Editor/UI/ByteLimitView.swift @@ -27,7 +27,7 @@ struct PreferenceContainer: View { VStack(alignment: .leading, spacing: 10) { HStack(alignment: .top, spacing: 50) { VStack(alignment: .leading) { - Text(self.name) + Text(self.name.localizedForSwiftUI) .bold() .multilineTextAlignment(.leading) .frame(minWidth: 150, maxWidth: 150, alignment: .leading) @@ -35,7 +35,7 @@ struct PreferenceContainer: View { VStack(alignment: .leading) { controlView - Text(self.description).font(.subheadline) + Text(self.description.localizedForSwiftUI).font(.subheadline) }.frame(maxWidth: .infinity, alignment: .leading) } } diff --git a/phpmon/Modules/PHP Config Editor/UI/ConfigManagerView.swift b/phpmon/Modules/PHP Config Editor/UI/ConfigManagerView.swift index 503c615..ccd7827 100644 --- a/phpmon/Modules/PHP Config Editor/UI/ConfigManagerView.swift +++ b/phpmon/Modules/PHP Config Editor/UI/ConfigManagerView.swift @@ -9,9 +9,24 @@ import Foundation import SwiftUI -struct PhpPreference { +class PhpPreference { let key: String - let type: PhpPreferenceType + + init(key: String) { + self.key = key + } +} + +class BoolPhpPreference: PhpPreference { + @State var value: Bool = false +} + +class StringPhpPreference: PhpPreference { + @State var value: String = "" +} + +class BytePhpPreference: PhpPreference { + @State var value: String = "" } enum PhpPreferenceType { @@ -22,10 +37,10 @@ enum PhpPreferenceType { struct ConfigManagerView: View { var preferences: [PhpPreference] = [ - PhpPreference(key: "memory_limit", type: .byteLimit), - PhpPreference(key: "post_max_size", type: .byteLimit), - PhpPreference(key: "file_uploads", type: .boolean), - PhpPreference(key: "upload_max_filesize", type: .byteLimit) + BytePhpPreference(key: "memory_limit"), + BytePhpPreference(key: "post_max_size"), + BoolPhpPreference(key: "file_uploads"), + BytePhpPreference(key: "upload_max_filesize") ] var body: some View { @@ -55,26 +70,28 @@ struct ConfigManagerView: View { VStack(spacing: 5) { ForEach(preferences, id: \.key) { preference in PreferenceContainer( - name: "php_ini." + preference.key + ".title", - description: "php_ini." + preference.key + ".description" + name: "php_ini.\(preference.key).title", + description: "php_ini.\(preference.key).description" ) { - if preference.type == .byteLimit { + if let preference = preference as? BytePhpPreference { ByteLimitView() } - if preference.type == .boolean { - Text("Boolean value here") - // Toggle(isOn: preference.) + if let preference = preference as? BoolPhpPreference { + Toggle("", isOn: preference.$value) + } + if let preference = preference as? StringPhpPreference { + TextField("Placeholder", text: preference.$value) } }.frame(maxWidth: .infinity) } Divider() HStack { - Button("Close", action: { + Button("Cancel", action: { }) Spacer() - Button("Restart PHP-FPM", action: { + Button("Apply", action: { }) } diff --git a/phpmon/en.lproj/Localizable.strings b/phpmon/en.lproj/Localizable.strings index e5d7730..2c1f75d 100644 --- a/phpmon/en.lproj/Localizable.strings +++ b/phpmon/en.lproj/Localizable.strings @@ -786,3 +786,13 @@ Please note that some features (greyed out below) are currently unavailable beca "onboarding.tour.feature_unavailable" = "This feature is currently unavailable and requires Laravel Valet to be installed."; "onboarding.tour.once" = "You will only see the Welcome Tour once. You can re-open the Welcome Tour later via the menu bar icon (available in the menu, under First Aid & Services)."; "onboarding.tour.close" = "Close Tour"; + +// CONFIGURATION MANAGER + +"confman.title" = "Configuration Manager"; +"confman.description" = "You can update configuration values for the currently active PHP version."; + +"php_ini.memory_limit.title" = "Memory Limit"; +"php_ini.post_max_size.title" = "POST Max Size"; +"php_ini.file_uploads.title" = "File Uploads"; +"php_ini.upload_max_filesize.title" = "Upload Max Size";