diff options
author | Julius Härtl <jus@bitgrid.net> | 2020-01-07 12:57:57 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-01-07 19:35:45 +0100 |
commit | 445274cf93dbae31c6995008dcc0f9834c05d9ca (patch) | |
tree | 5f33fb92ff778f2a7effd66a3bd92e345d4c1bc6 /apps/files_sharing/js/app.js | |
parent | fbed6a3416dd96e3698575f67dc57fc861c2ed46 (diff) | |
download | nextcloud-server-445274cf93dbae31c6995008dcc0f9834c05d9ca.tar.gz nextcloud-server-445274cf93dbae31c6995008dcc0f9834c05d9ca.zip |
Add pending share list to frontend
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing/js/app.js')
-rw-r--r-- | apps/files_sharing/js/app.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index 6cf7a805ada..1a686ee228d 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -22,6 +22,7 @@ OCA.Sharing.App = { _inFileList: null, _outFileList: null, _overviewFileList: null, + _pendingFileList: null, initSharingIn: function($el) { if (this._inFileList) { @@ -129,6 +130,33 @@ OCA.Sharing.App = { return this._deletedFileList }, + initSharingPening: function($el) { + if (this._pendingFileList) { + return this._pendingFileList + } + this._pendingFileList = new OCA.Sharing.FileList( + $el, + { + id: 'shares.pending', + showPending: true, + sharedWithUser: true, + fileActions: this._acceptShareAction(), + config: OCA.Files.App.getFilesConfig(), + // The file list is created when a "show" event is handled, so + // it should be marked as "shown" like it would have been done + // if handling the event with the file list already created. + shown: true, + } + ) + + this._extendFileList(this._pendingFileList) + this._pendingFileList.appName = t('files_sharing', 'Pending shares') + this._pendingFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' + + '<h2>' + t('files_sharing', 'No pending shares') + '</h2>' + + '<p>' + t('files_sharing', 'Shares you have received but not confirmed will show up here') + '</p>') + return this._pendingFileList + }, + initShareingOverview: function($el) { if (this._overviewFileList) { return this._overviewFileList @@ -178,6 +206,12 @@ OCA.Sharing.App = { } }, + removeSharingPending: function() { + if (this._pendingFileList) { + this._pendingFileList.$fileList.empty() + } + }, + removeSharingOverview: function() { if (this._overviewFileList) { this._overviewFileList.$fileList.empty() @@ -249,6 +283,47 @@ OCA.Sharing.App = { return fileActions }, + _acceptShareAction: function() { + const fileActions = new OCA.Files.FileActions() + fileActions.registerAction({ + name: 'Accept share', + displayName: t('files_sharing', 'Accept share'), + mime: 'all', + permissions: OC.PERMISSION_ALL, + iconClass: 'icon-checkmark', + type: OCA.Files.FileActions.TYPE_INLINE, + actionHandler: function(fileName, context) { + const shareId = context.$file.data('shareId') + $.post(OC.linkToOCS('apps/files_sharing/api/v1/shares/pending', 2) + shareId) + .success(function(result) { + context.fileList.remove(context.fileInfoModel.attributes.name) + }).fail(function() { + OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to accept the share.')) + }) + }, + }) + fileActions.registerAction({ + name: 'Reject share', + displayName: t('files_sharing', 'Reject share'), + mime: 'all', + permissions: OC.PERMISSION_ALL, + iconClass: 'icon-close', + type: OCA.Files.FileActions.TYPE_INLINE, + actionHandler: function(fileName, context) { + const shareId = context.$file.data('shareId') + $.ajax({ + url: OC.linkToOCS('apps/files_sharing/api/v1/shares', 2) + shareId, + type: 'DELETE', + }).success(function(result) { + context.fileList.remove(context.fileInfoModel.attributes.name) + }).fail(function() { + OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to reject the share.')) + }) + }, + }) + return fileActions + }, + _onActionsUpdated: function(ev) { _.each([this._inFileList, this._outFileList, this._linkFileList], function(list) { if (!list) { @@ -297,6 +372,12 @@ $(document).ready(function() { $('#app-content-deletedshares').on('hide', function() { OCA.Sharing.App.removeSharingDeleted() }) + $('#app-content-pendingshares').on('show', function(e) { + OCA.Sharing.App.initSharingPening($(e.target)) + }) + $('#app-content-pendingshares').on('hide', function() { + OCA.Sharing.App.removeSharingPending() + }) $('#app-content-shareoverview').on('show', function(e) { OCA.Sharing.App.initShareingOverview($(e.target)) }) |