summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-07-17 12:53:45 +0200
committerGitHub <noreply@github.com>2018-07-17 12:53:45 +0200
commita155f804859d4afc579986be6472dfd80ade267d (patch)
tree123031de8298ea99346c9f905155d37766955af0 /apps/files_sharing
parentf78db1820138df0a097399f088057c1b0682ec98 (diff)
parentcdb42432c3a58efc24f59d9a4bb453288f346eab (diff)
downloadnextcloud-server-a155f804859d4afc579986be6472dfd80ade267d.tar.gz
nextcloud-server-a155f804859d4afc579986be6472dfd80ade267d.zip
Merge pull request #10230 from nextcloud/feature/shareoverview
Feature/shares overview
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/appinfo/app.php88
-rw-r--r--apps/files_sharing/js/app.js36
-rw-r--r--apps/files_sharing/js/sharedfilelist.js133
3 files changed, 164 insertions, 93 deletions
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index 4f5cf09befb..567b1a16bac 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -50,54 +50,62 @@ $eventDispatcher->addListener(
$config = \OC::$server->getConfig();
$shareManager = \OC::$server->getShareManager();
$userSession = \OC::$server->getUserSession();
+$l = \OC::$server->getL10N('files_sharing');
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') === 'yes') {
- \OCA\Files\App::getNavigationManager()->add(function () {
- $l = \OC::$server->getL10N('files_sharing');
- return [
- 'id' => 'sharingin',
- 'appname' => 'files_sharing',
- 'script' => 'list.php',
- 'order' => 15,
- 'name' => $l->t('Shared with you'),
- ];
- });
-
- \OCA\Files\App::getNavigationManager()->add(function () {
- $l = \OC::$server->getL10N('files_sharing');
- return [
- 'id' => 'deletedshares',
+
+ $sharingSublistArray = [];
+
+ if (\OCP\Util::isSharingDisabledForUser() === false) {
+ array_push($sharingSublistArray, [
+ 'id' => 'sharingout',
'appname' => 'files_sharing',
'script' => 'list.php',
- 'order' => 18,
- 'name' => $l->t('Deleted shares'),
- ];
- });
+ 'order' => 16,
+ 'name' => $l->t('Shared with others'),
+ ]);
+ }
- if (\OCP\Util::isSharingDisabledForUser() === false) {
- \OCA\Files\App::getNavigationManager()->add(function () {
- $l = \OC::$server->getL10N('files_sharing');
- return [
- 'id' => 'sharingout',
- 'appname' => 'files_sharing',
- 'script' => 'list.php',
- 'order' => 16,
- 'name' => $l->t('Shared with others'),
- ];
- });
+ array_push($sharingSublistArray, [
+ 'id' => 'sharingin',
+ 'appname' => 'files_sharing',
+ 'script' => 'list.php',
+ 'order' => 15,
+ 'name' => $l->t('Shared with you'),
+ ]);
+ if (\OCP\Util::isSharingDisabledForUser() === false) {
// Check if sharing by link is enabled
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
- \OCA\Files\App::getNavigationManager()->add(function () {
- $l = \OC::$server->getL10N('files_sharing');
- return [
- 'id' => 'sharinglinks',
- 'appname' => 'files_sharing',
- 'script' => 'list.php',
- 'order' => 17,
- 'name' => $l->t('Shared by link'),
- ];
- });
+ array_push($sharingSublistArray, [
+ 'id' => 'sharinglinks',
+ 'appname' => 'files_sharing',
+ 'script' => 'list.php',
+ 'order' => 17,
+ 'name' => $l->t('Shared by link'),
+ ]);
}
}
+
+ array_push($sharingSublistArray, [
+ 'id' => 'deletedshares',
+ 'appname' => 'files_sharing',
+ 'script' => 'list.php',
+ 'order' => 19,
+ 'name' => $l->t('Deleted shares'),
+ ]);
+
+ // show_Quick_Access stored as string
+ $defaultExpandedState = $config->getUserValue($userSession->getUser()->getUID(), 'files', 'show_sharing_menu', '0') === '1';
+
+ \OCA\Files\App::getNavigationManager()->add([
+ 'id' => 'shareoverview',
+ 'appname' => 'files_sharing',
+ 'script' => 'list.php',
+ 'order' => 18,
+ 'name' => $l->t('Shares'),
+ 'classes' => 'collapsible',
+ 'sublist' => $sharingSublistArray,
+ 'expandedState' => 'show_sharing_menu'
+ ]);
}
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js
index f63410bc9bf..76d52cfe9e0 100644
--- a/apps/files_sharing/js/app.js
+++ b/apps/files_sharing/js/app.js
@@ -21,6 +21,7 @@ OCA.Sharing.App = {
_inFileList: null,
_outFileList: null,
+ _overviewFileList: null,
initSharingIn: function($el) {
if (this._inFileList) {
@@ -116,6 +117,28 @@ OCA.Sharing.App = {
return this._deletedFileList;
},
+ initShareingOverview: function($el) {
+ if (this._overviewFileList) {
+ return this._overviewFileList;
+ }
+ this._overviewFileList = new OCA.Sharing.FileList(
+ $el,
+ {
+ id: 'shares.overview',
+ scrollContainer: $('#app-content'),
+ config: OCA.Files.App.getFilesConfig(),
+ isOverview: true
+ }
+ );
+
+ this._extendFileList(this._overviewFileList);
+ this._overviewFileList.appName = t('files_sharing', 'Shares');
+ this._overviewFileList.$el.find('#emptycontent').html('<div class="icon-share"></div>' +
+ '<h2>' + t('files_sharing', 'No shares') + '</h2>' +
+ '<p>' + t('files_sharing', 'Shares will show up here') + '</p>');
+ return this._overviewFileList;
+ },
+
removeSharingIn: function() {
if (this._inFileList) {
this._inFileList.$fileList.empty();
@@ -140,6 +163,12 @@ OCA.Sharing.App = {
}
},
+ removeSharingOverview: function() {
+ if (this._overviewFileList) {
+ this._overviewFileList.$fileList.empty();
+ }
+ },
+
/**
* Destroy the app
*/
@@ -152,6 +181,7 @@ OCA.Sharing.App = {
this._inFileList = null;
this._outFileList = null;
this._linkFileList = null;
+ this._overviewFileList = null;
delete this._globalActionsInitialized;
},
@@ -252,4 +282,10 @@ $(document).ready(function() {
$('#app-content-deletedshares').on('hide', function() {
OCA.Sharing.App.removeSharingDeleted();
});
+ $('#app-content-shareoverview').on('show', function(e) {
+ OCA.Sharing.App.initShareingOverview($(e.target));
+ });
+ $('#app-content-shareoverview').on('hide', function() {
+ OCA.Sharing.App.removeSharingOverview();
+ });
});
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index 973d2120b16..71192497143 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -40,6 +40,7 @@
_showDeleted: false,
_clientSideSort: true,
_allowSelection: false,
+ _isOverview: false,
/**
* @private
@@ -60,6 +61,9 @@
if (options && options.showDeleted) {
this._showDeleted = true;
}
+ if (options && options.isOverview) {
+ this._isOverview = true;
+ }
},
_renderRow: function() {
@@ -191,55 +195,62 @@
// there is only root
this._setCurrentDir('/', false);
+ var promises = [];
+ var deletedShares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ var shares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ shared_with_me: this._sharedWithUser !== false,
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ var remoteShares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json',
+ include_tags: true
+ },
+ type: 'GET',
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true');
+ },
+ };
+
+ // Add the proper ajax requests to the list and run them
+ // and make sure we have 2 promises
if (this._showDeleted) {
- var shares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1', 2) + 'deletedshares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- include_tags: true
- },
- type: 'GET',
- beforeSend: function(xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- } else {
- var shares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- shared_with_me: !!this._sharedWithUser,
- include_tags: true
- },
- type: 'GET',
- beforeSend: function(xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- }
- var promises = [];
- promises.push(shares);
-
- if (!!this._sharedWithUser) {
- var remoteShares = $.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
- /* jshint camelcase: false */
- data: {
- format: 'json',
- include_tags: true
- },
- type: 'GET',
- beforeSend: function(xhr) {
- xhr.setRequestHeader('OCS-APIREQUEST', 'true');
- },
- });
- promises.push(remoteShares);
+ promises.push($.ajax(deletedShares));
} else {
- //Push empty promise so callback gets called the same way
- promises.push($.Deferred().resolve());
+ promises.push($.ajax(shares));
+
+ if (this._sharedWithUser !== false || this._isOverview) {
+ promises.push($.ajax(remoteShares));
+ }
+ if (this._isOverview) {
+ shares.data.shared_with_me = !shares.data.shared_with_me
+ promises.push($.ajax(shares));
+ }
}
this._reloadCall = $.when.apply($, promises);
@@ -247,7 +258,7 @@
return this._reloadCall.then(callBack, callBack);
},
- reloadCallback: function(shares, remoteShares) {
+ reloadCallback: function(shares, remoteShares, additionnalShares) {
delete this._reloadCall;
this.hideMask();
@@ -257,14 +268,30 @@
var files = [];
- if (shares[0].ocs && shares[0].ocs.data) {
- files = files.concat(this._makeFilesFromShares(shares[0].ocs.data));
+ // make sure to use the same format
+ if (shares[0] && shares[0].ocs) {
+ shares = shares[0];
+ }
+ if (remoteShares && remoteShares[0] && remoteShares[0].ocs) {
+ remoteShares = remoteShares[0];
+ }
+ if (additionnalShares && additionnalShares[0] && additionnalShares[0].ocs) {
+ additionnalShares = additionnalShares[0];
+ }
+
+ if (shares.ocs && shares.ocs.data) {
+ files = files.concat(this._makeFilesFromShares(shares.ocs.data, this._sharedWithUser));
}
- if (remoteShares && remoteShares[0].ocs && remoteShares[0].ocs.data) {
- files = files.concat(this._makeFilesFromRemoteShares(remoteShares[0].ocs.data));
+ if (remoteShares && remoteShares.ocs && remoteShares.ocs.data) {
+ files = files.concat(this._makeFilesFromRemoteShares(remoteShares.ocs.data));
}
+ if (additionnalShares && additionnalShares && additionnalShares.ocs && additionnalShares.ocs.data) {
+ files = files.concat(this._makeFilesFromShares(additionnalShares.ocs.data, !this._sharedWithUser));
+ }
+
+
this.setFiles(files);
return true;
},
@@ -303,7 +330,7 @@
* @param {Array} data OCS API share array
* @return {Array.<OCA.Sharing.SharedFileInfo>} array of shared file info
*/
- _makeFilesFromShares: function(data) {
+ _makeFilesFromShares: function(data, sharedWithUser) {
/* jshint camelcase: false */
var self = this;
var files = data;
@@ -339,7 +366,7 @@
stime: share.stime * 1000,
expiration: share.expiration,
};
- if (self._sharedWithUser) {
+ if (sharedWithUser) {
file.shareOwner = share.displayname_owner;
file.shareOwnerId = share.uid_owner;
file.name = OC.basename(share.file_target);