summaryrefslogtreecommitdiffstats
path: root/core/js/shareitemmodel.js
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2015-09-03 15:53:17 +0200
committerVincent Petry <pvince81@owncloud.com>2015-09-16 07:23:27 +0200
commitce1b0c650e3a0e4cb701609ee08a13182909219a (patch)
tree917a0b27ab41898fbc37861909489824f49f3392 /core/js/shareitemmodel.js
parent5dc2c35ce5f3023ccea4cc599cf54d6b1c0e2c01 (diff)
downloadnextcloud-server-ce1b0c650e3a0e4cb701609ee08a13182909219a.tar.gz
nextcloud-server-ce1b0c650e3a0e4cb701609ee08a13182909219a.zip
show link share
Diffstat (limited to 'core/js/shareitemmodel.js')
-rw-r--r--core/js/shareitemmodel.js57
1 files changed, 55 insertions, 2 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js
index acaa890be11..e8371e16e0a 100644
--- a/core/js/shareitemmodel.js
+++ b/core/js/shareitemmodel.js
@@ -15,6 +15,14 @@
}
/**
+ * @typedef {object} OC.Share.Types.LinkShareInfo
+ * @property {bool} isLinkShare
+ * @property {string} token
+ * @property {string|null} password
+ * @property {string} link
+ */
+
+ /**
* @typedef {object} OC.Share.Types.Collection
* @property {string} item_type
* @property {string} path
@@ -49,6 +57,7 @@
* @typedef {object} OC.Share.Types.ShareItemInfo
* @property {OC.Share.Types.Reshare} reshare
* @property {OC.Share.Types.ShareInfo[]} shares
+ * @property {OC.Share.Types.LinkShareInfo|undefined} linkShare
*/
/**
@@ -64,11 +73,16 @@
if(!_.isUndefined(options.configModel)) {
this.configModel = options.configModel;
}
+ if(!_.isUndefined(options.fileInfoModel)) {
+ /** @type {OC.Files.FileInfo} **/
+ this.fileInfoModel = options.fileInfoModel;
+ }
},
defaults: {
allowPublicUploadStatus: false,
- permissions: 0
+ permissions: 0,
+ linkShare: {}
},
/**
@@ -186,7 +200,6 @@
* @returns {string}
*/
getReshareOwnerDisplayname: function() {
- return 'foo';
return this.get('reshare').displayname_owner;
},
@@ -399,12 +412,52 @@
});
}
+ /** @type {OC.Share.Types.ShareInfo[]} **/
var shares = _.toArray(data.shares);
this.legacyFillCurrentShares(shares);
+ var linkShare = { isLinkShare: false };
+ // filter out the share by link
+ shares = _.reject(shares,
+ /**
+ * @param {OC.Share.Types.ShareInfo} share
+ */
+ function(share) {
+ var isShareLink =
+ share.share_type === OC.Share.SHARE_TYPE_LINK
+ && ( share.file_source === this.get('itemSource')
+ || share.item_source === this.get('itemSource'));
+
+ if (isShareLink) {
+ var link = window.location.protocol + '//' + window.location.host;
+ if (!share.token) {
+ // pre-token link
+ var fullPath = this.fileInfoModel.get('path') + '/' +
+ this.fileInfoModel.get('name');
+ var location = '/' + OC.currentUser + '/files' + fullPath;
+ var type = this.fileInfoModel.isDirectory() ? 'folder' : 'file';
+ link += OC.linkTo('', 'public.php') + '?service=files&' +
+ type + '=' + encodeURIComponent(location);
+ } else {
+ link += OC.generateUrl('/s/') + share.token;
+ }
+ linkShare = {
+ isLinkShare: true,
+ token: share.token,
+ password: share.share_with,
+ link: link
+ };
+
+ return share;
+ }
+ },
+ this
+ );
+
return {
reshare: data.reshare,
shares: shares,
+ linkShare: linkShare,
permissions: permissions,
allowPublicUploadStatus: allowPublicUploadStatus
};