X Tutup
Skip to content

Commit eab3959

Browse files
committed
Show pending remote shares at Shared with you tab
1 parent 6296422 commit eab3959

File tree

6 files changed

+63
-8
lines changed

6 files changed

+63
-8
lines changed

apps/files_sharing/appinfo/routes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@
106106
'url' => '/api/v1/remote_shares',
107107
'verb' => 'GET'
108108
],
109+
[
110+
'name' => 'RemoteOcs#getAllShares',
111+
'url' => '/api/v1/remote_shares/all',
112+
'verb' => 'GET'
113+
],
109114
[
110115
'name' => 'RemoteOcs#getOpenShares',
111116
'url' => '/api/v1/remote_shares/pending',

apps/files_sharing/js/sharedfilelist.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@
244244

245245
if (!!this._sharedWithUser) {
246246
var remoteShares = $.ajax({
247-
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares',
247+
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'remote_shares/all',
248248
/* jshint camelcase: false */
249249
data: {
250250
format: 'json',
@@ -339,7 +339,7 @@
339339
.map(function(share) {
340340
var file = {
341341
shareOwner: share.owner + '@' + share.remote.replace(/.*?:\/\//g, ""),
342-
shareState: share.accepted ? OC.Share.STATE_ACCEPTED : OC.Share.STATE_PENDING,
342+
shareState: !!parseInt(share.accepted) ? OC.Share.STATE_ACCEPTED : OC.Share.STATE_PENDING,
343343
name: OC.basename(share.mountpoint),
344344
mtime: share.mtime * 1000,
345345
mimetype: share.mimetype,

apps/files_sharing/lib/Controller/RemoteOcsController.php

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,49 @@ public function declineShare($id) {
108108
* @NoCSRFRequired
109109
* @NoAdminRequired
110110
*
111+
* @param bool $includingPending
111112
* @return Result
112113
*/
113-
public function getShares() {
114-
$shares = $this->externalManager->getAcceptedShares();
115-
$shares = \array_map([$this, 'extendShareInfo'], $shares);
114+
public function getShares($includingPending = false) {
115+
$shares = \array_map(
116+
[$this, 'extendShareInfo'],
117+
$this->externalManager->getAcceptedShares()
118+
);
119+
120+
if ($includingPending === true) {
121+
/**
122+
* pending shares have mountpoint looking like
123+
* {{TemporaryMountPointName#/filename.ext}}
124+
* so we need to cut it off
125+
*/
126+
$openShares = \array_map(
127+
function ($share) {
128+
$share['mountpoint'] = \substr(
129+
$share['mountpoint'],
130+
\strlen('{{TemporaryMountPointName#')
131+
);
132+
133+
$share['mountpoint'] = \rtrim($share['mountpoint'], '}');
134+
return $share;
135+
},
136+
$this->externalManager->getOpenShares()
137+
);
138+
$shares = \array_merge($shares, $openShares);
139+
}
116140

117141
return new Result($shares);
118142
}
119143

144+
/**
145+
* @NoCSRFRequired
146+
* @NoAdminRequired
147+
*
148+
* @return Result
149+
*/
150+
public function getAllShares() {
151+
return $this->getShares(true);
152+
}
153+
120154
/**
121155
* @NoCSRFRequired
122156
* @NoAdminRequired

apps/files_sharing/tests/Controller/RemoteOcsControllerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,17 @@ public function testGetShares() {
125125
$this->assertEquals(100, $result->getStatusCode());
126126
}
127127

128+
public function testGetAllShares() {
129+
$this->externalManager->expects($this->once())
130+
->method('getAcceptedShares')
131+
->willReturn([]);
132+
$this->externalManager->expects($this->once())
133+
->method('getOpenShares')
134+
->willReturn([]);
135+
$result = $this->controller->getAllShares();
136+
$this->assertEquals(100, $result->getStatusCode());
137+
}
138+
128139
public function getShareDataProvider() {
129140
return [
130141
[false, 404],

apps/files_sharing/tests/js/sharedfilelistSpec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('OCA.Sharing.FileList tests', function() {
145145

146146
expect(fakeServer.requests[1].url).toEqual(
147147
OC.linkToOCS('apps/files_sharing/api/v1') +
148-
'remote_shares?format=json&include_tags=true'
148+
'remote_shares/all?format=json&include_tags=true'
149149
);
150150

151151
fakeServer.requests[0].respond(
@@ -226,7 +226,7 @@ describe('OCA.Sharing.FileList tests', function() {
226226
);
227227
expect(fakeServer.requests[1].url).toEqual(
228228
OC.linkToOCS('apps/files_sharing/api/v1') +
229-
'remote_shares?format=json&include_tags=true'
229+
'remote_shares/all?format=json&include_tags=true'
230230
);
231231

232232
fakeServer.requests[0].respond(
@@ -312,7 +312,7 @@ describe('OCA.Sharing.FileList tests', function() {
312312
);
313313
expect(fakeServer.requests[1].url).toEqual(
314314
OC.linkToOCS('apps/files_sharing/api/v1') +
315-
'remote_shares?format=json&include_tags=true'
315+
'remote_shares/all?format=json&include_tags=true'
316316
);
317317

318318
fakeServer.requests[0].respond(

changelog/unreleased/37022

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Bugfix: Show pending remote shares at the Shared with you tab
2+
3+
Fixed missing pending remote shares in the file list at the Shared with you tab.
4+
5+
https://github.com/owncloud/core/pull/37022

0 commit comments

Comments
 (0)
X Tutup