Skip to content

Commit 59e1b48

Browse files
Merge pull request #2787 from nextcloud/backport/2772/stable31
[stable31] feat: Ease opening photos picker in album content view
2 parents 470ef15 + 5870c44 commit 59e1b48

File tree

26 files changed

+90
-173
lines changed

26 files changed

+90
-173
lines changed

cypress/e2e/albums.cy.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
addFilesToAlbumFromAlbum,
77
addFilesToAlbumFromAlbumFromHeader,
88
createAnAlbumFromAlbums,
9-
deleteAnAlbumFromAlbumContent,
109
goToAlbum,
1110
removeSelectionFromAlbum,
1211
} from './albumsUtils'
@@ -28,7 +27,7 @@ Cypress.on('uncaught:exception', (err) => {
2827
}
2928
})
3029

31-
describe('Manage albums', { testIsolation: true }, () => {
30+
describe('Manage albums', () => {
3231
let user = null
3332

3433
beforeEach(function () {

cypress/e2e/albumsUtils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export function addFilesToAlbumFromAlbum(albumName: string, itemsIndex: number[]
5151
}
5252

5353
export function addFilesToAlbumFromAlbumFromHeader(albumName: string, itemsIndex: number[]) {
54-
cy.contains('New').click()
5554
cy.contains('Add photos to this album').click()
5655
cy.get('.photos-picker__file-list').within(() => {
5756
selectMedia(itemsIndex)

js/photos-main.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-main.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-node_modules_vue-material-design-icons_ArrowLeft_vue-src_views_Timeline_vue.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-node_modules_vue-material-design-icons_ArrowLeft_vue-src_views_Timeline_vue.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-node_modules_vue-material-design-icons_FolderMultipleImage_vue-src_views_AlbumContent_vue.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-node_modules_vue-material-design-icons_FolderMultipleImage_vue-src_views_AlbumContent_vue.js.license

-3
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,6 @@ This file is generated from multiple sources. Included packages:
396396
- date-format-parse
397397
- version: 0.2.7
398398
- license: MIT
399-
- debounce
400-
- version: 1.2.1
401-
- license: MIT
402399
- decode-named-character-reference
403400
- version: 1.0.2
404401
- license: MIT

js/photos-node_modules_vue-material-design-icons_FolderMultipleImage_vue-src_views_AlbumContent_vue.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-public.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-public.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--bc3bd7.js

-2
This file was deleted.

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--bc3bd7.js.map

-1
This file was deleted.

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--bc3bd7.js.map.license

-1
This file was deleted.

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--fc22b7.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--bc3bd7.js.license js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--fc22b7.js.license

-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ SPDX-License-Identifier: MIT
22
SPDX-License-Identifier: GPL-3.0-or-later
33
SPDX-License-Identifier: Apache-2.0
44
SPDX-FileCopyrightText: omahlama
5-
SPDX-FileCopyrightText: debounce developers
65
SPDX-FileCopyrightText: Rob Cresswell <[email protected]>
76
SPDX-FileCopyrightText: Evan You
87
SPDX-FileCopyrightText: Christoph Wurst
@@ -19,9 +18,6 @@ This file is generated from multiple sources. Included packages:
1918
- blurhash
2019
- version: 2.0.5
2120
- license: MIT
22-
- debounce
23-
- version: 1.2.1
24-
- license: MIT
2521
- vue-loader
2622
- version: 15.11.1
2723
- license: MIT

js/photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--fc22b7.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
photos-vendors-node_modules_nextcloud_sharing_dist_index_js-node_modules_blurhash_dist_esm_index_js--fc22b7.js.license

lib/Sabre/Album/AlbumRoot.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use OCP\Files\InvalidDirectoryException;
1818
use OCP\Files\IRootFolder;
1919
use OCP\Files\NotFoundException;
20+
use Psr\Log\LoggerInterface;
2021
use Sabre\DAV\Exception\Conflict;
2122
use Sabre\DAV\Exception\Forbidden;
2223
use Sabre\DAV\Exception\NotFound;
@@ -30,7 +31,8 @@ public function __construct(
3031
protected AlbumWithFiles $album,
3132
protected IRootFolder $rootFolder,
3233
protected string $userId,
33-
protected UserConfigService $userConfigService
34+
protected UserConfigService $userConfigService,
35+
protected LoggerInterface $logger,
3436
) {
3537
}
3638

@@ -96,6 +98,7 @@ public function createFile($name, $data = null) {
9698
\header('OC-FileId: ' . $node->getId());
9799
return '"' . $node->getEtag() . '"';
98100
} catch (\Exception $e) {
101+
$this->logger->error('Could not create file', ['exception' => $e]);
99102
throw new Forbidden('Could not create file');
100103
}
101104
}

lib/Sabre/Album/AlbumsHome.php

+15-17
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,12 @@
1313
use OCA\Photos\Album\AlbumWithFiles;
1414
use OCA\Photos\Service\UserConfigService;
1515
use OCP\Files\IRootFolder;
16+
use Psr\Log\LoggerInterface;
1617
use Sabre\DAV\Exception\Forbidden;
1718
use Sabre\DAV\Exception\NotFound;
1819
use Sabre\DAV\ICollection;
1920

2021
class AlbumsHome implements ICollection {
21-
protected AlbumMapper $albumMapper;
22-
protected array $principalInfo;
23-
protected string $userId;
24-
protected IRootFolder $rootFolder;
25-
protected UserConfigService $userConfigService;
26-
2722
public const NAME = 'albums';
2823

2924
/**
@@ -32,17 +27,13 @@ class AlbumsHome implements ICollection {
3227
protected ?array $children = null;
3328

3429
public function __construct(
35-
array $principalInfo,
36-
AlbumMapper $albumMapper,
37-
string $userId,
38-
IRootFolder $rootFolder,
39-
UserConfigService $userConfigService
30+
protected array $principalInfo,
31+
protected AlbumMapper $albumMapper,
32+
protected string $userId,
33+
protected IRootFolder $rootFolder,
34+
protected UserConfigService $userConfigService,
35+
protected LoggerInterface $logger,
4036
) {
41-
$this->principalInfo = $principalInfo;
42-
$this->albumMapper = $albumMapper;
43-
$this->userId = $userId;
44-
$this->rootFolder = $rootFolder;
45-
$this->userConfigService = $userConfigService;
4637
}
4738

4839
/**
@@ -91,7 +82,14 @@ public function getChildren(): array {
9182
if ($this->children === null) {
9283
$albumInfos = $this->albumMapper->getForUser($this->userId);
9384
$this->children = array_map(function (AlbumInfo $albumInfo) {
94-
return new AlbumRoot($this->albumMapper, new AlbumWithFiles($albumInfo, $this->albumMapper), $this->rootFolder, $this->userId, $this->userConfigService);
85+
return new AlbumRoot(
86+
$this->albumMapper,
87+
new AlbumWithFiles($albumInfo, $this->albumMapper),
88+
$this->rootFolder,
89+
$this->userId,
90+
$this->userConfigService,
91+
$this->logger,
92+
);
9593
}, $albumInfos);
9694
}
9795

lib/Sabre/Album/SharedAlbumRoot.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,28 @@
1313
use OCA\Photos\Service\UserConfigService;
1414
use OCP\Files\IRootFolder;
1515
use OCP\IUserManager;
16+
use Psr\Log\LoggerInterface;
1617
use Sabre\DAV\Exception\Conflict;
1718
use Sabre\DAV\Exception\Forbidden;
1819

1920
class SharedAlbumRoot extends AlbumRoot {
20-
private IUserManager $userManager;
21-
2221
public function __construct(
2322
AlbumMapper $albumMapper,
2423
AlbumWithFiles $album,
2524
IRootFolder $rootFolder,
2625
string $userId,
2726
UserConfigService $userConfigService,
28-
IUserManager $userManager
27+
LoggerInterface $logger,
28+
private IUserManager $userManager,
2929
) {
3030
parent::__construct(
3131
$albumMapper,
3232
$album,
3333
$rootFolder,
3434
$userId,
3535
$userConfigService,
36+
$logger,
3637
);
37-
38-
$this->userManager = $userManager;
3938
}
4039

4140
/**

lib/Sabre/Album/SharedAlbumsHome.php

+17-11
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@
1414
use OCP\Files\IRootFolder;
1515
use OCP\IGroupManager;
1616
use OCP\IUserManager;
17+
use Psr\Log\LoggerInterface;
1718
use Sabre\DAV\Exception\Forbidden;
1819

1920
class SharedAlbumsHome extends AlbumsHome {
20-
private IUserManager $userManager;
21-
private IGroupManager $groupManager;
22-
2321
public const NAME = 'sharedalbums';
2422

2523
public function __construct(
2624
array $principalInfo,
2725
AlbumMapper $albumMapper,
2826
string $userId,
2927
IRootFolder $rootFolder,
30-
IUserManager $userManager,
31-
IGroupManager $groupManager,
32-
UserConfigService $userConfigService
28+
private IUserManager $userManager,
29+
private IGroupManager $groupManager,
30+
UserConfigService $userConfigService,
31+
LoggerInterface $logger,
32+
3333
) {
3434
parent::__construct(
3535
$principalInfo,
3636
$albumMapper,
3737
$userId,
3838
$rootFolder,
39-
$userConfigService
39+
$userConfigService,
40+
$logger,
4041
);
41-
42-
$this->userManager = $userManager;
43-
$this->groupManager = $groupManager;
4442
}
4543

4644
/**
@@ -66,7 +64,15 @@ public function getChildren(): array {
6664
}
6765

6866
$this->children = array_map(function (AlbumWithFiles $album) {
69-
return new SharedAlbumRoot($this->albumMapper, $album, $this->rootFolder, $this->userId, $this->userConfigService, $this->userManager);
67+
return new SharedAlbumRoot(
68+
$this->albumMapper,
69+
$album,
70+
$this->rootFolder,
71+
$this->userId,
72+
$this->userConfigService,
73+
$this->logger,
74+
$this->userManager,
75+
);
7076
}, $albums);
7177
}
7278

lib/Sabre/PhotosHome.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use OCP\Files\IRootFolder;
1919
use OCP\IGroupManager;
2020
use OCP\IUserManager;
21+
use Psr\Log\LoggerInterface;
2122
use Sabre\DAV\Exception\Forbidden;
2223
use Sabre\DAV\Exception\NotFound;
2324
use Sabre\DAV\ICollection;
@@ -33,6 +34,7 @@ public function __construct(
3334
private IUserManager $userManager,
3435
private IGroupManager $groupManager,
3536
private UserConfigService $userConfigService,
37+
private LoggerInterface $logger,
3638
) {
3739
}
3840

@@ -69,9 +71,9 @@ public function createDirectory($name) {
6971
public function getChild($name) {
7072
switch ($name) {
7173
case AlbumsHome::NAME:
72-
return new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService);
74+
return new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService, $this->logger);
7375
case SharedAlbumsHome::NAME:
74-
return new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService);
76+
return new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger);
7577
case PlacesHome::NAME:
7678
return new PlacesHome($this->userId, $this->rootFolder, $this->reverseGeoCoderService, $this->placeMapper);
7779
}
@@ -84,8 +86,8 @@ public function getChild($name) {
8486
*/
8587
public function getChildren(): array {
8688
return [
87-
new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService),
88-
new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService),
89+
new AlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userConfigService, $this->logger),
90+
new SharedAlbumsHome($this->principalInfo, $this->albumMapper, $this->userId, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger),
8991
new PlacesHome($this->userId, $this->rootFolder, $this->reverseGeoCoderService, $this->placeMapper),
9092
];
9193
}

lib/Sabre/PublicRootCollection.php

+15-17
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,24 @@
1414
use OCP\Files\IRootFolder;
1515
use OCP\IRequest;
1616
use OCP\Security\Bruteforce\IThrottler;
17+
use Psr\Log\LoggerInterface;
1718
use Sabre\DAV\Exception\NotFound;
1819
use Sabre\DAVACL\AbstractPrincipalCollection;
1920
use Sabre\DAVACL\PrincipalBackend;
2021

2122
class PublicRootCollection extends AbstractPrincipalCollection {
2223
private const BRUTEFORCE_ACTION = 'publicphotos_webdav_auth';
23-
private AlbumMapper $albumMapper;
24-
private IRootFolder $rootFolder;
25-
private UserConfigService $userConfigService;
26-
private IRequest $request;
27-
private IThrottler $throttler;
2824

2925
public function __construct(
30-
AlbumMapper $albumMapper,
31-
IRootFolder $rootFolder,
26+
private AlbumMapper $albumMapper,
27+
private IRootFolder $rootFolder,
3228
PrincipalBackend\BackendInterface $principalBackend,
33-
UserConfigService $userConfigService,
34-
IRequest $request,
35-
IThrottler $throttler
29+
private UserConfigService $userConfigService,
30+
private IRequest $request,
31+
private IThrottler $throttler,
32+
private LoggerInterface $logger,
3633
) {
3734
parent::__construct($principalBackend, 'principals/token');
38-
39-
$this->albumMapper = $albumMapper;
40-
$this->rootFolder = $rootFolder;
41-
$this->userConfigService = $userConfigService;
42-
$this->request = $request;
43-
$this->throttler = $throttler;
4435
}
4536

4637
public function getName(): string {
@@ -79,6 +70,13 @@ public function getChild($name) {
7970
throw new NotFound('Unable to find public album');
8071
}
8172

82-
return new PublicAlbumRoot($this->albumMapper, $albums[0], $this->rootFolder, $albums[0]->getAlbum()->getUserId(), $this->userConfigService);
73+
return new PublicAlbumRoot(
74+
$this->albumMapper,
75+
$albums[0],
76+
$this->rootFolder,
77+
$albums[0]->getAlbum()->getUserId(),
78+
$this->userConfigService,
79+
$this->logger,
80+
);
8381
}
8482
}

lib/Sabre/RootCollection.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use OCP\IGroupManager;
1717
use OCP\IUserManager;
1818
use OCP\IUserSession;
19+
use Psr\Log\LoggerInterface;
1920
use Sabre\DAVACL\AbstractPrincipalCollection;
2021
use Sabre\DAVACL\PrincipalBackend;
2122

@@ -30,6 +31,7 @@ public function __construct(
3031
private IUserManager $userManager,
3132
private IGroupManager $groupManager,
3233
private UserConfigService $userConfigService,
34+
private LoggerInterface $logger,
3335
) {
3436
parent::__construct($principalBackend, 'principals/users');
3537
}
@@ -49,7 +51,7 @@ public function getChildForPrincipal(array $principalInfo): PhotosHome {
4951
if (is_null($user) || $name !== $user->getUID()) {
5052
throw new \Sabre\DAV\Exception\Forbidden();
5153
}
52-
return new PhotosHome($principalInfo, $this->albumMapper, $this->placeMapper, $this->reverseGeoCoderService, $name, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService);
54+
return new PhotosHome($principalInfo, $this->albumMapper, $this->placeMapper, $this->reverseGeoCoderService, $name, $this->rootFolder, $this->userManager, $this->groupManager, $this->userConfigService, $this->logger);
5355
}
5456

5557
public function getName(): string {

0 commit comments

Comments
 (0)