Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
add delete without trashbin alert
Signed-off-by: xiangbin.li <[email protected]>
  • Loading branch information
dassio committed Sep 9, 2020
commit 40ec5097d54c46d75c1aa38548012fa2dbf7687b
5 changes: 5 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,10 @@ a.action > img {
margin-left: 6px;
}

.fileActionsMenu .action-delete-container.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
28 changes: 18 additions & 10 deletions apps/files/js/filelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,7 @@
permissions = this.getDirectoryPermissions();
}


//containing tr
var tr = $('<tr></tr>').attr({
"data-id" : fileData.id,
Expand All @@ -1497,7 +1498,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 @@ -2063,21 +2065,18 @@
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()
}
);
this.storageStatusCall = this.getStorageStatistics();
if (this._detailsView) {
// close sidebar
this._updateDetailsView(null);
}
this._setCurrentDir(this.getCurrentDirectory(), false);
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 +2125,7 @@
}

this.updateStorageStatistics(true);

// first entry is the root
this.dirInfo = result.shift();
this.breadcrumb.setDirectoryInfo(this.dirInfo);
Expand All @@ -2135,6 +2134,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 +2159,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
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
4 changes: 3 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
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
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 @@ -64,6 +64,7 @@ public static function buildFileStorageStatistics($dir) {
'owner' => $storageInfo['owner'],
'ownerDisplayName' => $storageInfo['ownerDisplayName'],
'mountType' => $storageInfo['mountType'],
'noTrashbin' => $storageInfo['noTrashbin'],
];
}

Expand Down
2 changes: 1 addition & 1 deletion core/js/dist/files_client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/files_client.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions core/src/files/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ import escapeHTML from 'escape-html'
*
* @returns {Promise} promise
*/
getFolderContents: function(path, options) {
getFolderContents: function(path, options,storageStatus) {
if (!path) {
path = ''
}
Expand All @@ -502,10 +502,10 @@ import escapeHTML from 'escape-html'
// remove root dir, the first entry
results.shift()
}
deferred.resolve(result.status, results)
deferred.resolve(result.status, results,storageStatus)
} else {
result = _.extend(result, self._getSabreException(result))
deferred.reject(result.status, result)
deferred.reject(result.status, result,storageStatus)
}
})
return promise
Expand Down
3 changes: 2 additions & 1 deletion lib/private/legacy/OC_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,8 @@ public static function getStorageInfo($path, $rootInfo = null) {
'relative' => $relative,
'owner' => $ownerId,
'ownerDisplayName' => $ownerDisplayName,
'mountType' => $mount->getMountType()
'mountType' => $mount->getMountType(),
'noTrashbin' => $mount->getOptions()['no_trashbin'],
];
}

Expand Down