From cd60e5b63406d4f23a8c04491cbdc57b47b972cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 25 May 2018 14:56:54 +0200 Subject: [PATCH] Move logic to app management mixin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/private/App/AppStore/Manager.php | 7 +- settings/Controller/AppSettingsController.php | 10 ++- settings/src/components/appDetails.vue | 17 +++- settings/src/components/appList.vue | 52 ------------ settings/src/components/appList/appItem.vue | 76 +++-------------- settings/src/components/appManagement.vue | 81 +++++++++++++++++++ settings/src/views/Apps.vue | 2 +- 7 files changed, 121 insertions(+), 124 deletions(-) create mode 100644 settings/src/components/appManagement.vue diff --git a/lib/private/App/AppStore/Manager.php b/lib/private/App/AppStore/Manager.php index 1c7f09a817e..4498918da70 100644 --- a/lib/private/App/AppStore/Manager.php +++ b/lib/private/App/AppStore/Manager.php @@ -29,10 +29,13 @@ use OC\App\AppStore\Fetcher\AppFetcher; class Manager { public function __construct(AppFetcher $appFetcher) { - $this->apps = $appFetcher->get(); + $apps = $appFetcher->get(); + foreach ($apps as $app) { + $this->apps[$app['id']] = $app; + } } public function getApp(string $appId) { - return $this->apps; + return $this->apps[$appId]; } } \ No newline at end of file diff --git a/settings/Controller/AppSettingsController.php b/settings/Controller/AppSettingsController.php index ac6e5d1850d..a44a252a747 100644 --- a/settings/Controller/AppSettingsController.php +++ b/settings/Controller/AppSettingsController.php @@ -334,12 +334,12 @@ class AppSettingsController extends Controller { */ public function listApps($category = '') { $appClass = new \OC_App(); + $manager = \OC::$server->query(\OC\App\AppStore\Manager::class); switch ($category) { // installed apps case 'installed': $apps = $appClass->listAllApps(); - foreach($apps as $key => $app) { $newVersion = $this->installer->isUpdateAvailable($app['id']); $apps[$key]['update'] = $newVersion; @@ -481,6 +481,14 @@ class AppSettingsController extends Controller { return $app; }, $apps); + // Add app store dump for app to data + $apps = array_map(function($appData) use ($manager) { + $appStoreData = $manager->getApp($appData['id']); + $appData['appstoreData'] = $appStoreData; + $appData['preview'] = isset($appStoreData['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/'.base64_encode($appStoreData['screenshots'][0]['url']) : ''; + return $appData; + }, $apps); + return new JSONResponse(['apps' => $apps, 'status' => 'success']); } diff --git a/settings/src/components/appDetails.vue b/settings/src/components/appDetails.vue index 5467b1ffb10..70078d87c64 100644 --- a/settings/src/components/appDetails.vue +++ b/settings/src/components/appDetails.vue @@ -25,7 +25,7 @@ Close

{{ app.name }}

- +
{{ author }} {{ licence }} @@ -38,6 +38,19 @@
+
+
+ + + + + {{t('settings', 'No results')}} + +
+

{{ t('settings', 'Visit website') }} ↗ {{ t('settings', 'Report a bug') }} ↗ @@ -65,7 +78,9 @@ diff --git a/settings/src/components/appList/appItem.vue b/settings/src/components/appList/appItem.vue index 8797fd88bd9..b2fb86f955a 100644 --- a/settings/src/components/appList/appItem.vue +++ b/settings/src/components/appList/appItem.vue @@ -26,8 +26,8 @@

- - + +
@@ -70,9 +70,11 @@ diff --git a/settings/src/components/appManagement.vue b/settings/src/components/appManagement.vue new file mode 100644 index 00000000000..24f56040900 --- /dev/null +++ b/settings/src/components/appManagement.vue @@ -0,0 +1,81 @@ + + + diff --git a/settings/src/views/Apps.vue b/settings/src/views/Apps.vue index b24123e4aff..d59a62ee22c 100644 --- a/settings/src/views/Apps.vue +++ b/settings/src/views/Apps.vue @@ -24,7 +24,7 @@
-
+