Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Confirm folder delete - fixes issue #4446 #4515

Merged
merged 8 commits into from
Aug 1, 2013
Merged
32 changes: 31 additions & 1 deletion src/document/DocumentCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,37 @@ define(function (require, exports, module) {

function handleFileDelete() {
var entry = ProjectManager.getSelectedItem();
ProjectManager.deleteItem(entry);
if (entry.isDirectory) {
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_EXT_DELETED,
Strings.CONFIRM_FOLDER_DELETE_TITLE,
StringUtils.format(
Strings.CONFIRM_FOLDER_DELETE,
StringUtils.breakableUrl(entry.name)
),
[
{
className : Dialogs.DIALOG_BTN_CLASS_NORMAL,
id : Dialogs.DIALOG_BTN_CANCEL,
text : Strings.CANCEL
},
{
className : Dialogs.DIALOG_BTN_CLASS_PRIMARY,
id : Dialogs.DIALOG_BTN_OK,
text : Strings.OK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterflynn Mentioned that he preferred Delete here instead of Ok. Maybe you could change this string. I am not sure if using CMD_FILE_DELETE will be ok, or if creating a new string for delete might be better.

}
]
)
.done(function (id) {
if (id === Dialogs.DIALOG_BTN_CANCEL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably don't need this branch of the if as it does nothing, and just use the other one.

return;
} else if (id === Dialogs.DIALOG_BTN_OK) {
ProjectManager.deleteItem(entry);
}
});
} else {
ProjectManager.deleteItem(entry);
}
}

/** Show the selected sidebar (tree or working set) item in Finder/Explorer */
Expand Down
2 changes: 2 additions & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ define({
"SAVE_CLOSE_MESSAGE" : "Do you want to save the changes you made in the document <span class='dialog-filename'>{0}</span>?",
"SAVE_CLOSE_MULTI_MESSAGE" : "Do you want to save your changes to the following files?",
"EXT_MODIFIED_TITLE" : "External Changes",
"CONFIRM_FOLDER_DELETE_TITLE" : "Confirm Delete",
"CONFIRM_FOLDER_DELETE" : "Are you sure you want to delete the folder?",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To show the file, use Are you sure you want to delete the folder <span class='dialog-filename'>{0}</span>? or similar. After using StringUtils.format, the folder name will replace {0} in the string.

"FILE_DELETED_TITLE" : "File Deleted",
"EXT_MODIFIED_MESSAGE" : "<span class='dialog-filename'>{0}</span> has been modified on disk, but also has unsaved changes in {APP_NAME}.<br /><br />Which version do you want to keep?",
"EXT_DELETED_MESSAGE" : "<span class='dialog-filename'>{0}</span> has been deleted on disk, but has unsaved changes in {APP_NAME}.<br /><br />Do you want to keep your changes?",
Expand Down