Added an alert before deleting the custom prompt and power mode
This commit is contained in:
parent
95790c4a58
commit
3b456104a8
@ -284,7 +284,17 @@ extension CustomPrompt {
|
||||
|
||||
if let onDelete = onDelete, !isPredefined {
|
||||
Button(role: .destructive) {
|
||||
onDelete(self)
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "Delete Prompt?"
|
||||
alert.informativeText = "Are you sure you want to delete '\(self.title)' prompt? This action cannot be undone."
|
||||
alert.alertStyle = .warning
|
||||
alert.addButton(withTitle: "Delete")
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
|
||||
let response = alert.runModal()
|
||||
if response == .alertFirstButtonReturn {
|
||||
onDelete(self)
|
||||
}
|
||||
} label: {
|
||||
Label("Delete", systemImage: "trash")
|
||||
}
|
||||
|
||||
@ -130,8 +130,21 @@ struct ConfigurationView: View {
|
||||
|
||||
if case .edit(let config) = mode {
|
||||
Button("Delete") {
|
||||
powerModeManager.removeConfiguration(with: config.id)
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "Delete Power Mode?"
|
||||
alert.informativeText = "Are you sure you want to delete the '\(config.name)' power mode? This action cannot be undone."
|
||||
alert.alertStyle = .warning
|
||||
alert.addButton(withTitle: "Delete")
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
|
||||
// Style the Delete button as destructive
|
||||
alert.buttons[0].hasDestructiveAction = true
|
||||
|
||||
let response = alert.runModal()
|
||||
if response == .alertFirstButtonReturn {
|
||||
powerModeManager.removeConfiguration(with: config.id)
|
||||
presentationMode.wrappedValue.dismiss()
|
||||
}
|
||||
}
|
||||
.foregroundColor(.red)
|
||||
.padding(.trailing, 8)
|
||||
@ -623,7 +636,7 @@ struct ConfigurationView: View {
|
||||
.padding(.vertical, 8)
|
||||
.background(
|
||||
RoundedRectangle(cornerRadius: 10)
|
||||
.fill(canSave ? .green : .green.opacity(0.5))
|
||||
.fill(canSave ? Color(red: 0.3, green: 0.7, blue: 0.4) : Color(red: 0.3, green: 0.7, blue: 0.4).opacity(0.5))
|
||||
)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
|
||||
@ -118,11 +118,15 @@ struct PowerModeView: View {
|
||||
Text(isReorderMode ? "Done" : "Reorder")
|
||||
.font(.system(size: 13, weight: .medium))
|
||||
}
|
||||
.foregroundColor(.white)
|
||||
.foregroundColor(.primary)
|
||||
.padding(.horizontal, 12)
|
||||
.padding(.vertical, 6)
|
||||
.background(Color.accentColor)
|
||||
.background(Color(NSColor.controlBackgroundColor))
|
||||
.cornerRadius(6)
|
||||
.overlay(
|
||||
RoundedRectangle(cornerRadius: 6)
|
||||
.stroke(Color(NSColor.separatorColor), lineWidth: 1)
|
||||
)
|
||||
}
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
}
|
||||
|
||||
@ -63,18 +63,6 @@ struct PowerModeConfigurationsGrid: View {
|
||||
powerModeManager: powerModeManager,
|
||||
onEditConfig: onEditConfig
|
||||
)
|
||||
.contextMenu {
|
||||
Button(action: {
|
||||
onEditConfig(config)
|
||||
}) {
|
||||
Label("Edit", systemImage: "pencil")
|
||||
}
|
||||
Button(role: .destructive, action: {
|
||||
powerModeManager.removeConfiguration(with: config.id)
|
||||
}) {
|
||||
Label("Remove", systemImage: "trash")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal)
|
||||
@ -330,9 +318,19 @@ struct ConfigurationRow: View {
|
||||
Label("Edit", systemImage: "pencil")
|
||||
}
|
||||
Button(role: .destructive, action: {
|
||||
powerModeManager.removeConfiguration(with: config.id)
|
||||
let alert = NSAlert()
|
||||
alert.messageText = "Delete Power Mode?"
|
||||
alert.informativeText = "Are you sure you want to delete the '\(config.name)' power mode? This action cannot be undone."
|
||||
alert.alertStyle = .warning
|
||||
alert.addButton(withTitle: "Delete")
|
||||
alert.addButton(withTitle: "Cancel")
|
||||
alert.buttons[0].hasDestructiveAction = true
|
||||
|
||||
if alert.runModal() == .alertFirstButtonReturn {
|
||||
powerModeManager.removeConfiguration(with: config.id)
|
||||
}
|
||||
}) {
|
||||
Label("Remove", systemImage: "trash")
|
||||
Label("Delete", systemImage: "trash")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user