Quick action input labels shown as the profile writes them

"Current User ID" / "New User ID" on Xerox, "Current User Code" on Ricoh; the CLI
validation error uses the same label.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kfattic
2026-09-16 21:22:10 -05:00
parent d1d6c8045c
commit 08ae1d3043
4 changed files with 6 additions and 6 deletions

View File

@@ -180,7 +180,7 @@ struct QuickActionSheet: View {
@ViewBuilder private var content: some View { @ViewBuilder private var content: some View {
if model.action.input == .userCode { if model.action.input == .userCode {
Form { Form {
LabeledContent("Current \(model.inputLabel.lowercased())") { LabeledContent("Current \(model.inputLabel)") {
HStack(spacing: 8) { HStack(spacing: 8) {
if let current = model.currentCode { if let current = model.currentCode {
Text(model.showCurrentCode ? current : String(repeating: "•", count: current.count)) Text(model.showCurrentCode ? current : String(repeating: "•", count: current.count))
@@ -202,7 +202,7 @@ struct QuickActionSheet: View {
.frame(width: 160) .frame(width: 160)
.disabled(model.phase != .ready) .disabled(model.phase != .ready)
} label: { } label: {
Text("New \(model.inputLabel.lowercased())") Text("New \(model.inputLabel)")
if let error = model.validationError { if let error = model.validationError {
Text(error).foregroundStyle(.red) Text(error).foregroundStyle(.red)
} }

View File

@@ -104,8 +104,8 @@ public struct QuickAction: Identifiable, Hashable {
return resolved.profile.inputs[id] return resolved.profile.inputs[id]
} }
/// "User code" (Ricoh) or the profile's label ("User ID" for Xerox). /// "User Code" (Ricoh) or the profile's label ("User ID" for Xerox). Shown as written, never re-cased.
public func inputLabel(_ context: DriverContext) -> String { inputSpec(context)?.label ?? "User code" } public func inputLabel(_ context: DriverContext) -> String { inputSpec(context)?.label ?? "User Code" }
/// The optional second value's label ("Account ID (optional)"), or nil when the profile has none. /// The optional second value's label ("Account ID (optional)"), or nil when the profile has none.
public func secondInputLabel(_ context: DriverContext) -> String? { inputSpec(context)?.second?.label } public func secondInputLabel(_ context: DriverContext) -> String? { inputSpec(context)?.second?.label }

View File

@@ -52,7 +52,7 @@ enum QuickCommand {
let before = try await OptionState.load(client: client, queue: queue) let before = try await OptionState.load(client: client, queue: queue)
let context = DriverContext(ppd: before.ppd, attributes: before.snapshot.attributes) let context = DriverContext(ppd: before.ppd, attributes: before.snapshot.attributes)
if let value, let error = action.validationError(value, context: context) { if let value, let error = action.validationError(value, context: context) {
throw CupsAdminError.usage("\(action.inputLabel(context).lowercased()) \(value): \(error)") throw CupsAdminError.usage("\(action.inputLabel(context)) \(value): \(error)")
} }
if let secondValue, let error = action.secondValidationError(secondValue, context: context) { if let secondValue, let error = action.secondValidationError(secondValue, context: context) {
throw CupsAdminError.usage("second value \(secondValue): \(error)") throw CupsAdminError.usage("second value \(secondValue): \(error)")

View File

@@ -56,7 +56,7 @@ private func profileID(_ id: String, _ context: DriverContext) -> String? {
let clear = try QuickAction.named("usercode")!.resolve(c, clearing: true).get().changes let clear = try QuickAction.named("usercode")!.resolve(c, clearing: true).get().changes
#expect(clear.map(\.value) == ["False", "None"]) #expect(clear.map(\.value) == ["False", "None"])
// Ricoh takes one value: digits, no second input. // Ricoh takes one value: digits, no second input.
#expect(QuickAction.named("usercode")!.inputLabel(c) == "User code") #expect(QuickAction.named("usercode")!.inputLabel(c) == "User Code")
#expect(QuickAction.named("usercode")!.secondInputLabel(c) == nil) #expect(QuickAction.named("usercode")!.secondInputLabel(c) == nil)
#expect(throws: QuickActionUnavailable.self) { try QuickAction.named("usercode")!.resolve(c, value: "4321", secondValue: "9").get() } #expect(throws: QuickActionUnavailable.self) { try QuickAction.named("usercode")!.resolve(c, value: "4321", secondValue: "9").get() }
} }