Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Nov 7, 2017
0 parents commit 4bd6402
Show file tree
Hide file tree
Showing 9 changed files with 219 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
npm-debug.log
node_modules
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.1.0 - First Release
* Every feature added
* Every bug fixed
20 changes: 20 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2017 JJ Kasper

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# actual-delete Atom package

Adds option to context menu in file tree to skip recycle or trash bin and actually deletes the entry.

Works with nuclide package

## Config

| setting | type | default | description |
|---------|------|---------|-------------|
| `confirm` | boolean | `true` | Show a confirm dialog before deleting the files. |

## Keybindings
| Keystroke | Command | Selector |
|-----------|---------|----------|
| `shift-delete` | `actual-delete:delete` | `.tree-view` |
5 changes: 5 additions & 0 deletions keymaps/actual-delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
".tree-view": {
"shift-delete": "actual-delete:delete"
}
}
119 changes: 119 additions & 0 deletions lib/actual-delete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
'use babel';

import { CompositeDisposable } from 'atom';
import fse from 'fs-extra';

export default {

config: {
confirmDelete: {
description: 'Confirm before permanently deleting files',
type: 'boolean',
default: true
}
},

subscriptions: null,

activate(state) {
// Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
this.subscriptions = new CompositeDisposable();

// Register command that toggles this view
this.subscriptions.add(atom.commands.add('atom-workspace', {
'actual-delete:delete': () => this.delete()
}));
},

deactivate() {
this.subscriptions.dispose();
},

error(shortMsg, longMsg) {
atom.confirm({
message: shortMsg,
detailedMessage: longMsg
});
},

delete() {
let handlePlugins = {

'nuclide-file-tree': function() {
let fileTree = atom.packages.getActivePackage('nuclide-file-tree');
fileTree = fileTree.mainModule._createView();

let selPath = fileTree._store._selectionRange._anchor._nodeKey;

if(selPath.indexOf('nuclide://') > -1) {
this.error('Actual-delete: error deleting...', 'Nuclide remote folders are currently not supported. Although if you are connecting to a server without a trash or recycle bin the file should be permanently deleted with the normal delete option.');
return 'err';
}

return selPath;
},

'tree-view': function() {
let fileTree = atom.packages.getActivePackage('tree-view');
fileTree = fileTree.mainModule.treeView;

return fileTree.selectedPath;
},
}
handlePlugins['nuclide-file-tree'] = handlePlugins['nuclide-file-tree'].bind(this);

let supportedPkgs = Object.keys(handlePlugins);
let selPath = null;
let supportedPlugin = false;
let hadErr = false;

supportedPkgs.some((pkg, i) => {
if(!atom.packages.isPackageActive(pkg))
return false;

supportedPlugin = true;
selPath = handlePlugins[pkg]();

if(selPath && selPath !== 'err')
return true;
});

if(selPath === 'err')
return;

if(!supportedPlugin) {
this.error('Actual-delete: error deleting...', 'Current file-view plugin is not yet supported.');
return;
}

let confirmOpts = {
message: 'Actual-delete: confirm!',
detailedMessage: 'Are you positive you want to permanently delete: ' + selPath,
buttons: {
'Delete Permanently': function() {
this.runDelete(selPath);
},
Cancel: null
}
};
confirmOpts.buttons['Delete Permanently'] = confirmOpts.buttons['Delete Permanently'].bind(this);

if(atom.config.get('actual-delete.confirmDelete')) {
atom.confirm(confirmOpts);
return;
}
else {
this.runDelete(selPath);
}
},

runDelete(selPath) {
fse.remove(selPath, (err) => {
if(err) {
this.error('Actual-delete: error while deleting...',
'The path: ' + selPath + ' could not be deleted.');
console.log('actual-delete: ', err);
}
})
}
};
10 changes: 10 additions & 0 deletions menus/actual-delete.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"context-menu": {
".tree-view .entry": [
{
"label": "Actual delete",
"command": "actual-delete:delete"
}
]
}
}
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "actual-delete",
"main": "./lib/actual-delete",
"version": "0.1.0",
"description": "Adds option to context menu in file tree to skip recycle or trash bin and actually deletes the entry. Works with nuclide package.",
"keywords": ["delete", "actual", "permanent"],
"activationCommands": {
"atom-workspace": "actual-delete:delete"
},
"repository": "",
"license": "MIT",
"engines": {
"atom": ">=1.17.0 <2.0.0"
},
"dependencies": {
"fs-extra": "^4.0.1"
}
}
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


fs-extra@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.1.tgz#7fc0c6c8957f983f57f306a24e5b9ddd8d0dd880"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^3.0.0"
universalify "^0.1.0"

graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"

jsonfile@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-3.0.1.tgz#a5ecc6f65f53f662c4415c7675a0331d0992ec66"
optionalDependencies:
graceful-fs "^4.1.6"

universalify@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.1.tgz#fa71badd4437af4c148841e3b3b165f9e9e590b7"

0 comments on commit 4bd6402

Please sign in to comment.