Skip to content

Commit

Permalink
Mark destructive actions
Browse files Browse the repository at this point in the history
  • Loading branch information
NattyNarwhal committed Jun 4, 2024
1 parent dcfd3e5 commit 382b9df
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion Submariner/SBDatabaseController.m
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ - (IBAction)removeItem:(id)sender {
if(resource && ([resource isKindOfClass:[SBPlaylist class]] || [resource isKindOfClass:[SBServer class]])) {

NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Delete the selected item?"];
[alert setInformativeText:@"Deleted items cannot be restored."];
Expand Down
3 changes: 2 additions & 1 deletion Submariner/SBLibraryPurgeOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class SBLibraryPurgeOperation: SBOperation {
alert.alertStyle = .informational
alert.messageText = "Do you want to delete \(tracks!.count) downloaded items?"
alert.informativeText = "Tracks downloaded to the library take up \(totalSizeString) of space on disk. Items that were imported to the library outside of a server won't be affected. You can redownload tracks from a server at any time."
alert.addButton(withTitle: "Delete Items")
let deleteButton = alert.addButton(withTitle: "Delete Items")
deleteButton.hasDestructiveAction = true
alert.addButton(withTitle: "Cancel")
if alert.runModal() == .alertFirstButtonReturn {
self.deleteItems()
Expand Down
29 changes: 19 additions & 10 deletions Submariner/SBMusicController.m
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ - (IBAction)removeArtist:(id)sender {
if(selectedArtist != nil) {
if([selectedArtist.isLinked boolValue] == NO) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Remove"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove from Database"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"Delete"];
NSButton *deleteButton = [alert addButtonWithTitle: @"Delete Files"];
deleteButton.hasDestructiveAction = YES;
[alert setMessageText:@"Delete the selected artist?"];
[alert setInformativeText:@"This artist has been copied into the Submariner database. If you choose Delete, the artist will be removed from the database and deleted from the file system. If you choose Remove, the copied files will be preserved."];
[alert setAlertStyle:NSAlertStyleWarning];
Expand All @@ -247,7 +249,8 @@ - (IBAction)removeArtist:(id)sender {

} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
NSButton *removeButton = [alert addButtonWithTitle:@"Remove"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Remove the selected artist?"];
[alert setInformativeText:@"This can't be undone."];
Expand All @@ -271,9 +274,11 @@ - (IBAction)removeAlbum:(id)sender {
if([selectedAlbum.isLinked boolValue] == NO) {

NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Remove"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove from Database"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"Delete"];
NSButton *deleteButton = [alert addButtonWithTitle: @"Delete Files"];
deleteButton.hasDestructiveAction = YES;
[alert setMessageText:@"Delete the selected album?"];
[alert setInformativeText:@"This album has been copied into the Submariner database. If you choose Delete, the album will be removed from the database and deleted from the file system. If you choose Remove, the copied files will be preserved."];
[alert setAlertStyle:NSAlertStyleWarning];
Expand All @@ -284,7 +289,8 @@ - (IBAction)removeAlbum:(id)sender {

} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Remove the selected album?"];
[alert setInformativeText:@"This can't be undone."];
Expand All @@ -306,9 +312,11 @@ - (IBAction)removeTrack:(id)sender {
if(selectedTrack != nil) {
if([selectedTrack.isLinked boolValue] == NO) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"Remove"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove from Database"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert addButtonWithTitle:@"Delete"];
NSButton *deleteButton = [alert addButtonWithTitle: @"Delete Files"];
deleteButton.hasDestructiveAction = YES;
[alert setMessageText:@"Delete the selected track?"];
[alert setInformativeText:@"This track has been copied into the Submariner database. If you choose Delete, the track will be removed from the database and deleted from the file system. If you choose Remove, the copied files will be preserved."];
[alert setAlertStyle:NSAlertStyleWarning];
Expand All @@ -319,9 +327,10 @@ - (IBAction)removeTrack:(id)sender {

} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
NSButton *removeButton = [alert addButtonWithTitle: @"Remove"];
removeButton.hasDestructiveAction = YES;
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Remove the selected track ?"];
[alert setMessageText:@"Remove the selected track?"];
[alert setInformativeText:@"Removed tracks cannot be restored."];
[alert setAlertStyle:NSAlertStyleWarning];

Expand Down

0 comments on commit 382b9df

Please sign in to comment.