Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External delete directly #23489

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/files/css/files.scss
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ a.action > img {
.fileActionsMenu .action.permanent {
opacity: 1;
}

}

// Ellipsize long sharer names
Expand All @@ -641,6 +642,13 @@ a.action > img {
margin-left: 6px;
}

.fileActionsMenu .action-delete-container.permanent-delete span{
color: red;
}
.filesSelectMenu .item-delete.permanent-delete span {
color: red;
}

#fileList .remoteAddress .userDomain {
margin-left: 0 !important;
}
Expand Down
24 changes: 20 additions & 4 deletions apps/files/js/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
iconClass: action.iconClass,
permissions: action.permissions,
type: action.type || FileActions.TYPE_DROPDOWN,
altText: action.altText || ''
altText: action.altText || '',
deleteAlert: action.deleteAlert || ''
};
if (_.isUndefined(action.displayName)) {
actionSpec.displayName = t('files', name);
Expand Down Expand Up @@ -694,17 +695,32 @@
name: 'Delete',
displayName: function(context) {
var mountType = context.$file.attr('data-mounttype');
var noTrashbin = context.$file.attr('no-trashbin');
var type = context.$file.attr('data-type');
var deleteTitle = (type && type === 'file')
? t('files', 'Delete file')
: t('files', 'Delete folder')
if (noTrashbin && noTrashbin == 'true'){
var deleteTitle = (type && type === 'file')
? t('files', 'Delete file permanently')
: t('files', 'Delete folder permanently');
} else {
var deleteTitle = (type && type === 'file')
? t('files', 'Delete file')
: t('files', 'Delete folder');
}
if (mountType === 'external-root') {
deleteTitle = t('files', 'Disconnect storage');
} else if (mountType === 'shared-root') {
deleteTitle = t('files', 'Leave this share');
}
return deleteTitle;
},
deleteAlert: function(context) {
var noTrashbin = context.$file.attr('no-trashbin')
if (noTrashbin && noTrashbin == 'true') {
return "permanent-delete"
} else {
return ""
}
},
mime: 'all',
order: 1000,
// permission is READ because we show a hint instead if there is no permission
Expand Down
4 changes: 4 additions & 0 deletions apps/files/js/fileactionsmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@
item = _.extend({}, item);
item.icon = item.icon(fileName, self._context);
}
if (_.isFunction(item.deleteAlert)) {
item = _.extend({}, item);
item.deleteAlert = item.deleteAlert(self._context);
}
item.inline = item.type === OCA.Files.FileActions.TYPE_INLINE
return item;
});
Expand Down
52 changes: 34 additions & 18 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@
this.multiSelectMenuItems[i] = this.multiSelectMenuItems[i](this);
}
}
this.fileMultiSelectMenu = new OCA.Files.FileMultiSelectMenu(this.multiSelectMenuItems);
this.fileMultiSelectMenu.render();
this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el);
}

if (options.sorting) {
Expand Down Expand Up @@ -398,10 +395,6 @@
this.$el.on('show', _.bind(this._onShow, this));
this.$el.on('urlChanged', _.bind(this._onUrlChanged, this));
this.$el.find('.select-all').click(_.bind(this._onClickSelectAll, this));
this.$el.find('.actions-selected').click(function () {
self.fileMultiSelectMenu.show(self);
return false;
});

this.$container.on('scroll', _.bind(this._onScroll, this));

Expand Down Expand Up @@ -1486,6 +1479,7 @@
permissions = this.getDirectoryPermissions();
}


//containing tr
var tr = $('<tr></tr>').attr({
"data-id" : fileData.id,
Expand All @@ -1497,7 +1491,8 @@
"data-etag": fileData.etag,
"data-permissions": permissions,
"data-has-preview": fileData.hasPreview !== false,
"data-e2eencrypted": fileData.isEncrypted === true
"data-e2eencrypted": fileData.isEncrypted === true,
"no-trashbin": fileData.noTrashbin
});

if (dataIcon) {
Expand Down Expand Up @@ -1971,7 +1966,7 @@
targetDir = '/' + targetDir;
}
this._currentDirectory = targetDir;

// legacy stuff
this.$el.find('#dir').val(targetDir);

Expand Down Expand Up @@ -2063,21 +2058,33 @@
this._currentFileModel = null;
this.$el.find('.select-all').prop('checked', false);
this.showMask();
this._reloadCall = this.filesClient.getFolderContents(
this.getCurrentDirectory(), {
includeParent: true,
properties: this._getWebdavProperties()
}
);

if (this._detailsView) {
// close sidebar
this._updateDetailsView(null);
}
this._setCurrentDir(this.getCurrentDirectory(), false);

var getStorageStatisticsCall = this.getStorageStatistics();
getStorageStatisticsCall
.then(storageStatus => {
this.fileMultiSelectMenu = new OCA.Files.FileMultiSelectMenu(this.multiSelectMenuItems,storageStatus);
this.fileMultiSelectMenu.render();
this.$el.find('.selectedActions').append(this.fileMultiSelectMenu.$el);

this.$el.find('.actions-selected').click(() =>{
this.fileMultiSelectMenu.show(this);
return false;
})
});

this.storageStatusCall = this.getStorageStatistics();
var callBack = this.reloadCallback.bind(this);
return this._reloadCall.then(callBack, callBack);
return this.storageStatusCall
.then(storageStatus => this.filesClient.getFolderContents(this.getCurrentDirectory(),{includeParent:true,properties:this._getWebdavProperties()},storageStatus))
.then(callBack, callBack);
},
reloadCallback: function(status, result) {
reloadCallback: function(status, result, storageStatus) {
delete this._reloadCall;
this.hideMask();

Expand Down Expand Up @@ -2126,7 +2133,7 @@
}

this.updateStorageStatistics(true);

// first entry is the root
this.dirInfo = result.shift();
this.breadcrumb.setDirectoryInfo(this.dirInfo);
Expand All @@ -2135,6 +2142,11 @@
this._updateDirectoryPermissions();
}

result = result.map(function(el) {
var o = Object.assign({}, el);
o.noTrashbin = storageStatus.data.noTrashbin;
return o;
})
result.sort(this._sortComparator);
this.setFiles(result);

Expand All @@ -2155,6 +2167,10 @@
updateStorageStatistics: function(force) {
OCA.Files.Files.updateStorageStatistics(this.getCurrentDirectory(), force);
},

getStorageStatistics: function() {
return OCA.Files.Files.getStorageStatistics(this.getCurrentDirectory());
},

updateStorageQuotas: function() {
OCA.Files.Files.updateStorageQuotas();
Expand Down
12 changes: 11 additions & 1 deletion apps/files/js/filemultiselectmenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,17 @@
tagName: 'div',
className: 'filesSelectMenu popovermenu bubble menu-center',
_scopes: null,
initialize: function(menuItems) {
initialize: function(menuItems,storageStatus) {
if (storageStatus && storageStatus.data.noTrashbin) {
menuItems = menuItems.map(function(el) {
var o = Object.assign({}, el);
if (o.name == "delete") {
o.deleteAlert = "permanent-delete";
o.displayName = "delete permanently";
}
return o;
});
}
this._scopes = menuItems;
},
events: {
Expand Down
15 changes: 15 additions & 0 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
Files.updateMaxUploadFilesize(response);
});
},
_getStorageStatistics: function(currentDir) {
var deferred = $.Deferred();
var promise = deferred.promise();
$.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) {
deferred.resolve(response);
});
return promise;
},
// update quota
updateStorageQuotas: function() {
Files._updateStorageQuotasThrottled();
Expand Down Expand Up @@ -64,6 +72,13 @@
}
},

getStorageStatistics: function(dir) {
if (!OC.currentUser) {
return;
}
return Files._getStorageStatistics(dir);
},

updateMaxUploadFilesize:function(response) {
if (response === undefined) {
return;
Expand Down
6 changes: 5 additions & 1 deletion apps/files/js/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ templates['fileactionsmenu'] = template({"1":function(container,depth0,helpers,p
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"inline") : depth0),{"name":"if","hash":{},"fn":container.program(2, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":3,"column":13},"end":{"line":3,"column":40}}})) != null ? stack1 : "")
+ " action-"
+ alias4(((helper = (helper = lookupProperty(helpers,"nameLowerCase") || (depth0 != null ? lookupProperty(depth0,"nameLowerCase") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"nameLowerCase","hash":{},"data":data,"loc":{"start":{"line":3,"column":48},"end":{"line":3,"column":65}}}) : helper)))
+ "-container\">\n <a href=\"#\" class=\"menuitem action action-"
+ "-container "
+ alias4(((helper = (helper = lookupProperty(helpers,"deleteAlert") || (depth0 != null ? lookupProperty(depth0,"deleteAlert") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"deleteAlert","hash":{},"data":data,"loc":{"start":{"line":3,"column":76},"end":{"line":3,"column":91}}}) : helper)))
+ "\">\n <a href=\"#\" class=\"menuitem action action-"
+ alias4(((helper = (helper = lookupProperty(helpers,"nameLowerCase") || (depth0 != null ? lookupProperty(depth0,"nameLowerCase") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"nameLowerCase","hash":{},"data":data,"loc":{"start":{"line":4,"column":45},"end":{"line":4,"column":62}}}) : helper)))
+ " permanent\" data-action=\""
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":4,"column":87},"end":{"line":4,"column":95}}}) : helper)))
Expand Down Expand Up @@ -222,6 +224,8 @@ templates['filemultiselectmenu'] = template({"1":function(container,depth0,helpe

return " <li class=\"item-"
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":3,"column":18},"end":{"line":3,"column":26}}}) : helper)))
+ " "
+ alias4(((helper = (helper = lookupProperty(helpers,"deleteAlert") || (depth0 != null ? lookupProperty(depth0,"deleteAlert") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"deleteAlert","hash":{},"data":data,"loc":{"start":{"line":3,"column":27},"end":{"line":3,"column":42}}}) : helper)))
+ "\">\n <a href=\"#\" class=\"menuitem action "
+ alias4(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":4,"column":38},"end":{"line":4,"column":46}}}) : helper)))
+ " permanent\" data-action=\""
Expand Down
2 changes: 1 addition & 1 deletion apps/files/js/templates/fileactionsmenu.handlebars
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul>
{{#each items}}
<li class="{{#if inline}}hidden{{/if}} action-{{nameLowerCase}}-container">
<li class="{{#if inline}}hidden{{/if}} action-{{nameLowerCase}}-container {{deleteAlert}}">
<a href="#" class="menuitem action action-{{nameLowerCase}} permanent" data-action="{{name}}">
{{#if icon}}<img class="icon" src="{{icon}}"/>
{{else}}
Expand Down
2 changes: 1 addition & 1 deletion apps/files/js/templates/filemultiselectmenu.handlebars
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul>
{{#each items}}
<li class="item-{{name}}">
<li class="item-{{name}} {{deleteAlert}}">
<a href="#" class="menuitem action {{name}} permanent" data-action="{{name}}">
{{#if iconClass}}
<span class="icon {{iconClass}}"></span>
Expand Down
3 changes: 2 additions & 1 deletion apps/files/lib/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static function buildFileStorageStatistics($dir) {
$maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']);
$maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize);
$maxHumanFileSize = $l->t('Upload (max. %s)', [$maxHumanFileSize]);

return [
'uploadMaxFilesize' => $maxUploadFileSize,
'maxHumanFilesize' => $maxHumanFileSize,
Expand All @@ -65,6 +65,7 @@ public static function buildFileStorageStatistics($dir) {
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
'mountType' => $storageInfo['mountType'],
'mountPoint' => $storageInfo['mountPoint'],
'noTrashbin' => $storageInfo['noTrashbin'],
];
}

Expand Down
2 changes: 2 additions & 0 deletions apps/files_external/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ MountOptionsDropdown.prototype = {
mountOptionsFilesystemCheckOnce: t('files_external', 'Never'),
mountOptionsFilesystemCheckDA: t('files_external', 'Once every direct access'),
mountOptionsReadOnlyLabel: t('files_external', 'Read only'),
mountOptionsNoTrashbinLabel: t('files_external','Deletion without trashbin'),
deleteLabel: t('files_external', 'Delete')
}));
this.$el = $el;
Expand Down Expand Up @@ -1288,6 +1289,7 @@ MountConfigListView.prototype = _.extend({
'enable_sharing',
'encoding_compatibility',
'readonly',
'no_trashbin',
'delete'
];
if (this._encryptionEnabled) {
Expand Down
6 changes: 4 additions & 2 deletions apps/files_external/js/templates.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
<label for="mountOptionsReadOnly">{{mountOptionsReadOnlyLabel}}</label>
</span>
</li>
<li class="optionRow persistent">
<li class="optionRow">
<span class="menuitem">
<input id="mountOptionsNoTrashbin" class="checkbox" name="no_trashbin" type="checkbox" value="true"/>
<label for="mountOptionsNoTrashbin">{{mountOptionsNoTrashbinLabel}}</label>
</span>
</li><li class="optionRow persistent">
<a href="#" class="menuitem remove icon-delete">
<span>{{deleteLabel}}</span>
</a>
Expand Down
6 changes: 5 additions & 1 deletion apps/files_external/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
use OCP\IGroup;
use OCP\IUser;
use Symfony\Component\EventDispatcher\GenericEvent;
use OCA\Files_External\Listener\MoveToTrashListener;

/**
* @package OCA\Files_External\AppInfo
Expand Down Expand Up @@ -116,7 +117,10 @@ function (GenericEvent $event) {
$config = $this->getContainer()->query(DBConfigService::class);
$config->modifyMountsOnGroupDelete($group->getGID());
}
);
);
$container = $this->getContainer();
$moveToTrashListener = $container->query(MoveToTrashListener::class);
$dispatcher->addListener('OCA\Files_Trashbin::moveToTrash',[$moveToTrashListener,'handle']);
}

/**
Expand Down
Loading