From 18528a554e61cf8863d027bb277b560f16347e3d Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 27 Dec 2025 13:58:56 +0100 Subject: [PATCH 1/7] build: harden module name generation Signed-off-by: Ferdinand Thiessen --- build/frontend/vite.config.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/build/frontend/vite.config.ts b/build/frontend/vite.config.ts index 198081027a1ed..dd48577bca800 100644 --- a/build/frontend/vite.config.ts +++ b/build/frontend/vite.config.ts @@ -74,12 +74,10 @@ export default createAppConfig(Object.fromEntries(viteModuleEntries), { entryFileNames: '[name].mjs', chunkFileNames: '[name]-[hash].chunk.mjs', assetFileNames({ originalFileNames }) { - const [name] = originalFileNames - if (name) { - const [, appId] = name.match(/apps\/([^/]+)\//)! - return `${appId}-[name]-[hash][extname]` - } - return '[name]-[hash][extname]' + const apps = originalFileNames.map((name) => name.match(/apps\/([^/]+)\//)?.[1]) + .filter(Boolean) + const appId = apps.length === 1 ? apps[0] : 'common' + return `${appId}-[name]-[hash][extname]` }, experimentalMinChunkSize: 100 * 1024, /* // with rolldown-vite: From 474a138390a0689f50a6a226f3e8eeecd01a9948 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 12 Dec 2025 00:39:39 +0100 Subject: [PATCH 2/7] refactor: split appstore from settings app Signed-off-by: Ferdinand Thiessen --- .gitignore | 9 +- apps/appstore/appinfo/info.xml | 22 + apps/appstore/appinfo/routes.php | 27 + apps/appstore/composer/autoload.php | 22 + apps/appstore/composer/composer.json | 13 + apps/appstore/composer/composer.lock | 18 + .../composer/composer/ClassLoader.php | 579 ++++++++++++++ .../composer/composer/InstalledVersions.php | 396 ++++++++++ apps/appstore/composer/composer/LICENSE | 21 + .../composer/composer/autoload_classmap.php | 14 + .../composer/composer/autoload_namespaces.php | 9 + .../composer/composer/autoload_psr4.php | 10 + .../composer/composer/autoload_real.php | 37 + .../composer/composer/autoload_static.php | 40 + .../appstore/composer/composer/installed.json | 5 + apps/appstore/composer/composer/installed.php | 23 + apps/{settings => appstore}/img/apps.svg | 0 apps/appstore/l10n/.gitkeep | 0 apps/appstore/lib/AppInfo/Application.php | 30 + .../lib/Controller/AppSettingsController.php | 5 +- .../lib/Search/AppSearch.php | 2 +- apps/appstore/openapi-administration.json | 104 +++ .../openapi-administration.json.license | 2 + apps/appstore/openapi-full.json | 709 ++++++++++++++++++ apps/appstore/openapi-full.json.license | 2 + apps/appstore/openapi.json | 632 ++++++++++++++++ apps/appstore/openapi.json.license | 2 + apps/{settings => appstore}/src/app-types.ts | 0 apps/{settings => appstore}/src/apps.js | 0 .../AppAPI/DaemonSelectionDialog.vue | 0 .../AppAPI/DaemonSelectionEntry.vue | 0 .../components/AppAPI/DaemonSelectionList.vue | 0 .../src/components/AppList.vue | 2 +- .../src/components/AppList/AppDaemonBadge.vue | 0 .../src/components/AppList/AppItem.vue | 0 .../src/components/AppList/AppLevelBadge.vue | 0 .../src/components/AppList/AppScore.vue | 0 .../components/AppStoreDiscover/AppLink.vue | 0 .../AppStoreDiscoverSection.vue | 2 +- .../components/AppStoreDiscover/AppType.vue | 0 .../AppStoreDiscover/CarouselType.vue | 0 .../components/AppStoreDiscover/PostType.vue | 0 .../AppStoreDiscover/ShowcaseType.vue | 0 .../src/components/AppStoreDiscover/common.ts | 0 .../AppStoreSidebar/AppDeployDaemonTab.vue | 0 .../AppStoreSidebar/AppDeployOptionsModal.vue | 0 .../AppStoreSidebar/AppDescriptionTab.vue | 0 .../AppStoreSidebar/AppDetailsTab.vue | 0 .../AppStoreSidebar/AppReleasesTab.vue | 0 apps/appstore/src/components/Markdown.spec.ts | 58 ++ apps/appstore/src/components/Markdown.vue | 158 ++++ .../src/composables/useAppIcon.ts | 2 +- .../src/composables/useGetLocalizedValue.ts | 0 .../src/constants/AppDiscoverTypes.ts | 117 +++ apps/appstore/src/constants/AppsConstants.js | 18 + .../src/constants/AppstoreCategoryIcons.ts | 63 ++ apps/appstore/src/main.ts | 39 + .../src/mixins/AppManagement.js | 0 apps/appstore/src/router/index.ts | 22 + apps/appstore/src/router/routes.ts | 46 ++ .../src/service/rebuild-navigation.ts | 23 + apps/appstore/src/settings.ts | 11 + apps/appstore/src/store/api.js | 67 ++ .../src/store/app-api-store.ts | 2 +- .../src/store/apps-store.ts | 2 +- apps/{settings => appstore}/src/store/apps.js | 2 +- apps/appstore/src/store/index.js | 39 + .../src/utils/appDiscoverParser.spec.ts | 0 .../src/utils/appDiscoverParser.ts | 0 apps/appstore/src/utils/handlers.ts | 33 + apps/appstore/src/utils/logger.ts | 11 + apps/appstore/src/utils/sorting.ts | 14 + apps/appstore/src/utils/userUtils.ts | 28 + apps/appstore/src/utils/validate.js | 79 ++ apps/appstore/src/views/App.vue | 16 + .../src/views/AppStore.vue | 0 .../src/views/AppStoreNavigation.vue | 0 .../src/views/AppStoreSidebar.vue | 0 apps/appstore/templates/empty.php | 6 + .../tests/AppInfo/ApplicationTest.php | 63 ++ .../Controller/AppSettingsControllerTest.php | 222 ++++++ apps/settings/appinfo/routes.php | 16 - .../lib/Controller/UsersController.php | 2 +- .../src/components/SvgFilterMixin.vue | 25 - ...management.ts => main-users-management.ts} | 0 apps/settings/src/router/routes.ts | 37 +- .../src/service/rebuild-navigation.js | 19 - apps/settings/src/store/index.js | 2 - apps/settings/templates/settings/frame.php | 2 +- build/frontend-legacy/apps/appstore | 1 + build/frontend-legacy/webpack.common.cjs | 1 - build/frontend-legacy/webpack.modules.cjs | 3 +- build/frontend/apps/appstore | 1 + build/frontend/vite.config.ts | 4 + core/shipped.json | 3 + .../AppFramework/Routing/RouteParser.php | 1 + lib/private/NavigationManager.php | 4 +- lib/private/Route/Router.php | 2 + package-lock.json | 68 +- package.json | 1 + 100 files changed, 3927 insertions(+), 143 deletions(-) create mode 100644 apps/appstore/appinfo/info.xml create mode 100644 apps/appstore/appinfo/routes.php create mode 100644 apps/appstore/composer/autoload.php create mode 100644 apps/appstore/composer/composer.json create mode 100644 apps/appstore/composer/composer.lock create mode 100644 apps/appstore/composer/composer/ClassLoader.php create mode 100644 apps/appstore/composer/composer/InstalledVersions.php create mode 100644 apps/appstore/composer/composer/LICENSE create mode 100644 apps/appstore/composer/composer/autoload_classmap.php create mode 100644 apps/appstore/composer/composer/autoload_namespaces.php create mode 100644 apps/appstore/composer/composer/autoload_psr4.php create mode 100644 apps/appstore/composer/composer/autoload_real.php create mode 100644 apps/appstore/composer/composer/autoload_static.php create mode 100644 apps/appstore/composer/composer/installed.json create mode 100644 apps/appstore/composer/composer/installed.php rename apps/{settings => appstore}/img/apps.svg (100%) create mode 100644 apps/appstore/l10n/.gitkeep create mode 100644 apps/appstore/lib/AppInfo/Application.php rename apps/{settings => appstore}/lib/Controller/AppSettingsController.php (99%) rename apps/{settings => appstore}/lib/Search/AppSearch.php (98%) create mode 100644 apps/appstore/openapi-administration.json create mode 100644 apps/appstore/openapi-administration.json.license create mode 100644 apps/appstore/openapi-full.json create mode 100644 apps/appstore/openapi-full.json.license create mode 100644 apps/appstore/openapi.json create mode 100644 apps/appstore/openapi.json.license rename apps/{settings => appstore}/src/app-types.ts (100%) rename apps/{settings => appstore}/src/apps.js (100%) rename apps/{settings => appstore}/src/components/AppAPI/DaemonSelectionDialog.vue (100%) rename apps/{settings => appstore}/src/components/AppAPI/DaemonSelectionEntry.vue (100%) rename apps/{settings => appstore}/src/components/AppAPI/DaemonSelectionList.vue (100%) rename apps/{settings => appstore}/src/components/AppList.vue (99%) rename apps/{settings => appstore}/src/components/AppList/AppDaemonBadge.vue (100%) rename apps/{settings => appstore}/src/components/AppList/AppItem.vue (100%) rename apps/{settings => appstore}/src/components/AppList/AppLevelBadge.vue (100%) rename apps/{settings => appstore}/src/components/AppList/AppScore.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/AppLink.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue (98%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/AppType.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/CarouselType.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/PostType.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/ShowcaseType.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreDiscover/common.ts (100%) rename apps/{settings => appstore}/src/components/AppStoreSidebar/AppDeployDaemonTab.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreSidebar/AppDeployOptionsModal.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreSidebar/AppDescriptionTab.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreSidebar/AppDetailsTab.vue (100%) rename apps/{settings => appstore}/src/components/AppStoreSidebar/AppReleasesTab.vue (100%) create mode 100644 apps/appstore/src/components/Markdown.spec.ts create mode 100644 apps/appstore/src/components/Markdown.vue rename apps/{settings => appstore}/src/composables/useAppIcon.ts (97%) rename apps/{settings => appstore}/src/composables/useGetLocalizedValue.ts (100%) create mode 100644 apps/appstore/src/constants/AppDiscoverTypes.ts create mode 100644 apps/appstore/src/constants/AppsConstants.js create mode 100644 apps/appstore/src/constants/AppstoreCategoryIcons.ts create mode 100644 apps/appstore/src/main.ts rename apps/{settings => appstore}/src/mixins/AppManagement.js (100%) create mode 100644 apps/appstore/src/router/index.ts create mode 100644 apps/appstore/src/router/routes.ts create mode 100644 apps/appstore/src/service/rebuild-navigation.ts create mode 100644 apps/appstore/src/settings.ts create mode 100644 apps/appstore/src/store/api.js rename apps/{settings => appstore}/src/store/app-api-store.ts (99%) rename apps/{settings => appstore}/src/store/apps-store.ts (98%) rename apps/{settings => appstore}/src/store/apps.js (99%) create mode 100644 apps/appstore/src/store/index.js rename apps/{settings => appstore}/src/utils/appDiscoverParser.spec.ts (100%) rename apps/{settings => appstore}/src/utils/appDiscoverParser.ts (100%) create mode 100644 apps/appstore/src/utils/handlers.ts create mode 100644 apps/appstore/src/utils/logger.ts create mode 100644 apps/appstore/src/utils/sorting.ts create mode 100644 apps/appstore/src/utils/userUtils.ts create mode 100644 apps/appstore/src/utils/validate.js create mode 100644 apps/appstore/src/views/App.vue rename apps/{settings => appstore}/src/views/AppStore.vue (100%) rename apps/{settings => appstore}/src/views/AppStoreNavigation.vue (100%) rename apps/{settings => appstore}/src/views/AppStoreSidebar.vue (100%) create mode 100644 apps/appstore/templates/empty.php create mode 100644 apps/appstore/tests/AppInfo/ApplicationTest.php create mode 100644 apps/appstore/tests/Controller/AppSettingsControllerTest.php delete mode 100644 apps/settings/src/components/SvgFilterMixin.vue rename apps/settings/src/{main-apps-users-management.ts => main-users-management.ts} (100%) delete mode 100644 apps/settings/src/service/rebuild-navigation.js create mode 120000 build/frontend-legacy/apps/appstore create mode 120000 build/frontend/apps/appstore diff --git a/.gitignore b/.gitignore index 06cb1ac1eccfb..603d63ad54fcc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,16 +17,17 @@ node_modules/ # ignore all apps except core ones /apps*/* +!/apps/admin_audit +!/apps/appstore !/apps/cloud_federation_api !/apps/comments !/apps/contactsinteraction !/apps/dashboard !/apps/dav -!/apps/files +!/apps/encryption !/apps/federation !/apps/federatedfilesharing -!/apps/sharebymail -!/apps/encryption +!/apps/files !/apps/files_external !/apps/files_reminders !/apps/files_sharing @@ -38,9 +39,9 @@ node_modules/ !/apps/profile !/apps/provisioning_api !/apps/settings +!/apps/sharebymail !/apps/systemtags !/apps/testing -!/apps/admin_audit !/apps/updatenotification !/apps/theming !/apps/twofactor_backupcodes diff --git a/apps/appstore/appinfo/info.xml b/apps/appstore/appinfo/info.xml new file mode 100644 index 0000000000000..9b6c801bab30b --- /dev/null +++ b/apps/appstore/appinfo/info.xml @@ -0,0 +1,22 @@ + + + + settings + Nextcloud Appstore + Nextcloud Appstore + Nextcloud Appstore + 1.0.0 + agpl + Nextcloud + Appstore + + customization + https://github.com/nextcloud/server/issues + + + + diff --git a/apps/appstore/appinfo/routes.php b/apps/appstore/appinfo/routes.php new file mode 100644 index 0000000000000..b1dfba13ba70f --- /dev/null +++ b/apps/appstore/appinfo/routes.php @@ -0,0 +1,27 @@ + [ + ['name' => 'AppSettings#getAppDiscoverJSON', 'url' => '/settings/api/apps/discover', 'verb' => 'GET', 'root' => ''], + ['name' => 'AppSettings#getAppDiscoverMedia', 'url' => '/settings/api/apps/media', 'verb' => 'GET', 'root' => ''], + ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST' , 'root' => ''], + ['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST' , 'root' => ''], + ['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST' , 'root' => ''], + ['name' => 'AppSettings#updateApp', 'url' => '/settings/apps/update/{appId}', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#uninstallApp', 'url' => '/settings/apps/uninstall/{appId}', 'verb' => 'GET' , 'root' => ''], + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => ''] , 'root' => ''], + ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => ''] , 'root' => ''], + ['name' => 'AppSettings#force', 'url' => '/settings/apps/force', 'verb' => 'POST' , 'root' => ''], + ], +]; diff --git a/apps/appstore/composer/autoload.php b/apps/appstore/composer/autoload.php new file mode 100644 index 0000000000000..6c9b0406c7749 --- /dev/null +++ b/apps/appstore/composer/autoload.php @@ -0,0 +1,22 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/apps/appstore/composer/composer/InstalledVersions.php b/apps/appstore/composer/composer/InstalledVersions.php new file mode 100644 index 0000000000000..2052022fd8e1e --- /dev/null +++ b/apps/appstore/composer/composer/InstalledVersions.php @@ -0,0 +1,396 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool + */ + private static $installedIsLocalDir; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + $copiedLocalDir = false; + + if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; + } + } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array() && !$copiedLocalDir) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/apps/appstore/composer/composer/LICENSE b/apps/appstore/composer/composer/LICENSE new file mode 100644 index 0000000000000..f27399a042d95 --- /dev/null +++ b/apps/appstore/composer/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + diff --git a/apps/appstore/composer/composer/autoload_classmap.php b/apps/appstore/composer/composer/autoload_classmap.php new file mode 100644 index 0000000000000..8dab41160b3db --- /dev/null +++ b/apps/appstore/composer/composer/autoload_classmap.php @@ -0,0 +1,14 @@ + $vendorDir . '/composer/InstalledVersions.php', + 'OCA\\Appstore\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', + 'OCA\\Appstore\\Controller\\AppSettingsController' => $baseDir . '/../lib/Controller/AppSettingsController.php', + 'OCA\\Appstore\\Search\\AppSearch' => $baseDir . '/../lib/Search/AppSearch.php', + 'OCA\\Settings\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php', +); diff --git a/apps/appstore/composer/composer/autoload_namespaces.php b/apps/appstore/composer/composer/autoload_namespaces.php new file mode 100644 index 0000000000000..3f5c929625125 --- /dev/null +++ b/apps/appstore/composer/composer/autoload_namespaces.php @@ -0,0 +1,9 @@ + array($baseDir . '/../lib'), +); diff --git a/apps/appstore/composer/composer/autoload_real.php b/apps/appstore/composer/composer/autoload_real.php new file mode 100644 index 0000000000000..7d3ecc79600ce --- /dev/null +++ b/apps/appstore/composer/composer/autoload_real.php @@ -0,0 +1,37 @@ +setClassMapAuthoritative(true); + $loader->register(true); + + return $loader; + } +} diff --git a/apps/appstore/composer/composer/autoload_static.php b/apps/appstore/composer/composer/autoload_static.php new file mode 100644 index 0000000000000..78e9f60837890 --- /dev/null +++ b/apps/appstore/composer/composer/autoload_static.php @@ -0,0 +1,40 @@ + + array ( + 'OCA\\Appstore\\' => 13, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'OCA\\Appstore\\' => + array ( + 0 => __DIR__ . '/..' . '/../lib', + ), + ); + + public static $classMap = array ( + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'OCA\\Appstore\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', + 'OCA\\Appstore\\Controller\\AppSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AppSettingsController.php', + 'OCA\\Appstore\\Search\\AppSearch' => __DIR__ . '/..' . '/../lib/Search/AppSearch.php', + 'OCA\\Settings\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitAppstore::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitAppstore::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitAppstore::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/apps/appstore/composer/composer/installed.json b/apps/appstore/composer/composer/installed.json new file mode 100644 index 0000000000000..f20a6c47c6d4f --- /dev/null +++ b/apps/appstore/composer/composer/installed.json @@ -0,0 +1,5 @@ +{ + "packages": [], + "dev": false, + "dev-package-names": [] +} diff --git a/apps/appstore/composer/composer/installed.php b/apps/appstore/composer/composer/installed.php new file mode 100644 index 0000000000000..1f633b95afd69 --- /dev/null +++ b/apps/appstore/composer/composer/installed.php @@ -0,0 +1,23 @@ + array( + 'name' => '__root__', + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '3efb1d80e9851e0c33311a7722f523e020654691', + 'type' => 'library', + 'install_path' => __DIR__ . '/../', + 'aliases' => array(), + 'dev' => false, + ), + 'versions' => array( + '__root__' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => '3efb1d80e9851e0c33311a7722f523e020654691', + 'type' => 'library', + 'install_path' => __DIR__ . '/../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/apps/settings/img/apps.svg b/apps/appstore/img/apps.svg similarity index 100% rename from apps/settings/img/apps.svg rename to apps/appstore/img/apps.svg diff --git a/apps/appstore/l10n/.gitkeep b/apps/appstore/l10n/.gitkeep new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/apps/appstore/lib/AppInfo/Application.php b/apps/appstore/lib/AppInfo/Application.php new file mode 100644 index 0000000000000..e25bbd9bc5735 --- /dev/null +++ b/apps/appstore/lib/AppInfo/Application.php @@ -0,0 +1,30 @@ + $this->l10n->t('Settings')]); $templateResponse->setContentSecurityPolicy($policy); - Util::addStyle('settings', 'settings'); - Util::addScript('settings', 'vue-settings-apps-users-management'); + Util::addScript('appstore', 'main'); return $templateResponse; } diff --git a/apps/settings/lib/Search/AppSearch.php b/apps/appstore/lib/Search/AppSearch.php similarity index 98% rename from apps/settings/lib/Search/AppSearch.php rename to apps/appstore/lib/Search/AppSearch.php index 19c2bce5451a7..5e6c3fe78992b 100644 --- a/apps/settings/lib/Search/AppSearch.php +++ b/apps/appstore/lib/Search/AppSearch.php @@ -6,7 +6,7 @@ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -namespace OCA\Settings\Search; +namespace OCA\Appstore\Search; use OCP\IL10N; use OCP\INavigationManager; diff --git a/apps/appstore/openapi-administration.json b/apps/appstore/openapi-administration.json new file mode 100644 index 0000000000000..6e099465cb9e8 --- /dev/null +++ b/apps/appstore/openapi-administration.json @@ -0,0 +1,104 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "settings-administration", + "version": "0.0.1", + "description": "Nextcloud settings", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": {} + }, + "paths": { + "/index.php/settings/admin/log/download": { + "get": { + "operationId": "log_settings-download", + "summary": "download logfile", + "description": "This endpoint requires admin access", + "tags": [ + "log_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "Logfile returned", + "headers": { + "Content-Disposition": { + "schema": { + "type": "string", + "enum": [ + "attachment; filename=\"nextcloud.log\"" + ] + } + } + }, + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "403": { + "description": "Logged in account must be an admin", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "tags": [] +} diff --git a/apps/appstore/openapi-administration.json.license b/apps/appstore/openapi-administration.json.license new file mode 100644 index 0000000000000..83559daa9dcb7 --- /dev/null +++ b/apps/appstore/openapi-administration.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +SPDX-License-Identifier: AGPL-3.0-or-later \ No newline at end of file diff --git a/apps/appstore/openapi-full.json b/apps/appstore/openapi-full.json new file mode 100644 index 0000000000000..33ffe61ea04aa --- /dev/null +++ b/apps/appstore/openapi-full.json @@ -0,0 +1,709 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "settings-full", + "version": "0.0.1", + "description": "Nextcloud settings", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": { + "DeclarativeForm": { + "type": "object", + "required": [ + "id", + "priority", + "section_type", + "section_id", + "storage_type", + "title", + "app", + "fields" + ], + "properties": { + "id": { + "type": "string" + }, + "priority": { + "type": "integer", + "format": "int64" + }, + "section_type": { + "type": "string", + "enum": [ + "admin", + "personal" + ] + }, + "section_id": { + "type": "string" + }, + "storage_type": { + "type": "string", + "enum": [ + "internal", + "external" + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "doc_url": { + "type": "string" + }, + "app": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DeclarativeFormField" + } + } + } + }, + "DeclarativeFormField": { + "type": "object", + "required": [ + "id", + "title", + "type", + "default", + "value" + ], + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "text", + "password", + "email", + "tel", + "url", + "number", + "checkbox", + "multi-checkbox", + "radio", + "select", + "multi-select" + ] + }, + "placeholder": { + "type": "string" + }, + "label": { + "type": "string" + }, + "default": { + "type": "object" + }, + "options": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "object" + } + } + } + ] + } + }, + "value": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer", + "format": "int64" + }, + { + "type": "number", + "format": "double" + }, + { + "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "sensitive": { + "type": "boolean" + } + } + }, + "OCSMeta": { + "type": "object", + "required": [ + "status", + "statuscode" + ], + "properties": { + "status": { + "type": "string" + }, + "statuscode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "totalitems": { + "type": "string" + }, + "itemsperpage": { + "type": "string" + } + } + } + } + }, + "paths": { + "/index.php/settings/admin/log/download": { + "get": { + "operationId": "log_settings-download", + "summary": "download logfile", + "description": "This endpoint requires admin access", + "tags": [ + "log_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "responses": { + "200": { + "description": "Logfile returned", + "headers": { + "Content-Disposition": { + "schema": { + "type": "string", + "enum": [ + "attachment; filename=\"nextcloud.log\"" + ] + } + } + }, + "content": { + "application/octet-stream": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + }, + "403": { + "description": "Logged in account must be an admin", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "message" + ], + "properties": { + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/settings/api/declarative/value": { + "post": { + "operationId": "declarative_settings-set-value", + "summary": "Sets a declarative settings value", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "app", + "formId", + "fieldId", + "value" + ], + "properties": { + "app": { + "type": "string", + "description": "ID of the app" + }, + "formId": { + "type": "string", + "description": "ID of the form" + }, + "fieldId": { + "type": "string", + "description": "ID of the field" + }, + "value": { + "type": "object", + "description": "Value to be saved" + } + } + } + } + } + }, + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Value set successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "nullable": true + } + } + } + } + } + } + } + }, + "500": { + "description": "Not logged in or not an admin user", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid arguments to save value", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/settings/api/declarative/value-sensitive": { + "post": { + "operationId": "declarative_settings-set-sensitive-value", + "summary": "Sets a declarative settings value. Password confirmation is required for sensitive values.", + "description": "This endpoint requires password confirmation", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "app", + "formId", + "fieldId", + "value" + ], + "properties": { + "app": { + "type": "string", + "description": "ID of the app" + }, + "formId": { + "type": "string", + "description": "ID of the form" + }, + "fieldId": { + "type": "string", + "description": "ID of the field" + }, + "value": { + "type": "object", + "description": "Value to be saved" + } + } + } + } + } + }, + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Value set successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "nullable": true + } + } + } + } + } + } + } + }, + "500": { + "description": "Not logged in or not an admin user", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid arguments to save value", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/settings/api/declarative/forms": { + "get": { + "operationId": "declarative_settings-get-forms", + "summary": "Gets all declarative forms with the values prefilled.", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Forms returned", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DeclarativeForm" + } + } + } + } + } + } + } + } + }, + "500": { + "description": "", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + } + }, + "tags": [] +} diff --git a/apps/appstore/openapi-full.json.license b/apps/appstore/openapi-full.json.license new file mode 100644 index 0000000000000..83559daa9dcb7 --- /dev/null +++ b/apps/appstore/openapi-full.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +SPDX-License-Identifier: AGPL-3.0-or-later \ No newline at end of file diff --git a/apps/appstore/openapi.json b/apps/appstore/openapi.json new file mode 100644 index 0000000000000..c23971fbe269b --- /dev/null +++ b/apps/appstore/openapi.json @@ -0,0 +1,632 @@ +{ + "openapi": "3.0.3", + "info": { + "title": "settings", + "version": "0.0.1", + "description": "Nextcloud settings", + "license": { + "name": "agpl" + } + }, + "components": { + "securitySchemes": { + "basic_auth": { + "type": "http", + "scheme": "basic" + }, + "bearer_auth": { + "type": "http", + "scheme": "bearer" + } + }, + "schemas": { + "DeclarativeForm": { + "type": "object", + "required": [ + "id", + "priority", + "section_type", + "section_id", + "storage_type", + "title", + "app", + "fields" + ], + "properties": { + "id": { + "type": "string" + }, + "priority": { + "type": "integer", + "format": "int64" + }, + "section_type": { + "type": "string", + "enum": [ + "admin", + "personal" + ] + }, + "section_id": { + "type": "string" + }, + "storage_type": { + "type": "string", + "enum": [ + "internal", + "external" + ] + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "doc_url": { + "type": "string" + }, + "app": { + "type": "string" + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DeclarativeFormField" + } + } + } + }, + "DeclarativeFormField": { + "type": "object", + "required": [ + "id", + "title", + "type", + "default", + "value" + ], + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "type": { + "type": "string", + "enum": [ + "text", + "password", + "email", + "tel", + "url", + "number", + "checkbox", + "multi-checkbox", + "radio", + "select", + "multi-select" + ] + }, + "placeholder": { + "type": "string" + }, + "label": { + "type": "string" + }, + "default": { + "type": "object" + }, + "options": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string" + }, + { + "type": "object", + "required": [ + "name", + "value" + ], + "properties": { + "name": { + "type": "string" + }, + "value": { + "type": "object" + } + } + } + ] + } + }, + "value": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer", + "format": "int64" + }, + { + "type": "number", + "format": "double" + }, + { + "type": "boolean" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "sensitive": { + "type": "boolean" + } + } + }, + "OCSMeta": { + "type": "object", + "required": [ + "status", + "statuscode" + ], + "properties": { + "status": { + "type": "string" + }, + "statuscode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "totalitems": { + "type": "string" + }, + "itemsperpage": { + "type": "string" + } + } + } + } + }, + "paths": { + "/ocs/v2.php/settings/api/declarative/value": { + "post": { + "operationId": "declarative_settings-set-value", + "summary": "Sets a declarative settings value", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "app", + "formId", + "fieldId", + "value" + ], + "properties": { + "app": { + "type": "string", + "description": "ID of the app" + }, + "formId": { + "type": "string", + "description": "ID of the form" + }, + "fieldId": { + "type": "string", + "description": "ID of the field" + }, + "value": { + "type": "object", + "description": "Value to be saved" + } + } + } + } + } + }, + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Value set successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "nullable": true + } + } + } + } + } + } + } + }, + "500": { + "description": "Not logged in or not an admin user", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid arguments to save value", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/settings/api/declarative/value-sensitive": { + "post": { + "operationId": "declarative_settings-set-sensitive-value", + "summary": "Sets a declarative settings value. Password confirmation is required for sensitive values.", + "description": "This endpoint requires password confirmation", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "app", + "formId", + "fieldId", + "value" + ], + "properties": { + "app": { + "type": "string", + "description": "ID of the app" + }, + "formId": { + "type": "string", + "description": "ID of the form" + }, + "fieldId": { + "type": "string", + "description": "ID of the field" + }, + "value": { + "type": "object", + "description": "Value to be saved" + } + } + } + } + } + }, + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Value set successfully", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "nullable": true + } + } + } + } + } + } + } + }, + "500": { + "description": "Not logged in or not an admin user", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid arguments to save value", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + }, + "/ocs/v2.php/settings/api/declarative/forms": { + "get": { + "operationId": "declarative_settings-get-forms", + "summary": "Gets all declarative forms with the values prefilled.", + "tags": [ + "declarative_settings" + ], + "security": [ + { + "bearer_auth": [] + }, + { + "basic_auth": [] + } + ], + "parameters": [ + { + "name": "OCS-APIRequest", + "in": "header", + "description": "Required to be true for the API request to pass", + "required": true, + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Forms returned", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DeclarativeForm" + } + } + } + } + } + } + } + } + }, + "500": { + "description": "", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "Current user is not logged in", + "content": { + "application/json": { + "schema": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": {} + } + } + } + } + } + } + } + } + } + } + }, + "tags": [] +} diff --git a/apps/appstore/openapi.json.license b/apps/appstore/openapi.json.license new file mode 100644 index 0000000000000..83559daa9dcb7 --- /dev/null +++ b/apps/appstore/openapi.json.license @@ -0,0 +1,2 @@ +SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors +SPDX-License-Identifier: AGPL-3.0-or-later \ No newline at end of file diff --git a/apps/settings/src/app-types.ts b/apps/appstore/src/app-types.ts similarity index 100% rename from apps/settings/src/app-types.ts rename to apps/appstore/src/app-types.ts diff --git a/apps/settings/src/apps.js b/apps/appstore/src/apps.js similarity index 100% rename from apps/settings/src/apps.js rename to apps/appstore/src/apps.js diff --git a/apps/settings/src/components/AppAPI/DaemonSelectionDialog.vue b/apps/appstore/src/components/AppAPI/DaemonSelectionDialog.vue similarity index 100% rename from apps/settings/src/components/AppAPI/DaemonSelectionDialog.vue rename to apps/appstore/src/components/AppAPI/DaemonSelectionDialog.vue diff --git a/apps/settings/src/components/AppAPI/DaemonSelectionEntry.vue b/apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue similarity index 100% rename from apps/settings/src/components/AppAPI/DaemonSelectionEntry.vue rename to apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue diff --git a/apps/settings/src/components/AppAPI/DaemonSelectionList.vue b/apps/appstore/src/components/AppAPI/DaemonSelectionList.vue similarity index 100% rename from apps/settings/src/components/AppAPI/DaemonSelectionList.vue rename to apps/appstore/src/components/AppAPI/DaemonSelectionList.vue diff --git a/apps/settings/src/components/AppList.vue b/apps/appstore/src/components/AppList.vue similarity index 99% rename from apps/settings/src/components/AppList.vue rename to apps/appstore/src/components/AppList.vue index f2892854b4355..09096dc9965ca 100644 --- a/apps/settings/src/components/AppList.vue +++ b/apps/appstore/src/components/AppList.vue @@ -150,7 +150,7 @@ import { subscribe, unsubscribe } from '@nextcloud/event-bus' import pLimit from 'p-limit' import NcButton from '@nextcloud/vue/components/NcButton' import AppItem from './AppList/AppItem.vue' -import logger from '../logger.ts' +import logger from '../utils/logger.ts' import AppManagement from '../mixins/AppManagement.js' import { useAppApiStore } from '../store/app-api-store.ts' import { useAppsStore } from '../store/apps-store.ts' diff --git a/apps/settings/src/components/AppList/AppDaemonBadge.vue b/apps/appstore/src/components/AppList/AppDaemonBadge.vue similarity index 100% rename from apps/settings/src/components/AppList/AppDaemonBadge.vue rename to apps/appstore/src/components/AppList/AppDaemonBadge.vue diff --git a/apps/settings/src/components/AppList/AppItem.vue b/apps/appstore/src/components/AppList/AppItem.vue similarity index 100% rename from apps/settings/src/components/AppList/AppItem.vue rename to apps/appstore/src/components/AppList/AppItem.vue diff --git a/apps/settings/src/components/AppList/AppLevelBadge.vue b/apps/appstore/src/components/AppList/AppLevelBadge.vue similarity index 100% rename from apps/settings/src/components/AppList/AppLevelBadge.vue rename to apps/appstore/src/components/AppList/AppLevelBadge.vue diff --git a/apps/settings/src/components/AppList/AppScore.vue b/apps/appstore/src/components/AppList/AppScore.vue similarity index 100% rename from apps/settings/src/components/AppList/AppScore.vue rename to apps/appstore/src/components/AppList/AppScore.vue diff --git a/apps/settings/src/components/AppStoreDiscover/AppLink.vue b/apps/appstore/src/components/AppStoreDiscover/AppLink.vue similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/AppLink.vue rename to apps/appstore/src/components/AppStoreDiscover/AppLink.vue diff --git a/apps/settings/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue b/apps/appstore/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue similarity index 98% rename from apps/settings/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue rename to apps/appstore/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue index 3690850bcdccc..ebf00972e4138 100644 --- a/apps/settings/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue +++ b/apps/appstore/src/components/AppStoreDiscover/AppStoreDiscoverSection.vue @@ -42,7 +42,7 @@ import { defineAsyncComponent, defineComponent, onBeforeMount, ref } from 'vue' import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' -import logger from '../../logger.ts' +import logger from '../../utils/logger.ts' import { filterElements, parseApiResponse } from '../../utils/appDiscoverParser.ts' const PostType = defineAsyncComponent(() => import('./PostType.vue')) diff --git a/apps/settings/src/components/AppStoreDiscover/AppType.vue b/apps/appstore/src/components/AppStoreDiscover/AppType.vue similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/AppType.vue rename to apps/appstore/src/components/AppStoreDiscover/AppType.vue diff --git a/apps/settings/src/components/AppStoreDiscover/CarouselType.vue b/apps/appstore/src/components/AppStoreDiscover/CarouselType.vue similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/CarouselType.vue rename to apps/appstore/src/components/AppStoreDiscover/CarouselType.vue diff --git a/apps/settings/src/components/AppStoreDiscover/PostType.vue b/apps/appstore/src/components/AppStoreDiscover/PostType.vue similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/PostType.vue rename to apps/appstore/src/components/AppStoreDiscover/PostType.vue diff --git a/apps/settings/src/components/AppStoreDiscover/ShowcaseType.vue b/apps/appstore/src/components/AppStoreDiscover/ShowcaseType.vue similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/ShowcaseType.vue rename to apps/appstore/src/components/AppStoreDiscover/ShowcaseType.vue diff --git a/apps/settings/src/components/AppStoreDiscover/common.ts b/apps/appstore/src/components/AppStoreDiscover/common.ts similarity index 100% rename from apps/settings/src/components/AppStoreDiscover/common.ts rename to apps/appstore/src/components/AppStoreDiscover/common.ts diff --git a/apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppDeployDaemonTab.vue similarity index 100% rename from apps/settings/src/components/AppStoreSidebar/AppDeployDaemonTab.vue rename to apps/appstore/src/components/AppStoreSidebar/AppDeployDaemonTab.vue diff --git a/apps/settings/src/components/AppStoreSidebar/AppDeployOptionsModal.vue b/apps/appstore/src/components/AppStoreSidebar/AppDeployOptionsModal.vue similarity index 100% rename from apps/settings/src/components/AppStoreSidebar/AppDeployOptionsModal.vue rename to apps/appstore/src/components/AppStoreSidebar/AppDeployOptionsModal.vue diff --git a/apps/settings/src/components/AppStoreSidebar/AppDescriptionTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue similarity index 100% rename from apps/settings/src/components/AppStoreSidebar/AppDescriptionTab.vue rename to apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue diff --git a/apps/settings/src/components/AppStoreSidebar/AppDetailsTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppDetailsTab.vue similarity index 100% rename from apps/settings/src/components/AppStoreSidebar/AppDetailsTab.vue rename to apps/appstore/src/components/AppStoreSidebar/AppDetailsTab.vue diff --git a/apps/settings/src/components/AppStoreSidebar/AppReleasesTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue similarity index 100% rename from apps/settings/src/components/AppStoreSidebar/AppReleasesTab.vue rename to apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue diff --git a/apps/appstore/src/components/Markdown.spec.ts b/apps/appstore/src/components/Markdown.spec.ts new file mode 100644 index 0000000000000..64f5d90227945 --- /dev/null +++ b/apps/appstore/src/components/Markdown.spec.ts @@ -0,0 +1,58 @@ +/*! + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { cleanup, render } from '@testing-library/vue' +import { beforeEach, describe, expect, it } from 'vitest' +import Markdown from './Markdown.vue' + +describe('Markdown component', () => { + beforeEach(cleanup) + + it('renders links', () => { + const component = render(Markdown, { + props: { + text: 'This is [a link](http://example.com)!', + }, + }) + + const link = component.getByRole('link') + expect(link).toBeInstanceOf(HTMLAnchorElement) + expect(link.getAttribute('href')).toBe('http://example.com') + expect(link.textContent).toBe('a link') + }) + + it('renders headings', () => { + const component = render(Markdown, { + props: { + text: '# level 1\nText\n## level 2\nText\n### level 3\nText\n#### level 4\nText\n##### level 5\nText\n###### level 6\nText\n', + }, + }) + + for (let level = 1; level <= 6; level++) { + const heading = component.getByRole('heading', { level }) + expect(heading.textContent).toBe(`level ${level}`) + } + }) + + it('can limit headings', async () => { + const component = render(Markdown, { + props: { + text: '# level 1\nText\n## level 2\nText\n### level 3\nText\n#### level 4\nText\n##### level 5\nText\n###### level 6\nText\n', + minHeading: 4, + }, + }) + + await expect(component.findByRole('heading', { level: 1 })).rejects.toThrow() + await expect(component.findByRole('heading', { level: 2 })).rejects.toThrow() + await expect(component.findByRole('heading', { level: 3 })).rejects.toThrow() + + expect(component.getByRole('heading', { level: 4 }).textContent).toBe('level 1') + expect(component.getByRole('heading', { level: 5 }).textContent).toBe('level 2') + await expect(component.findByRole('heading', { level: 6, name: 'level 3' })).resolves.not.toThrow() + await expect(component.findByRole('heading', { level: 6, name: 'level 4' })).resolves.not.toThrow() + await expect(component.findByRole('heading', { level: 6, name: 'level 5' })).resolves.not.toThrow() + await expect(component.findByRole('heading', { level: 6, name: 'level 6' })).resolves.not.toThrow() + }) +}) diff --git a/apps/appstore/src/components/Markdown.vue b/apps/appstore/src/components/Markdown.vue new file mode 100644 index 0000000000000..defe46a6800b0 --- /dev/null +++ b/apps/appstore/src/components/Markdown.vue @@ -0,0 +1,158 @@ + + + + + + + diff --git a/apps/settings/src/composables/useAppIcon.ts b/apps/appstore/src/composables/useAppIcon.ts similarity index 97% rename from apps/settings/src/composables/useAppIcon.ts rename to apps/appstore/src/composables/useAppIcon.ts index 533363d17e38b..de2ef6438d30e 100644 --- a/apps/settings/src/composables/useAppIcon.ts +++ b/apps/appstore/src/composables/useAppIcon.ts @@ -8,7 +8,7 @@ import type { IAppstoreApp } from '../app-types.ts' import { mdiCog, mdiCogOutline } from '@mdi/js' import { computed, ref, watchEffect } from 'vue' import AppstoreCategoryIcons from '../constants/AppstoreCategoryIcons.ts' -import logger from '../logger.ts' +import logger from '../utils/logger.ts' /** * Get the app icon raw SVG for use with `NcIconSvgWrapper` (do never use without sanitizing) diff --git a/apps/settings/src/composables/useGetLocalizedValue.ts b/apps/appstore/src/composables/useGetLocalizedValue.ts similarity index 100% rename from apps/settings/src/composables/useGetLocalizedValue.ts rename to apps/appstore/src/composables/useGetLocalizedValue.ts diff --git a/apps/appstore/src/constants/AppDiscoverTypes.ts b/apps/appstore/src/constants/AppDiscoverTypes.ts new file mode 100644 index 0000000000000..ceca45a4058b3 --- /dev/null +++ b/apps/appstore/src/constants/AppDiscoverTypes.ts @@ -0,0 +1,117 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/** + * Currently known types of app discover section elements + */ +export const APP_DISCOVER_KNOWN_TYPES = ['post', 'showcase', 'carousel'] as const + +/** + * Helper for localized values + */ +export type ILocalizedValue = Record & { en: T } + +export interface IAppDiscoverElement { + /** + * Type of the element + */ + type: typeof APP_DISCOVER_KNOWN_TYPES[number] + + /** + * Identifier for this element + */ + id: string + + /** + * Order of this element to pin elements (smaller = shown on top) + */ + order?: number + + /** + * Optional, localized, headline for the element + */ + headline?: ILocalizedValue + + /** + * Optional link target for the element + */ + link?: string + + /** + * Optional date when this element will get valid (only show since then) + */ + date?: number + + /** + * Optional date when this element will be invalid (only show until then) + */ + expiryDate?: number +} + +/** Wrapper for media source and MIME type */ +type MediaSource = { src: string, mime: string } + +/** + * Media content type for posts + */ +interface IAppDiscoverMediaContent { + /** + * The media source to show - either one or a list of sources with their MIME type for fallback options + */ + src: MediaSource | MediaSource[] + + /** + * Alternative text for the media + */ + alt: string + + /** + * Optional link target for the media (e.g. to the full video) + */ + link?: string +} + +/** + * Wrapper for post media + */ +interface IAppDiscoverMedia { + /** + * The alignment of the media element + */ + alignment?: 'start' | 'end' | 'center' + + /** + * The (localized) content + */ + content: ILocalizedValue +} + +/** + * An app element only used for the showcase type + */ +export interface IAppDiscoverApp { + /** The App ID */ + type: 'app' + appId: string +} + +export interface IAppDiscoverPost extends IAppDiscoverElement { + type: 'post' + text?: ILocalizedValue + media?: IAppDiscoverMedia +} + +export interface IAppDiscoverShowcase extends IAppDiscoverElement { + type: 'showcase' + content: (IAppDiscoverPost | IAppDiscoverApp)[] +} + +export interface IAppDiscoverCarousel extends IAppDiscoverElement { + type: 'carousel' + text?: ILocalizedValue + content: IAppDiscoverPost[] +} + +export type IAppDiscoverElements = IAppDiscoverPost | IAppDiscoverCarousel | IAppDiscoverShowcase diff --git a/apps/appstore/src/constants/AppsConstants.js b/apps/appstore/src/constants/AppsConstants.js new file mode 100644 index 0000000000000..c90e35c84cec7 --- /dev/null +++ b/apps/appstore/src/constants/AppsConstants.js @@ -0,0 +1,18 @@ +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { translate as t } from '@nextcloud/l10n' + +/** Enum of verification constants, according to Apps */ +export const APPS_SECTION_ENUM = Object.freeze({ + discover: t('settings', 'Discover'), + installed: t('settings', 'Your apps'), + enabled: t('settings', 'Active apps'), + disabled: t('settings', 'Disabled apps'), + updates: t('settings', 'Updates'), + 'app-bundles': t('settings', 'App bundles'), + featured: t('settings', 'Featured apps'), + supported: t('settings', 'Supported apps'), // From subscription +}) diff --git a/apps/appstore/src/constants/AppstoreCategoryIcons.ts b/apps/appstore/src/constants/AppstoreCategoryIcons.ts new file mode 100644 index 0000000000000..989ffe79c2221 --- /dev/null +++ b/apps/appstore/src/constants/AppstoreCategoryIcons.ts @@ -0,0 +1,63 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import { + mdiAccountMultipleOutline, + mdiAccountOutline, + mdiArchiveOutline, + mdiCheck, + mdiClipboardFlowOutline, + mdiClose, + mdiCogOutline, + mdiControllerClassicOutline, + mdiCreationOutline, + mdiDownload, + mdiFileDocumentEdit, + mdiFolder, + mdiKeyOutline, + mdiMagnify, + mdiMonitorEye, + mdiMultimedia, + mdiOfficeBuildingOutline, + mdiOpenInApp, + mdiSecurity, + mdiStar, + mdiStarCircleOutline, + mdiStarShootingOutline, + mdiTools, + mdiViewColumnOutline, +} from '@mdi/js' + +/** + * SVG paths used for appstore category icons + */ +export default Object.freeze({ + // system special categories + discover: mdiStarCircleOutline, + installed: mdiAccountOutline, + enabled: mdiCheck, + disabled: mdiClose, + bundles: mdiArchiveOutline, + supported: mdiStarShootingOutline, + featured: mdiStar, + updates: mdiDownload, + + // generic category + ai: mdiCreationOutline, + auth: mdiKeyOutline, + customization: mdiCogOutline, + dashboard: mdiViewColumnOutline, + files: mdiFolder, + games: mdiControllerClassicOutline, + integration: mdiOpenInApp, + monitoring: mdiMonitorEye, + multimedia: mdiMultimedia, + office: mdiFileDocumentEdit, + organization: mdiOfficeBuildingOutline, + search: mdiMagnify, + security: mdiSecurity, + social: mdiAccountMultipleOutline, + tools: mdiTools, + workflow: mdiClipboardFlowOutline, +}) diff --git a/apps/appstore/src/main.ts b/apps/appstore/src/main.ts new file mode 100644 index 0000000000000..2f71618e952e4 --- /dev/null +++ b/apps/appstore/src/main.ts @@ -0,0 +1,39 @@ +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { getCSPNonce } from '@nextcloud/auth' +import { n, t } from '@nextcloud/l10n' +import { createPinia, PiniaVuePlugin } from 'pinia' +import VTooltipPlugin from 'v-tooltip' +import Vue from 'vue' +import Vuex from 'vuex' +import { sync } from 'vuex-router-sync' +import App from './views/App.vue' +import router from './router/index.ts' +import { useStore } from './store/index.js' + +// CSP config for webpack dynamic chunk loading + +__webpack_nonce__ = getCSPNonce() + +// bind to window +Vue.prototype.t = t +Vue.prototype.n = n +Vue.use(PiniaVuePlugin) +Vue.use(VTooltipPlugin, { defaultHtml: false }) +Vue.use(Vuex) + +const store = useStore() +sync(store, router) + +const pinia = createPinia() + +export default new Vue({ + router, + store, + pinia, + render: (h) => h(App), + el: '#content', +}) diff --git a/apps/settings/src/mixins/AppManagement.js b/apps/appstore/src/mixins/AppManagement.js similarity index 100% rename from apps/settings/src/mixins/AppManagement.js rename to apps/appstore/src/mixins/AppManagement.js diff --git a/apps/appstore/src/router/index.ts b/apps/appstore/src/router/index.ts new file mode 100644 index 0000000000000..16114da161e4d --- /dev/null +++ b/apps/appstore/src/router/index.ts @@ -0,0 +1,22 @@ +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { generateUrl } from '@nextcloud/router' +import Vue from 'vue' +import Router from 'vue-router' +import routes from './routes.ts' + +Vue.use(Router) + +const router = new Router({ + mode: 'history', + // if index.php is in the url AND we got this far, then it's working: + // let's keep using index.php in the url + base: generateUrl(''), + linkActiveClass: 'active', + routes, +}) + +export default router diff --git a/apps/appstore/src/router/routes.ts b/apps/appstore/src/router/routes.ts new file mode 100644 index 0000000000000..489ddf6f12930 --- /dev/null +++ b/apps/appstore/src/router/routes.ts @@ -0,0 +1,46 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { RouteConfig } from 'vue-router' + +import { loadState } from '@nextcloud/initial-state' + +const appstoreEnabled = loadState('settings', 'appstoreEnabled', true) + +// Dynamic loading +const AppStore = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStore.vue') +const AppStoreNavigation = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStoreNavigation.vue') +const AppStoreSidebar = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStoreSidebar.vue') + +const routes: RouteConfig[] = [ + { + path: '/:index(index.php/)?settings/apps', + name: 'apps', + redirect: { + name: 'apps-category', + params: { + category: appstoreEnabled ? 'discover' : 'installed', + }, + }, + components: { + default: AppStore, + navigation: AppStoreNavigation, + sidebar: AppStoreSidebar, + }, + children: [ + { + path: ':category', + name: 'apps-category', + children: [ + { + path: ':id', + name: 'apps-details', + }, + ], + }, + ], + }, +] + +export default routes diff --git a/apps/appstore/src/service/rebuild-navigation.ts b/apps/appstore/src/service/rebuild-navigation.ts new file mode 100644 index 0000000000000..e3ff425cbd6b2 --- /dev/null +++ b/apps/appstore/src/service/rebuild-navigation.ts @@ -0,0 +1,23 @@ +/*! + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import type { OCSResponse } from '@nextcloud/typings/ocs' + +import axios from '@nextcloud/axios' +import { emit } from '@nextcloud/event-bus' +import { generateOcsUrl } from '@nextcloud/router' + +/** + * Rebuilds the app navigation menu + */ +export async function rebuildNavigation() { + const { data } = await axios.get(generateOcsUrl('core/navigation/apps?format=json')) + if (data.ocs.meta.statuscode !== 200) { + return + } + + emit('nextcloud:app-menu.refresh', { apps: data.ocs.data }) + window.dispatchEvent(new Event('resize')) +} diff --git a/apps/appstore/src/settings.ts b/apps/appstore/src/settings.ts new file mode 100644 index 0000000000000..17cd8f82fbe7f --- /dev/null +++ b/apps/appstore/src/settings.ts @@ -0,0 +1,11 @@ +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { rebuildNavigation } from './service/rebuild-navigation.ts' + +window.OC.Settings ??= {} +window.OC.Settings.Apps ??= { + rebuildNavigation, +} diff --git a/apps/appstore/src/store/api.js b/apps/appstore/src/store/api.js new file mode 100644 index 0000000000000..6f3e661e8c11c --- /dev/null +++ b/apps/appstore/src/store/api.js @@ -0,0 +1,67 @@ +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import axios from '@nextcloud/axios' +import { confirmPassword } from '@nextcloud/password-confirmation' + +/** + * @param {string} url - The url to sanitize + */ +function sanitize(url) { + return url.replace(/\/$/, '') // Remove last url slash +} + +export default { + + /** + * This Promise is used to chain a request that require an admin password confirmation + * Since chaining Promise have a very precise behavior concerning catch and then, + * you'll need to be careful when using it. + * e.g + * // store + * action(context) { + * return api.requireAdmin().then((response) => { + * return api.get('url') + * .then((response) => {API success}) + * .catch((error) => {API failure}); + * }).catch((error) => {requireAdmin failure}); + * } + * // vue + * this.$store.dispatch('action').then(() => {always executed}) + * + * Since Promise.then().catch().then() will always execute the last then + * this.$store.dispatch('action').then will always be executed + * + * If you want requireAdmin failure to also catch the API request failure + * you will need to throw a new error in the api.get.catch() + * + * e.g + * api.requireAdmin().then((response) => { + * api.get('url') + * .then((response) => {API success}) + * .catch((error) => {throw error;}); + * }).catch((error) => {requireAdmin OR API failure}); + * + * @return {Promise} + */ + requireAdmin() { + return confirmPassword() + }, + get(url, options) { + return axios.get(sanitize(url), options) + }, + post(url, data) { + return axios.post(sanitize(url), data) + }, + patch(url, data) { + return axios.patch(sanitize(url), data) + }, + put(url, data) { + return axios.put(sanitize(url), data) + }, + delete(url, data) { + return axios.delete(sanitize(url), { params: data }) + }, +} diff --git a/apps/settings/src/store/app-api-store.ts b/apps/appstore/src/store/app-api-store.ts similarity index 99% rename from apps/settings/src/store/app-api-store.ts rename to apps/appstore/src/store/app-api-store.ts index ba14956bf5e09..5963a4e4baf8e 100644 --- a/apps/settings/src/store/app-api-store.ts +++ b/apps/appstore/src/store/app-api-store.ts @@ -13,7 +13,7 @@ import { confirmPassword } from '@nextcloud/password-confirmation' import { generateUrl } from '@nextcloud/router' import { defineStore } from 'pinia' import Vue from 'vue' -import logger from '../logger.ts' +import logger from '../utils/logger.ts' import api from './api.js' interface AppApiState { diff --git a/apps/settings/src/store/apps-store.ts b/apps/appstore/src/store/apps-store.ts similarity index 98% rename from apps/settings/src/store/apps-store.ts rename to apps/appstore/src/store/apps-store.ts index 0d062aba277a9..46bae37f3c212 100644 --- a/apps/settings/src/store/apps-store.ts +++ b/apps/appstore/src/store/apps-store.ts @@ -12,7 +12,7 @@ import { translate as t } from '@nextcloud/l10n' import { generateUrl } from '@nextcloud/router' import { defineStore } from 'pinia' import APPSTORE_CATEGORY_ICONS from '../constants/AppstoreCategoryIcons.ts' -import logger from '../logger.ts' +import logger from '../utils/logger.ts' const showApiError = () => showError(t('settings', 'An error occurred during the request. Unable to proceed.')) diff --git a/apps/settings/src/store/apps.js b/apps/appstore/src/store/apps.js similarity index 99% rename from apps/settings/src/store/apps.js rename to apps/appstore/src/store/apps.js index 53f66424c0ea2..023d202d5b781 100644 --- a/apps/settings/src/store/apps.js +++ b/apps/appstore/src/store/apps.js @@ -8,7 +8,7 @@ import { showError, showInfo } from '@nextcloud/dialogs' import { loadState } from '@nextcloud/initial-state' import { generateUrl } from '@nextcloud/router' import Vue from 'vue' -import logger from '../logger.ts' +import logger from '../utils/logger.ts' import api from './api.js' const state = { diff --git a/apps/appstore/src/store/index.js b/apps/appstore/src/store/index.js new file mode 100644 index 0000000000000..0b2764d0810d5 --- /dev/null +++ b/apps/appstore/src/store/index.js @@ -0,0 +1,39 @@ +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { showError } from '@nextcloud/dialogs' +import { Store } from 'vuex' +import logger from '../utils/logger.js' +import apps from './apps.js' + +const mutations = { + API_FAILURE(state, error) { + try { + const message = error.error.response.data.ocs.meta.message + showError(t('settings', 'An error occurred during the request. Unable to proceed.') + '
' + message, { isHTML: true }) + } catch { + showError(t('settings', 'An error occurred during the request. Unable to proceed.')) + } + logger.error('An error occurred during the request.', { state, error }) + }, +} + +let store = null + +/** + * + */ +export function useStore() { + if (store === null) { + store = new Store({ + modules: { + apps, + }, + strict: !PRODUCTION, + mutations, + }) + } + return store +} diff --git a/apps/settings/src/utils/appDiscoverParser.spec.ts b/apps/appstore/src/utils/appDiscoverParser.spec.ts similarity index 100% rename from apps/settings/src/utils/appDiscoverParser.spec.ts rename to apps/appstore/src/utils/appDiscoverParser.spec.ts diff --git a/apps/settings/src/utils/appDiscoverParser.ts b/apps/appstore/src/utils/appDiscoverParser.ts similarity index 100% rename from apps/settings/src/utils/appDiscoverParser.ts rename to apps/appstore/src/utils/appDiscoverParser.ts diff --git a/apps/appstore/src/utils/handlers.ts b/apps/appstore/src/utils/handlers.ts new file mode 100644 index 0000000000000..e608e95571555 --- /dev/null +++ b/apps/appstore/src/utils/handlers.ts @@ -0,0 +1,33 @@ +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import type { AxiosError } from '@nextcloud/axios' + +import { showError } from '@nextcloud/dialogs' +import { translate as t } from '@nextcloud/l10n' +import logger from '../utils/logger.ts' + +/** + * @param error the error + * @param message the message to display + */ +export function handleError(error: AxiosError, message: string) { + let fullMessage = '' + + if (message) { + fullMessage += message + } + + if (error.response?.status === 429) { + if (fullMessage) { + fullMessage += '\n' + } + fullMessage += t('settings', 'There were too many requests from your network. Retry later or contact your administrator if this is an error.') + } + + fullMessage = fullMessage || t('settings', 'Error') + showError(fullMessage) + logger.error(fullMessage, { error }) +} diff --git a/apps/appstore/src/utils/logger.ts b/apps/appstore/src/utils/logger.ts new file mode 100644 index 0000000000000..45dab72807d1f --- /dev/null +++ b/apps/appstore/src/utils/logger.ts @@ -0,0 +1,11 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { getLoggerBuilder } from '@nextcloud/logger' + +export default getLoggerBuilder() + .setApp('appstore') + .detectUser() + .build() diff --git a/apps/appstore/src/utils/sorting.ts b/apps/appstore/src/utils/sorting.ts new file mode 100644 index 0000000000000..88f877733ccc3 --- /dev/null +++ b/apps/appstore/src/utils/sorting.ts @@ -0,0 +1,14 @@ +/** + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { getCanonicalLocale, getLanguage } from '@nextcloud/l10n' + +export const naturalCollator = Intl.Collator( + [getLanguage(), getCanonicalLocale()], + { + numeric: true, + usage: 'sort', + }, +) diff --git a/apps/appstore/src/utils/userUtils.ts b/apps/appstore/src/utils/userUtils.ts new file mode 100644 index 0000000000000..957688d20e66e --- /dev/null +++ b/apps/appstore/src/utils/userUtils.ts @@ -0,0 +1,28 @@ +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { translate as t } from '@nextcloud/l10n' + +export const unlimitedQuota = { + id: 'none', + label: t('settings', 'Unlimited'), +} + +export const defaultQuota = { + id: 'default', + label: t('settings', 'Default quota'), +} + +/** + * Return `true` if the logged in user does not have permissions to view the + * data of `user` + * + * @param user The user to check + * @param user.id Id of the user + */ +export function isObfuscated(user: { id: string, [key: string]: unknown }) { + const keys = Object.keys(user) + return keys.length === 1 && keys.at(0) === 'id' +} diff --git a/apps/appstore/src/utils/validate.js b/apps/appstore/src/utils/validate.js new file mode 100644 index 0000000000000..a9e0da458472d --- /dev/null +++ b/apps/appstore/src/utils/validate.js @@ -0,0 +1,79 @@ +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +/* + * Frontend validators, less strict than backend validators + * + * TODO add nice validation errors for Profile page settings modal + */ + +import { VALIDATE_EMAIL_REGEX } from '../constants/AccountPropertyConstants.ts' + +/** + * Validate the email input + * + * Compliant with PHP core FILTER_VALIDATE_EMAIL validator* + * + * Reference implementation https://github.com/mpyw/FILTER_VALIDATE_EMAIL.js/blob/71e62ca48841d2246a1b531e7e84f5a01f15e615/src/index.ts* + * + * @param {string} input the input + * @return {boolean} + */ +export function validateEmail(input) { + return typeof input === 'string' + && VALIDATE_EMAIL_REGEX.test(input) + && input.slice(-1) !== '\n' + && input.length <= 320 + && encodeURIComponent(input).replace(/%../g, 'x').length <= 320 +} + +/** + * Validate the URL input + * + * @param {string} input the input + * @return {boolean} + */ +export function validateUrl(input) { + try { + new URL(input) + return true + } catch { + return false + } +} + +/** + * Validate the language input + * + * @param {object} input the input + * @return {boolean} + */ +export function validateLanguage(input) { + return input.code !== '' + && input.name !== '' + && input.name !== undefined +} + +/** + * Validate the locale input + * + * @param {object} input the input + * @return {boolean} + */ +export function validateLocale(input) { + return input.code !== '' + && input.name !== '' + && input.name !== undefined +} + +/** + * Validate boolean input + * + * @param {boolean} input the input + * @return {boolean} + */ +export function validateBoolean(input) { + return typeof input === 'boolean' +} diff --git a/apps/appstore/src/views/App.vue b/apps/appstore/src/views/App.vue new file mode 100644 index 0000000000000..7e135175ef6bb --- /dev/null +++ b/apps/appstore/src/views/App.vue @@ -0,0 +1,16 @@ + + + + + diff --git a/apps/settings/src/views/AppStore.vue b/apps/appstore/src/views/AppStore.vue similarity index 100% rename from apps/settings/src/views/AppStore.vue rename to apps/appstore/src/views/AppStore.vue diff --git a/apps/settings/src/views/AppStoreNavigation.vue b/apps/appstore/src/views/AppStoreNavigation.vue similarity index 100% rename from apps/settings/src/views/AppStoreNavigation.vue rename to apps/appstore/src/views/AppStoreNavigation.vue diff --git a/apps/settings/src/views/AppStoreSidebar.vue b/apps/appstore/src/views/AppStoreSidebar.vue similarity index 100% rename from apps/settings/src/views/AppStoreSidebar.vue rename to apps/appstore/src/views/AppStoreSidebar.vue diff --git a/apps/appstore/templates/empty.php b/apps/appstore/templates/empty.php new file mode 100644 index 0000000000000..ab87c53681d87 --- /dev/null +++ b/apps/appstore/templates/empty.php @@ -0,0 +1,6 @@ + diff --git a/apps/appstore/tests/AppInfo/ApplicationTest.php b/apps/appstore/tests/AppInfo/ApplicationTest.php new file mode 100644 index 0000000000000..f016c7a86a8ac --- /dev/null +++ b/apps/appstore/tests/AppInfo/ApplicationTest.php @@ -0,0 +1,63 @@ +app = new Application(); + $this->container = $this->app->getContainer(); + } + + public function testContainerAppName(): void { + $this->app = new Application(); + $this->assertEquals('settings', $this->container->get('appName')); + } + + public static function dataContainerQuery(): array { + return [ + [AdminSettingsController::class, Controller::class], + [AppSettingsController::class, Controller::class], + [AuthSettingsController::class, Controller::class], + [CheckSetupController::class, Controller::class], + [LogSettingsController::class, Controller::class], + [MailSettingsController::class, Controller::class], + [UsersController::class, Controller::class], + + [SubadminMiddleware::class, Middleware::class], + ]; + } + + #[\PHPUnit\Framework\Attributes\DataProvider('dataContainerQuery')] + public function testContainerQuery(string $service, string $expected): void { + $this->assertTrue($this->container->query($service) instanceof $expected); + } +} diff --git a/apps/appstore/tests/Controller/AppSettingsControllerTest.php b/apps/appstore/tests/Controller/AppSettingsControllerTest.php new file mode 100644 index 0000000000000..de96a10d31ee9 --- /dev/null +++ b/apps/appstore/tests/Controller/AppSettingsControllerTest.php @@ -0,0 +1,222 @@ +request = $this->createMock(IRequest::class); + $this->appDataFactory = $this->createMock(IAppDataFactory::class); + $this->l10n = $this->createMock(IL10N::class); + $this->l10n->expects($this->any()) + ->method('t') + ->willReturnArgument(0); + $this->config = $this->createMock(IConfig::class); + $this->navigationManager = $this->createMock(INavigationManager::class); + $this->appManager = $this->createMock(AppManager::class); + $this->categoryFetcher = $this->createMock(CategoryFetcher::class); + $this->appFetcher = $this->createMock(AppFetcher::class); + $this->l10nFactory = $this->createMock(IFactory::class); + $this->bundleFetcher = $this->createMock(BundleFetcher::class); + $this->installer = $this->createMock(Installer::class); + $this->urlGenerator = $this->createMock(IURLGenerator::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->initialState = $this->createMock(IInitialState::class); + $this->discoverFetcher = $this->createMock(AppDiscoverFetcher::class); + $this->clientService = $this->createMock(IClientService::class); + + $this->appSettingsController = new AppSettingsController( + 'settings', + $this->request, + $this->appDataFactory, + $this->l10n, + $this->config, + $this->navigationManager, + $this->appManager, + $this->categoryFetcher, + $this->appFetcher, + $this->l10nFactory, + $this->bundleFetcher, + $this->installer, + $this->urlGenerator, + $this->logger, + $this->initialState, + $this->discoverFetcher, + $this->clientService, + ); + } + + public function testListCategories(): void { + $this->installer->expects($this->any()) + ->method('isUpdateAvailable') + ->willReturn(false); + $expected = new JSONResponse([ + [ + 'id' => 'auth', + 'displayName' => 'Authentication & authorization', + ], + [ + 'id' => 'customization', + 'displayName' => 'Customization', + ], + [ + 'id' => 'files', + 'displayName' => 'Files', + ], + [ + 'id' => 'integration', + 'displayName' => 'Integration', + ], + [ + 'id' => 'monitoring', + 'displayName' => 'Monitoring', + ], + [ + 'id' => 'multimedia', + 'displayName' => 'Multimedia', + ], + [ + 'id' => 'office', + 'displayName' => 'Office & text', + ], + [ + 'id' => 'organization', + 'displayName' => 'Organization', + ], + [ + 'id' => 'social', + 'displayName' => 'Social & communication', + ], + [ + 'id' => 'tools', + 'displayName' => 'Tools', + ], + ]); + + $this->categoryFetcher + ->expects($this->once()) + ->method('get') + ->willReturn(json_decode('[{"id":"auth","translations":{"cs":{"name":"Autentizace & autorizace","description":"Aplikace poskytující služby dodatečného ověření nebo přihlášení"},"hu":{"name":"Azonosítás és hitelesítés","description":"Apps that provide additional authentication or authorization services"},"de":{"name":"Authentifizierung & Authorisierung","description":"Apps die zusätzliche Autentifizierungs- oder Autorisierungsdienste bereitstellen"},"nl":{"name":"Authenticatie & authorisatie","description":"Apps die aanvullende authenticatie- en autorisatiediensten bieden"},"nb":{"name":"Pålogging og tilgangsstyring","description":"Apper for å tilby ekstra pålogging eller tilgangsstyring"},"it":{"name":"Autenticazione e autorizzazione","description":"Apps that provide additional authentication or authorization services"},"fr":{"name":"Authentification et autorisations","description":"Applications qui fournissent des services d\'authentification ou d\'autorisations additionnels."},"ru":{"name":"Аутентификация и авторизация","description":"Apps that provide additional authentication or authorization services"},"en":{"name":"Authentication & authorization","description":"Apps that provide additional authentication or authorization services"}}},{"id":"customization","translations":{"cs":{"name":"Přizpůsobení","description":"Motivy a aplikace měnící rozvržení a uživatelské rozhraní"},"it":{"name":"Personalizzazione","description":"Applicazioni di temi, modifiche della disposizione e UX"},"de":{"name":"Anpassung","description":"Apps zur Änderung von Themen, Layout und Benutzererfahrung"},"hu":{"name":"Személyre szabás","description":"Témák, elrendezések felhasználói felület módosító alkalmazások"},"nl":{"name":"Maatwerk","description":"Thema\'s, layout en UX aanpassingsapps"},"nb":{"name":"Tilpasning","description":"Apper for å endre Tema, utseende og brukeropplevelse"},"fr":{"name":"Personalisation","description":"Thèmes, apparence et applications modifiant l\'expérience utilisateur"},"ru":{"name":"Настройка","description":"Themes, layout and UX change apps"},"en":{"name":"Customization","description":"Themes, layout and UX change apps"}}},{"id":"files","translations":{"cs":{"name":"Soubory","description":"Aplikace rozšiřující správu souborů nebo aplikaci Soubory"},"it":{"name":"File","description":"Applicazioni di gestione dei file ed estensione dell\'applicazione FIle"},"de":{"name":"Dateien","description":"Dateimanagement sowie Erweiterungs-Apps für die Dateien-App"},"hu":{"name":"Fájlok","description":"Fájl kezelő és kiegészítő alkalmazások"},"nl":{"name":"Bestanden","description":"Bestandebeheer en uitbreidingen van bestand apps"},"nb":{"name":"Filer","description":"Apper for filhåndtering og filer"},"fr":{"name":"Fichiers","description":"Applications de gestion de fichiers et extensions à l\'application Fichiers"},"ru":{"name":"Файлы","description":"Расширение: файлы и управление файлами"},"en":{"name":"Files","description":"File management and Files app extension apps"}}},{"id":"integration","translations":{"it":{"name":"Integrazione","description":"Applicazioni che collegano Nextcloud con altri servizi e piattaforme"},"hu":{"name":"Integráció","description":"Apps that connect Nextcloud with other services and platforms"},"nl":{"name":"Integratie","description":"Apps die Nextcloud verbinden met andere services en platformen"},"nb":{"name":"Integrasjon","description":"Apper som kobler Nextcloud med andre tjenester og plattformer"},"de":{"name":"Integration","description":"Apps die Nextcloud mit anderen Diensten und Plattformen verbinden"},"cs":{"name":"Propojení","description":"Aplikace propojující NextCloud s dalšími službami a platformami"},"fr":{"name":"Intégration","description":"Applications qui connectent Nextcloud avec d\'autres services et plateformes"},"ru":{"name":"Интеграция","description":"Приложения, соединяющие Nextcloud с другими службами и платформами"},"en":{"name":"Integration","description":"Apps that connect Nextcloud with other services and platforms"}}},{"id":"monitoring","translations":{"nb":{"name":"Overvåking","description":"Apper for statistikk, systemdiagnose og aktivitet"},"it":{"name":"Monitoraggio","description":"Applicazioni di statistiche, diagnostica di sistema e attività"},"de":{"name":"Überwachung","description":"Datenstatistiken-, Systemdiagnose- und Aktivitäten-Apps"},"hu":{"name":"Megfigyelés","description":"Data statistics, system diagnostics and activity apps"},"nl":{"name":"Monitoren","description":"Gegevensstatistiek, systeem diagnose en activiteit apps"},"cs":{"name":"Kontrola","description":"Datové statistiky, diagnózy systému a aktivity aplikací"},"fr":{"name":"Surveillance","description":"Applications de statistiques sur les données, de diagnostics systèmes et d\'activité."},"ru":{"name":"Мониторинг","description":"Статистика данных, диагностика системы и активность приложений"},"en":{"name":"Monitoring","description":"Data statistics, system diagnostics and activity apps"}}},{"id":"multimedia","translations":{"nb":{"name":"Multimedia","description":"Apper for lyd, film og bilde"},"it":{"name":"Multimedia","description":"Applicazioni per audio, video e immagini"},"de":{"name":"Multimedia","description":"Audio-, Video- und Bilder-Apps"},"hu":{"name":"Multimédia","description":"Hang, videó és kép alkalmazások"},"nl":{"name":"Multimedia","description":"Audio, video en afbeelding apps"},"en":{"name":"Multimedia","description":"Audio, video and picture apps"},"cs":{"name":"Multimédia","description":"Aplikace audia, videa a obrázků"},"fr":{"name":"Multimédia","description":"Applications audio, vidéo et image"},"ru":{"name":"Мультимедиа","description":"Приложение аудио, видео и изображения"}}},{"id":"office","translations":{"nb":{"name":"Kontorstøtte og tekst","description":"Apper for Kontorstøtte og tekstbehandling"},"it":{"name":"Ufficio e testo","description":"Applicazione per ufficio ed elaborazione di testi"},"de":{"name":"Büro & Text","description":"Büro- und Textverarbeitungs-Apps"},"hu":{"name":"Iroda és szöveg","description":"Irodai és szöveg feldolgozó alkalmazások"},"nl":{"name":"Office & tekst","description":"Office en tekstverwerkingsapps"},"cs":{"name":"Kancelář a text","description":"Aplikace pro kancelář a zpracování textu"},"fr":{"name":"Bureautique & texte","description":"Applications de bureautique et de traitement de texte"},"en":{"name":"Office & text","description":"Office and text processing apps"}}},{"id":"organization","translations":{"nb":{"name":"Organisering","description":"Apper for tidsstyring, oppgaveliste og kalender"},"it":{"name":"Organizzazione","description":"Applicazioni di gestione del tempo, elenco delle cose da fare e calendario"},"hu":{"name":"Szervezet","description":"Időbeosztás, teendő lista és naptár alkalmazások"},"nl":{"name":"Organisatie","description":"Tijdmanagement, takenlijsten en agenda apps"},"cs":{"name":"Organizace","description":"Aplikace pro správu času, plánování a kalendáře"},"de":{"name":"Organisation","description":"Time management, Todo list and calendar apps"},"fr":{"name":"Organisation","description":"Applications de gestion du temps, de listes de tâches et d\'agendas"},"ru":{"name":"Организация","description":"Приложения по управлению временем, список задач и календарь"},"en":{"name":"Organization","description":"Time management, Todo list and calendar apps"}}},{"id":"social","translations":{"nb":{"name":"Sosialt og kommunikasjon","description":"Apper for meldinger, kontakthåndtering og sosiale medier"},"it":{"name":"Sociale e comunicazione","description":"Applicazioni di messaggistica, gestione dei contatti e reti sociali"},"de":{"name":"Kommunikation","description":"Nachrichten-, Kontaktverwaltungs- und Social-Media-Apps"},"hu":{"name":"Közösségi és kommunikáció","description":"Üzenetküldő, kapcsolat kezelő és közösségi média alkalmazások"},"nl":{"name":"Sociaal & communicatie","description":"Messaging, contactbeheer en social media apps"},"cs":{"name":"Sociální sítě a komunikace","description":"Aplikace pro zasílání zpráv, správu kontaktů a sociální sítě"},"fr":{"name":"Social & communication","description":"Applications de messagerie, de gestion de contacts et de réseaux sociaux"},"ru":{"name":"Социальное и связь","description":"Общение, управление контактами и социальное медиа-приложение"},"en":{"name":"Social & communication","description":"Messaging, contact management and social media apps"}}},{"id":"tools","translations":{"nb":{"name":"Verktøy","description":"Alt annet"},"it":{"name":"Strumenti","description":"Tutto il resto"},"hu":{"name":"Eszközök","description":"Minden más"},"nl":{"name":"Tools","description":"De rest"},"de":{"name":"Werkzeuge","description":"Alles Andere"},"en":{"name":"Tools","description":"Everything else"},"cs":{"name":"Nástroje","description":"Vše ostatní"},"fr":{"name":"Outils","description":"Tout le reste"},"ru":{"name":"Приложения","description":"Что-то еще"}}}]', true)); + + $this->assertEquals($expected, $this->appSettingsController->listCategories()); + } + + public function testViewApps(): void { + $this->bundleFetcher->expects($this->once())->method('getBundles')->willReturn([]); + $this->installer->expects($this->any()) + ->method('isUpdateAvailable') + ->willReturn(false); + $this->config + ->expects($this->once()) + ->method('getSystemValueBool') + ->with('appstoreenabled', true) + ->willReturn(true); + $this->navigationManager + ->expects($this->once()) + ->method('setActiveEntry') + ->with('core_apps'); + + $this->initialState + ->expects($this->exactly(4)) + ->method('provideInitialState'); + + $policy = new ContentSecurityPolicy(); + $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); + + $expected = new TemplateResponse('settings', + 'settings/empty', + [ + 'pageTitle' => 'Settings' + ], + 'user'); + $expected->setContentSecurityPolicy($policy); + + $this->assertEquals($expected, $this->appSettingsController->viewApps()); + } + + public function testViewAppsAppstoreNotEnabled(): void { + $this->installer->expects($this->any()) + ->method('isUpdateAvailable') + ->willReturn(false); + $this->bundleFetcher->expects($this->once())->method('getBundles')->willReturn([]); + $this->config + ->expects($this->once()) + ->method('getSystemValueBool') + ->with('appstoreenabled', true) + ->willReturn(false); + $this->navigationManager + ->expects($this->once()) + ->method('setActiveEntry') + ->with('core_apps'); + + $this->initialState + ->expects($this->exactly(4)) + ->method('provideInitialState'); + + $policy = new ContentSecurityPolicy(); + $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); + + $expected = new TemplateResponse('settings', + 'settings/empty', + [ + 'pageTitle' => 'Settings' + ], + 'user'); + $expected->setContentSecurityPolicy($policy); + + $this->assertEquals($expected, $this->appSettingsController->viewApps()); + } +} diff --git a/apps/settings/appinfo/routes.php b/apps/settings/appinfo/routes.php index c3f1333e6baf9..90fcd928dab85 100644 --- a/apps/settings/appinfo/routes.php +++ b/apps/settings/appinfo/routes.php @@ -20,22 +20,6 @@ ['name' => 'MailSettings#storeCredentials', 'url' => '/settings/admin/mailsettings/credentials', 'verb' => 'POST' , 'root' => ''], ['name' => 'MailSettings#sendTestMail', 'url' => '/settings/admin/mailtest', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#getAppDiscoverJSON', 'url' => '/settings/api/apps/discover', 'verb' => 'GET', 'root' => ''], - ['name' => 'AppSettings#getAppDiscoverMedia', 'url' => '/settings/api/apps/media', 'verb' => 'GET', 'root' => ''], - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#updateApp', 'url' => '/settings/apps/update/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#uninstallApp', 'url' => '/settings/apps/uninstall/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => ''] , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => ''] , 'root' => ''], - ['name' => 'AppSettings#force', 'url' => '/settings/apps/force', 'verb' => 'POST' , 'root' => ''], - ['name' => 'Users#setDisplayName', 'url' => '/settings/users/{username}/displayName', 'verb' => 'POST' , 'root' => ''], ['name' => 'Users#setEMailAddress', 'url' => '/settings/users/{id}/mailAddress', 'verb' => 'PUT' , 'root' => ''], ['name' => 'Users#setUserSettings', 'url' => '/settings/users/{username}/settings', 'verb' => 'PUT' , 'root' => ''], diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php index d08572f926f66..8af8d22633541 100644 --- a/apps/settings/lib/Controller/UsersController.php +++ b/apps/settings/lib/Controller/UsersController.php @@ -255,7 +255,7 @@ public function usersList(INavigationManager $navigationManager, ISubAdmin $subA $this->initialState->provideInitialState('usersSettings', $serverData); Util::addStyle('settings', 'settings'); - Util::addScript('settings', 'vue-settings-apps-users-management'); + Util::addScript('settings', 'vue-settings-users-management'); return new TemplateResponse('settings', 'settings/empty', ['pageTitle' => $this->l10n->t('Settings')]); } diff --git a/apps/settings/src/components/SvgFilterMixin.vue b/apps/settings/src/components/SvgFilterMixin.vue deleted file mode 100644 index 378835abb04e3..0000000000000 --- a/apps/settings/src/components/SvgFilterMixin.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/apps/settings/src/main-apps-users-management.ts b/apps/settings/src/main-users-management.ts similarity index 100% rename from apps/settings/src/main-apps-users-management.ts rename to apps/settings/src/main-users-management.ts diff --git a/apps/settings/src/router/routes.ts b/apps/settings/src/router/routes.ts index 42621eea09bb1..0742553220ab0 100644 --- a/apps/settings/src/router/routes.ts +++ b/apps/settings/src/router/routes.ts @@ -2,16 +2,8 @@ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors * SPDX-License-Identifier: AGPL-3.0-or-later */ -import type { RouteConfig } from 'vue-router' - -import { loadState } from '@nextcloud/initial-state' -const appstoreEnabled = loadState('settings', 'appstoreEnabled', true) - -// Dynamic loading -const AppStore = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStore.vue') -const AppStoreNavigation = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStoreNavigation.vue') -const AppStoreSidebar = () => import(/* webpackChunkName: 'settings-apps-view' */'../views/AppStoreSidebar.vue') +import type { RouteConfig } from 'vue-router' const UserManagement = () => import(/* webpackChunkName: 'settings-users' */'../views/UserManagement.vue') const UserManagementNavigation = () => import(/* webpackChunkName: 'settings-users' */'../views/UserManagementNavigation.vue') @@ -32,33 +24,6 @@ const routes: RouteConfig[] = [ }, ], }, - { - path: '/:index(index.php/)?settings/apps', - name: 'apps', - redirect: { - name: 'apps-category', - params: { - category: appstoreEnabled ? 'discover' : 'installed', - }, - }, - components: { - default: AppStore, - navigation: AppStoreNavigation, - sidebar: AppStoreSidebar, - }, - children: [ - { - path: ':category', - name: 'apps-category', - children: [ - { - path: ':id', - name: 'apps-details', - }, - ], - }, - ], - }, ] export default routes diff --git a/apps/settings/src/service/rebuild-navigation.js b/apps/settings/src/service/rebuild-navigation.js deleted file mode 100644 index 9b0c1ff1e12bf..0000000000000 --- a/apps/settings/src/service/rebuild-navigation.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -import axios from '@nextcloud/axios' -import { emit } from '@nextcloud/event-bus' -import { generateOcsUrl } from '@nextcloud/router' - -export default () => { - return axios.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json') - .then(({ data }) => { - if (data.ocs.meta.statuscode !== 200) { - return - } - - emit('nextcloud:app-menu.refresh', { apps: data.ocs.data }) - window.dispatchEvent(new Event('resize')) - }) -} diff --git a/apps/settings/src/store/index.js b/apps/settings/src/store/index.js index 2a31bea53c6e1..2a76f441deb6b 100644 --- a/apps/settings/src/store/index.js +++ b/apps/settings/src/store/index.js @@ -6,7 +6,6 @@ import { showError } from '@nextcloud/dialogs' import { Store } from 'vuex' import logger from '../logger.js' -import apps from './apps.js' import oc from './oc.js' import settings from './users-settings.js' import users from './users.js' @@ -33,7 +32,6 @@ export function useStore() { store = new Store({ modules: { users, - apps, settings, oc, }, diff --git a/apps/settings/templates/settings/frame.php b/apps/settings/templates/settings/frame.php index f028dd81406e9..372d5f3d53b0a 100644 --- a/apps/settings/templates/settings/frame.php +++ b/apps/settings/templates/settings/frame.php @@ -5,7 +5,7 @@ */ style('settings', 'settings'); -\OCP\Util::addScript('settings', 'settings', 'core'); +\OCP\Util::addScript('appstore', 'settings', 'core'); \OCP\Util::addScript('settings', 'legacy-admin'); ?> diff --git a/build/frontend-legacy/apps/appstore b/build/frontend-legacy/apps/appstore new file mode 120000 index 0000000000000..61a2d69d80091 --- /dev/null +++ b/build/frontend-legacy/apps/appstore @@ -0,0 +1 @@ +../../../apps/appstore \ No newline at end of file diff --git a/build/frontend-legacy/webpack.common.cjs b/build/frontend-legacy/webpack.common.cjs index b18f75a694bab..5d7a7a241a37f 100644 --- a/build/frontend-legacy/webpack.common.cjs +++ b/build/frontend-legacy/webpack.common.cjs @@ -15,7 +15,6 @@ const WebpackSPDXPlugin = require('./WebpackSPDXPlugin.cjs') const appVersion = readFileSync(path.join(__dirname, '../../version.php')).toString().match(/OC_Version.+\[([0-9]{2})/)?.[1] ?? 'unknown' const isDev = process.env.NODE_ENV === 'development' -const isTesting = process.env.TESTING === 'true' /** * diff --git a/build/frontend-legacy/webpack.modules.cjs b/build/frontend-legacy/webpack.modules.cjs index cdc0f8e58b932..09ce7141c46ff 100644 --- a/build/frontend-legacy/webpack.modules.cjs +++ b/build/frontend-legacy/webpack.modules.cjs @@ -58,7 +58,6 @@ module.exports = { main: path.join(__dirname, 'apps/profile/src', 'main.ts'), }, settings: { - apps: path.join(__dirname, 'apps/settings/src', 'apps.js'), 'legacy-admin': path.join(__dirname, 'apps/settings/src', 'admin.js'), 'vue-settings-admin-overview': path.join(__dirname, 'apps/settings/src', 'main-admin-overview.ts'), 'vue-settings-admin-basic-settings': path.join(__dirname, 'apps/settings/src', 'main-admin-basic-settings.js'), @@ -67,12 +66,12 @@ module.exports = { 'vue-settings-admin-security': path.join(__dirname, 'apps/settings/src', 'main-admin-security.js'), 'vue-settings-admin-settings-presets': path.join(__dirname, 'apps/settings/src', 'main-admin-settings-presets.js'), 'vue-settings-admin-sharing': path.join(__dirname, 'apps/settings/src', 'admin-settings-sharing.ts'), - 'vue-settings-apps-users-management': path.join(__dirname, 'apps/settings/src', 'main-apps-users-management.ts'), 'vue-settings-nextcloud-pdf': path.join(__dirname, 'apps/settings/src', 'main-nextcloud-pdf.js'), 'vue-settings-personal-info': path.join(__dirname, 'apps/settings/src', 'main-personal-info.js'), 'vue-settings-personal-password': path.join(__dirname, 'apps/settings/src', 'main-personal-password.js'), 'vue-settings-personal-security': path.join(__dirname, 'apps/settings/src', 'main-personal-security.js'), 'vue-settings-personal-webauthn': path.join(__dirname, 'apps/settings/src', 'main-personal-webauth.js'), + 'vue-settings-users-management': path.join(__dirname, 'apps/settings/src', 'main-users-management.ts'), 'declarative-settings-forms': path.join(__dirname, 'apps/settings/src', 'main-declarative-settings-forms.ts'), }, systemtags: { diff --git a/build/frontend/apps/appstore b/build/frontend/apps/appstore new file mode 120000 index 0000000000000..61a2d69d80091 --- /dev/null +++ b/build/frontend/apps/appstore @@ -0,0 +1 @@ +../../../apps/appstore \ No newline at end of file diff --git a/build/frontend/vite.config.ts b/build/frontend/vite.config.ts index dd48577bca800..0fe1e8818fdc6 100644 --- a/build/frontend/vite.config.ts +++ b/build/frontend/vite.config.ts @@ -7,6 +7,10 @@ import { createAppConfig } from '@nextcloud/vite-config' import { resolve } from 'node:path' const modules = { + appstore: { + main: resolve(import.meta.dirname, 'apps/appstore/src', 'main.ts'), + settings: resolve(import.meta.dirname, 'apps/appstore/src', 'settings.ts'), + }, dav: { 'settings-admin-caldav': resolve(import.meta.dirname, 'apps/dav/src', 'settings-admin.ts'), 'settings-admin-example-content': resolve(import.meta.dirname, 'apps/dav/src', 'settings-admin-example-content.ts'), diff --git a/core/shipped.json b/core/shipped.json index 79a88cf22f09c..85e221664b8ca 100644 --- a/core/shipped.json +++ b/core/shipped.json @@ -3,6 +3,7 @@ "activity", "admin_audit", "app_api", + "appstore", "bruteforcesettings", "circles", "cloud_federation_api", @@ -57,6 +58,7 @@ "defaultEnabled": [ "activity", "app_api", + "appstore", "bruteforcesettings", "circles", "comments", @@ -99,6 +101,7 @@ "webhook_listeners" ], "alwaysEnabled": [ + "appstore", "cloud_federation_api", "dav", "federatedfilesharing", diff --git a/lib/private/AppFramework/Routing/RouteParser.php b/lib/private/AppFramework/Routing/RouteParser.php index 13907b2a8af52..d212804512492 100644 --- a/lib/private/AppFramework/Routing/RouteParser.php +++ b/lib/private/AppFramework/Routing/RouteParser.php @@ -16,6 +16,7 @@ class RouteParser { private $controllerNameCache = []; private const rootUrlApps = [ + 'appstore', 'cloud_federation_api', 'core', 'files_sharing', diff --git a/lib/private/NavigationManager.php b/lib/private/NavigationManager.php index fb0795376bbb5..9f6f2d13a15b1 100644 --- a/lib/private/NavigationManager.php +++ b/lib/private/NavigationManager.php @@ -263,8 +263,8 @@ private function init(bool $resolveClosures = true): void { 'type' => 'settings', 'id' => 'core_apps', 'order' => 5, - 'href' => $this->urlGenerator->linkToRoute('settings.AppSettings.viewApps'), - 'icon' => $this->urlGenerator->imagePath('settings', 'apps.svg'), + 'href' => $this->urlGenerator->linkToRoute('appstore.AppSettings.viewApps'), + 'icon' => $this->urlGenerator->imagePath('appstore', 'apps.svg'), 'name' => $l->t('Apps'), ]); diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index c0170b7dd8383..2b9ba42f35c8d 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -265,6 +265,8 @@ public function findMatchingRoute(string $url): array { $app = $this->appManager->cleanAppId($app); \OC::$REQUESTEDAPP = $app; $this->loadRoutes($app); + } elseif (str_starts_with($url, '/settings/apps')) { + $this->loadRoutes('appstore'); } elseif (str_starts_with($url, '/settings/')) { $this->loadRoutes('settings'); } elseif (str_starts_with($url, '/core/')) { diff --git a/package-lock.json b/package-lock.json index b1a02b2567ef6..95d3aed671336 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@vueuse/core": "^14.1.0", "@vueuse/integrations": "^14.1.0", "debounce": "^3.0.0", + "marked": "^17.0.1", "pinia": "^3.0.4", "sortablejs": "^1.15.6", "vue": "^3.5.26", @@ -228,6 +229,7 @@ "integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.3", @@ -537,6 +539,7 @@ "integrity": "sha512-eohl3hKTiVyD1ilYdw9T0OiB4hnjef89e3dMYKz+mVKDzj+5IteTseASUsOB+EU9Tf6VNTCjDePcP6wkDGmLKQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@keyv/serialize": "^1.1.1" } @@ -666,6 +669,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" }, @@ -709,6 +713,7 @@ } ], "license": "MIT", + "peer": true, "engines": { "node": ">=18" } @@ -2339,6 +2344,7 @@ "resolved": "https://registry.npmjs.org/@nextcloud/l10n/-/l10n-3.4.1.tgz", "integrity": "sha512-aTFinTcKiK2gEXwLgutXekpZZ8/v/4QiC8C3QCLH5m0o+WtxsBC+fqV142ebC/rfDnzCLhY4ZtswSu8bFbZocg==", "license": "GPL-3.0-or-later", + "peer": true, "dependencies": { "@nextcloud/router": "^3.0.1", "@nextcloud/typings": "^1.9.1", @@ -2527,6 +2533,7 @@ "resolved": "https://registry.npmjs.org/@nextcloud/vue/-/vue-9.3.1.tgz", "integrity": "sha512-zNit83SI7IPT5iT9QsYPCYNwBYvKEqzLvWKTeJemqg9MZ8JGIC3/jjENeXzDolrTN/PixHns5lOYVCejATE1ag==", "license": "AGPL-3.0-or-later", + "peer": true, "dependencies": { "@ckpack/vue-color": "^1.6.0", "@floating-ui/dom": "^1.7.4", @@ -3430,6 +3437,7 @@ "integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "json-schema-traverse": "^1.0.0", @@ -3609,6 +3617,7 @@ "integrity": "sha512-IeZF+8H0ns6prg4VrkhgL+yrvDXWDH2cKchrbh80ejG9dQgZWp10epHMbgRuQvgchLII/lfh6Xn3lu6+6L86Hw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.9.0", "@typescript-eslint/types": "^8.46.1", @@ -4019,6 +4028,7 @@ "integrity": "sha512-jCzKdm/QK0Kg4V4IK/oMlRZlY+QOcdjv89U2NgKHZk1CYTj82/RVSx1mV/0gqCVMJ/DA+Zf/S4NBWNF8GQ+eqQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.48.0", "@typescript-eslint/types": "8.48.0", @@ -4469,6 +4479,7 @@ "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.26.tgz", "integrity": "sha512-egp69qDTSEZcf4bGOSsprUr4xI73wfrY5oRs6GSgXFTiHrWj4Y3X5Ydtip9QMqiCMCPVwLglB9GBxXtTadJ3mA==", "license": "MIT", + "peer": true, "dependencies": { "@babel/parser": "^7.28.5", "@vue/compiler-core": "3.5.26", @@ -4823,6 +4834,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5598,6 +5610,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.9", "caniuse-lite": "^1.0.30001746", @@ -6562,6 +6575,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "@cypress/request": "^3.0.9", "@cypress/xvfb": "^1.2.4", @@ -7264,7 +7278,6 @@ "integrity": "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.2", @@ -7280,7 +7293,6 @@ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=0.12" }, @@ -7312,8 +7324,7 @@ "url": "https://github.com/sponsors/fb55" } ], - "license": "BSD-2-Clause", - "peer": true + "license": "BSD-2-Clause" }, "node_modules/domhandler": { "version": "5.0.3", @@ -7321,7 +7332,6 @@ "integrity": "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "domelementtype": "^2.3.0" }, @@ -7347,7 +7357,6 @@ "integrity": "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "dependencies": { "dom-serializer": "^2.0.0", "domelementtype": "^2.3.0", @@ -7534,6 +7543,7 @@ "integrity": "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "ansi-colors": "^4.1.1", "strip-ansi": "^6.0.1" @@ -7753,6 +7763,7 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -9397,7 +9408,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.3", @@ -9411,7 +9421,6 @@ "integrity": "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==", "dev": true, "license": "BSD-2-Clause", - "peer": true, "engines": { "node": ">=0.12" }, @@ -11025,6 +11034,18 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/marked": { + "version": "17.0.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-17.0.1.tgz", + "integrity": "sha512-boeBdiS0ghpWcSwoNm/jJBwdpFaMnZWRzjA6SkUMYb40SVaN1x7mmfGKp0jvexGcx+7y2La5zRZsYFZI6Qpypg==", + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + }, "node_modules/material-colors": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/material-colors/-/material-colors-1.2.6.tgz", @@ -12853,6 +12874,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", @@ -12868,7 +12890,6 @@ "integrity": "sha512-5mMeb1TgLWoRKxZ0Xh9RZDfwUUIqRrcxO2uXO+Ezl1N5lqpCiSU5Gk6+1kZediBfBHFtPCdopr2UZ2SgUsKcgQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "htmlparser2": "^8.0.0", "js-tokens": "^9.0.0", @@ -12884,16 +12905,14 @@ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-9.0.1.tgz", "integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/postcss-media-query-parser": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/postcss-media-query-parser/-/postcss-media-query-parser-0.2.3.tgz", "integrity": "sha512-3sOlxmbKcSHMjlUXQZKQ06jOswE7oVkXPxmZdoB1r5l0q6gTFTQSHxNxOrCccElbW7dxNytifNEo8qidX2Vsig==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/postcss-resolve-nested-selector": { "version": "0.1.6", @@ -12908,7 +12927,6 @@ "integrity": "sha512-FARHN8pwH+WiS2OPCxJI8FuRJpTVnn6ZNFiqAM2aeW2LwTHWWmWgIyKC6cUo0L8aeKiF/14MNvnpls6R2PBeMQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12.0" }, @@ -12940,7 +12958,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=12.0" }, @@ -13740,6 +13757,7 @@ "integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/estree": "1.0.8" }, @@ -13944,6 +13962,7 @@ "integrity": "sha512-uf6HoO8fy6ClsrShvMgaKUn14f2EHQLQRtpsZZLeU/Mv0Q1K5P0+x2uvH6Cub39TVVbWNSrraUhDAoFph6vh0A==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -14364,7 +14383,8 @@ "version": "1.15.6", "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.15.6.tgz", "integrity": "sha512-aNfiuwMEpfBM/CN6LY0ibyhxPfPbyFeBTYJKCvzkJ2GkUpazIt3H+QIPAMHwqQ7tMKaHz1Qj+rJJCqljnf4p3A==", - "license": "MIT" + "license": "MIT", + "peer": true }, "node_modules/source-map": { "version": "0.6.1", @@ -14902,6 +14922,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "@csstools/css-parser-algorithms": "^3.0.5", "@csstools/css-syntax-patches-for-csstree": "^1.0.19", @@ -14956,7 +14977,6 @@ "integrity": "sha512-IZv4IVESjKLumUGi+HWeb7skgO6/g4VMuAYrJdlqQFndgbj6WJAXPhaysvBiXefX79upBdQVumgYcdd17gCpjQ==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": "^12 || >=14" }, @@ -14984,7 +15004,6 @@ } ], "license": "MIT", - "peer": true, "engines": { "node": ">=18.12.0" }, @@ -15046,7 +15065,6 @@ "integrity": "sha512-UJUfBFIvXfly8WKIgmqfmkGKPilKB4L5j38JfsDd+OCg2GBdU0vGUV08Uw82tsRZzd4TbsUURVVNGeOhJVF7pA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "css-tree": "^3.0.1", "is-plain-object": "^5.0.0", @@ -15069,16 +15087,14 @@ "resolved": "https://registry.npmjs.org/known-css-properties/-/known-css-properties-0.36.0.tgz", "integrity": "sha512-A+9jP+IUmuQsNdsLdcg6Yt7voiMF/D4K83ew0OpJtpu+l34ef7LaohWV0Rc6KNvzw6ZDizkqfyB5JznZnzuKQA==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/stylelint-scss/node_modules/mdn-data": { "version": "2.24.0", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.24.0.tgz", "integrity": "sha512-i97fklrJl03tL1tdRVw0ZfLLvuDsdb6wxL+TrJ+PKkCbLrp2PCu2+OYdCKychIUm19nSM/35S6qz7pJpnXttoA==", "dev": true, - "license": "CC0-1.0", - "peer": true + "license": "CC0-1.0" }, "node_modules/stylelint-scss/node_modules/postcss-selector-parser": { "version": "7.1.0", @@ -15086,7 +15102,6 @@ "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -15203,6 +15218,7 @@ "integrity": "sha512-8sLjZwK0R+JlxlYcTuVnyT2v+htpdrjDOKuMcOVdYjt52Lh8hWRYpxBPoKx/Zg+bcjc3wx6fmQevMmUztS/ccA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -15850,6 +15866,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -16217,6 +16234,7 @@ "integrity": "sha512-dZwN5L1VlUBewiP6H9s2+B3e3Jg96D0vzN+Ry73sOefebhYr9f94wwkMNN/9ouoU8pV1BqA1d1zGk8928cx0rg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -16830,6 +16848,7 @@ "integrity": "sha512-E4t7DJ9pESL6E3I8nFjPa4xGUd3PmiWDLsDztS2qXSJWfHtbQnwAWylaBvSNY48I3vr8PTqIZlyK8TE3V3CA4Q==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@vitest/expect": "4.0.16", "@vitest/mocker": "4.0.16", @@ -16921,6 +16940,7 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.26.tgz", "integrity": "sha512-SJ/NTccVyAoNUJmkM9KUqPcYlY+u8OVL1X5EW9RIs3ch5H2uERxyyIUI4MRxVCSOiEcupX9xNGde1tL9ZKpimA==", "license": "MIT", + "peer": true, "dependencies": { "@vue/compiler-dom": "3.5.26", "@vue/compiler-sfc": "3.5.26", diff --git a/package.json b/package.json index 949ab4caed627..f69b8362a048e 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@vueuse/core": "^14.1.0", "@vueuse/integrations": "^14.1.0", "debounce": "^3.0.0", + "marked": "^17.0.1", "pinia": "^3.0.4", "sortablejs": "^1.15.6", "vue": "^3.5.26", From 82e94b7daac9138af79dd842876fb02e53afd456 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 25 Dec 2025 13:06:19 +0100 Subject: [PATCH 3/7] refactor(appstore): migrate markdown component to Typescript Signed-off-by: Ferdinand Thiessen --- .../AppStoreSidebar/AppDescriptionTab.vue | 2 +- .../AppStoreSidebar/AppReleasesTab.vue | 4 +- apps/appstore/src/components/Markdown.spec.ts | 58 ------- apps/appstore/src/components/Markdown.vue | 158 ------------------ .../src/components/MarkdownPreview.spec.ts | 33 ++++ .../src/components/MarkdownPreview.vue | 84 ++++++++++ .../src/composables/useMarkdown.spec.ts | 52 ++++++ apps/appstore/src/composables/useMarkdown.ts | 129 ++++++++++++++ 8 files changed, 301 insertions(+), 219 deletions(-) delete mode 100644 apps/appstore/src/components/Markdown.spec.ts delete mode 100644 apps/appstore/src/components/Markdown.vue create mode 100644 apps/appstore/src/components/MarkdownPreview.spec.ts create mode 100644 apps/appstore/src/components/MarkdownPreview.vue create mode 100644 apps/appstore/src/composables/useMarkdown.spec.ts create mode 100644 apps/appstore/src/composables/useMarkdown.ts diff --git a/apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue index 31a229a915220..7eb93ea578d97 100644 --- a/apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue +++ b/apps/appstore/src/components/AppStoreSidebar/AppDescriptionTab.vue @@ -24,7 +24,7 @@ import { mdiTextShort } from '@mdi/js' import { translate as t } from '@nextcloud/l10n' import NcAppSidebarTab from '@nextcloud/vue/components/NcAppSidebarTab' import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' -import Markdown from '../Markdown.vue' +import MarkdownPreview from '../MarkdownPreview.vue' defineProps<{ app: IAppstoreApp diff --git a/apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue b/apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue index 2c2cad7239ca7..b93b06b652a64 100644 --- a/apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue +++ b/apps/appstore/src/components/AppStoreSidebar/AppReleasesTab.vue @@ -13,7 +13,7 @@

{{ release.version }}

-
@@ -28,7 +28,7 @@ import { getLanguage, translate as t } from '@nextcloud/l10n' import { computed } from 'vue' import NcAppSidebarTab from '@nextcloud/vue/components/NcAppSidebarTab' import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' -import Markdown from '../Markdown.vue' +import MarkdownPreview from '../MarkdownPreview.vue' const props = defineProps<{ app: IAppstoreApp }>() diff --git a/apps/appstore/src/components/Markdown.spec.ts b/apps/appstore/src/components/Markdown.spec.ts deleted file mode 100644 index 64f5d90227945..0000000000000 --- a/apps/appstore/src/components/Markdown.spec.ts +++ /dev/null @@ -1,58 +0,0 @@ -/*! - * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ - -import { cleanup, render } from '@testing-library/vue' -import { beforeEach, describe, expect, it } from 'vitest' -import Markdown from './Markdown.vue' - -describe('Markdown component', () => { - beforeEach(cleanup) - - it('renders links', () => { - const component = render(Markdown, { - props: { - text: 'This is [a link](http://example.com)!', - }, - }) - - const link = component.getByRole('link') - expect(link).toBeInstanceOf(HTMLAnchorElement) - expect(link.getAttribute('href')).toBe('http://example.com') - expect(link.textContent).toBe('a link') - }) - - it('renders headings', () => { - const component = render(Markdown, { - props: { - text: '# level 1\nText\n## level 2\nText\n### level 3\nText\n#### level 4\nText\n##### level 5\nText\n###### level 6\nText\n', - }, - }) - - for (let level = 1; level <= 6; level++) { - const heading = component.getByRole('heading', { level }) - expect(heading.textContent).toBe(`level ${level}`) - } - }) - - it('can limit headings', async () => { - const component = render(Markdown, { - props: { - text: '# level 1\nText\n## level 2\nText\n### level 3\nText\n#### level 4\nText\n##### level 5\nText\n###### level 6\nText\n', - minHeading: 4, - }, - }) - - await expect(component.findByRole('heading', { level: 1 })).rejects.toThrow() - await expect(component.findByRole('heading', { level: 2 })).rejects.toThrow() - await expect(component.findByRole('heading', { level: 3 })).rejects.toThrow() - - expect(component.getByRole('heading', { level: 4 }).textContent).toBe('level 1') - expect(component.getByRole('heading', { level: 5 }).textContent).toBe('level 2') - await expect(component.findByRole('heading', { level: 6, name: 'level 3' })).resolves.not.toThrow() - await expect(component.findByRole('heading', { level: 6, name: 'level 4' })).resolves.not.toThrow() - await expect(component.findByRole('heading', { level: 6, name: 'level 5' })).resolves.not.toThrow() - await expect(component.findByRole('heading', { level: 6, name: 'level 6' })).resolves.not.toThrow() - }) -}) diff --git a/apps/appstore/src/components/Markdown.vue b/apps/appstore/src/components/Markdown.vue deleted file mode 100644 index defe46a6800b0..0000000000000 --- a/apps/appstore/src/components/Markdown.vue +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - diff --git a/apps/appstore/src/components/MarkdownPreview.spec.ts b/apps/appstore/src/components/MarkdownPreview.spec.ts new file mode 100644 index 0000000000000..5155626e8d738 --- /dev/null +++ b/apps/appstore/src/components/MarkdownPreview.spec.ts @@ -0,0 +1,33 @@ +/*! + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { cleanup, render } from '@testing-library/vue' +import { beforeEach, describe, expect, it } from 'vitest' +import MarkdownPreview from './MarkdownPreview.vue' + +describe('MarkdownPreview component', () => { + beforeEach(cleanup) + + it('renders', () => { + const component = render(MarkdownPreview, { + props: { + minHeadingLevel: 2, + text: `# Heading one +This is [a link](http://example.com)! +## Heading two +> This is a block quote + +![](http://example.com/image.jpg "Title")`, + }, + }) + + expect(component.getByRole('heading', { level: 2, name: 'Heading one' })).toBeTruthy() + expect(component.getByRole('heading', { level: 3, name: 'Heading two' })).toBeTruthy() + expect(component.getByText('This is a block quote')).toBeInstanceOf(HTMLQuoteElement) + expect(component.getByRole('link', { name: 'a link' })).toBeInstanceOf(HTMLAnchorElement) + expect(component.getByRole('link', { name: 'a link' }).getAttribute('href')).toBe('http://example.com') + expect(() => component.getByRole('img')).toThrow() // its a text + }) +}) diff --git a/apps/appstore/src/components/MarkdownPreview.vue b/apps/appstore/src/components/MarkdownPreview.vue new file mode 100644 index 0000000000000..374a4980667dc --- /dev/null +++ b/apps/appstore/src/components/MarkdownPreview.vue @@ -0,0 +1,84 @@ + + + + + + + diff --git a/apps/appstore/src/composables/useMarkdown.spec.ts b/apps/appstore/src/composables/useMarkdown.spec.ts new file mode 100644 index 0000000000000..e518da81aa1fd --- /dev/null +++ b/apps/appstore/src/composables/useMarkdown.spec.ts @@ -0,0 +1,52 @@ +/*! + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ + +import { expect, test } from 'vitest' +import { useMarkdown } from './useMarkdown.ts' + +test('renders links', () => { + const rendered = useMarkdown('This is [a link](http://example.com)!') + expect(rendered.value).toMatchInlineSnapshot('"

This is a link!

\n"') +}) + +test('removes links with invalid URL', () => { + const rendered = useMarkdown('This is [a link](ftp://example.com)!') + expect(rendered.value).toMatchInlineSnapshot('"

This is !

\n"') +}) + +test('renders images', () => { + const rendered = useMarkdown('![alt text](http://example.com/image.jpg)') + expect(rendered.value).toMatchInlineSnapshot('"

alt text

\n"') +}) + +test('renders images with title', () => { + const rendered = useMarkdown('![](http://example.com/image.jpg "Title")') + expect(rendered.value).toMatchInlineSnapshot('"

Title

\n"') +}) + +test('renders images with alt text and title', () => { + const rendered = useMarkdown('![alt text](http://example.com/image.jpg "Title")') + expect(rendered.value).toMatchInlineSnapshot(` + "

alt text

\n" + `) +}) + +test('renders block quotes', () => { + const rendered = useMarkdown('> This is a block quote') + expect(rendered.value).toMatchInlineSnapshot('"
This is a block quote
"') +}) + +test('renders headings', () => { + const rendered = useMarkdown('# level 1\n## level 2\n### level 3\n#### level 4\n##### level 5\n###### level 6\n') + expect(rendered.value).toMatchInlineSnapshot('"

level 1

level 2

level 3

level 4

level 5
level 6
"') +}) + +test('renders headings with minHeadingLevel', () => { + const rendered = useMarkdown( + '# level 1\n## level 2\n### level 3\n#### level 4\n##### level 5\n###### level 6\n', + { minHeadingLevel: 4 }, + ) + expect(rendered.value).toMatchInlineSnapshot('"

level 1

level 2
level 3
level 4
level 5
level 6
"') +}) diff --git a/apps/appstore/src/composables/useMarkdown.ts b/apps/appstore/src/composables/useMarkdown.ts new file mode 100644 index 0000000000000..26eb66acdfbcb --- /dev/null +++ b/apps/appstore/src/composables/useMarkdown.ts @@ -0,0 +1,129 @@ +import type { Tokens } from 'marked' +import type { MaybeRefOrGetter } from 'vue' + +import dompurify from 'dompurify' +import { marked } from 'marked' +import { computed, toValue } from 'vue' + +export interface MarkdownOptions { + minHeadingLevel?: number +} + +/** + * Render Markdown to HTML + * + * @param text - The Markdown source + * @param options - Markdown options + */ +export function useMarkdown(text: MaybeRefOrGetter, options?: MarkdownOptions) { + const renderer = new marked.Renderer() + renderer.blockquote = markedBlockquote + renderer.link = markedLink + renderer.image = markedImage + + return computed(() => { + const minHeading = options?.minHeadingLevel ?? 1 + renderer.heading = getMarkedHeading(minHeading) + const markdown = toValue(text).trim() + + return dompurify.sanitize( + marked(markdown, { + async: false, + renderer, + gfm: false, + breaks: false, + pedantic: false, + }), + { + ALLOWED_TAGS: [ + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'strong', + 'p', + 'a', + 'ul', + 'ol', + 'li', + 'em', + 'del', + 'blockquote', + ], + }, + ) + }) +} + +/** + * Custom link renderer that only allows http and https links + * + * @param ctx - The render context + * @param ctx.href - The link href + * @param ctx.title - The link title + * @param ctx.text - The link text + */ +function markedLink({ href, title, text }: Tokens.Link) { + let url: URL + try { + url = new URL(href) + } catch { + return '' + } + + if (url.protocol !== 'http:' && url.protocol !== 'https:') { + return '' + } + + let out = '' + return out +} + +/** + * Only render image alt text or title + * + * @param ctx - The render context + * @param ctx.title - The image title + * @param ctx.text - The image alt text + */ +function markedImage({ title, text }: Tokens.Image): string { + if (text) { + return text + } + return title ?? '' +} + +/** + * Render block quotes without any special styling + * + * @param ctx - The render context + * @param ctx.text - The blockquote text + */ +function markedBlockquote({ text }: Tokens.Blockquote): string { + return `
${text}
` +} + +/** + * Get a custom heading renderer that clamps heading levels + * + * @param minHeading - The heading to clamp to + */ +function getMarkedHeading(minHeading: number) { + /** + * Custom heading renderer that adjusts heading levels + * + * @param ctx - The render context + * @param ctx.text - The heading text + * @param ctx.depth - The heading depth + */ + return ({ text, depth }: Tokens.Heading): string => { + depth = Math.min(6, depth + (minHeading - 1)) + return `${text}` + } +} From b54652b6c00cdf5a96c05bed50cb91ef9596c4a8 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 27 Dec 2025 13:50:13 +0100 Subject: [PATCH 4/7] refactor(appstore): split controllers and use proper root Signed-off-by: Ferdinand Thiessen --- apps/appstore/appinfo/routes.php | 27 - .../composer/composer/autoload_classmap.php | 5 +- .../composer/composer/autoload_static.php | 5 +- .../appstore/lib/Controller/ApiController.php | 443 ++++++++++++ .../lib/Controller/AppSettingsController.php | 681 ------------------ .../lib/Controller/DiscoverController.php | 181 +++++ .../lib/Controller/PageController.php | 110 +++ apps/appstore/lib/Search/AppSearch.php | 5 +- 8 files changed, 743 insertions(+), 714 deletions(-) delete mode 100644 apps/appstore/appinfo/routes.php create mode 100644 apps/appstore/lib/Controller/ApiController.php delete mode 100644 apps/appstore/lib/Controller/AppSettingsController.php create mode 100644 apps/appstore/lib/Controller/DiscoverController.php create mode 100644 apps/appstore/lib/Controller/PageController.php diff --git a/apps/appstore/appinfo/routes.php b/apps/appstore/appinfo/routes.php deleted file mode 100644 index b1dfba13ba70f..0000000000000 --- a/apps/appstore/appinfo/routes.php +++ /dev/null @@ -1,27 +0,0 @@ - [ - ['name' => 'AppSettings#getAppDiscoverJSON', 'url' => '/settings/api/apps/discover', 'verb' => 'GET', 'root' => ''], - ['name' => 'AppSettings#getAppDiscoverMedia', 'url' => '/settings/api/apps/media', 'verb' => 'GET', 'root' => ''], - ['name' => 'AppSettings#listCategories', 'url' => '/settings/apps/categories', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#listApps', 'url' => '/settings/apps/list', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#enableApp', 'url' => '/settings/apps/enable/{appId}', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#enableApps', 'url' => '/settings/apps/enable', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#disableApp', 'url' => '/settings/apps/disable/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#disableApps', 'url' => '/settings/apps/disable', 'verb' => 'POST' , 'root' => ''], - ['name' => 'AppSettings#updateApp', 'url' => '/settings/apps/update/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#uninstallApp', 'url' => '/settings/apps/uninstall/{appId}', 'verb' => 'GET' , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}', 'verb' => 'GET', 'defaults' => ['category' => ''] , 'root' => ''], - ['name' => 'AppSettings#viewApps', 'url' => '/settings/apps/{category}/{id}', 'verb' => 'GET', 'defaults' => ['category' => '', 'id' => ''] , 'root' => ''], - ['name' => 'AppSettings#force', 'url' => '/settings/apps/force', 'verb' => 'POST' , 'root' => ''], - ], -]; diff --git a/apps/appstore/composer/composer/autoload_classmap.php b/apps/appstore/composer/composer/autoload_classmap.php index 8dab41160b3db..b84e2600e431a 100644 --- a/apps/appstore/composer/composer/autoload_classmap.php +++ b/apps/appstore/composer/composer/autoload_classmap.php @@ -8,7 +8,8 @@ return array( 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', 'OCA\\Appstore\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', - 'OCA\\Appstore\\Controller\\AppSettingsController' => $baseDir . '/../lib/Controller/AppSettingsController.php', + 'OCA\\Appstore\\Controller\\ApiController' => $baseDir . '/../lib/Controller/ApiController.php', + 'OCA\\Appstore\\Controller\\DiscoverController' => $baseDir . '/../lib/Controller/DiscoverController.php', + 'OCA\\Appstore\\Controller\\PageController' => $baseDir . '/../lib/Controller/PageController.php', 'OCA\\Appstore\\Search\\AppSearch' => $baseDir . '/../lib/Search/AppSearch.php', - 'OCA\\Settings\\ResponseDefinitions' => $baseDir . '/../lib/ResponseDefinitions.php', ); diff --git a/apps/appstore/composer/composer/autoload_static.php b/apps/appstore/composer/composer/autoload_static.php index 78e9f60837890..564b5859cb343 100644 --- a/apps/appstore/composer/composer/autoload_static.php +++ b/apps/appstore/composer/composer/autoload_static.php @@ -23,9 +23,10 @@ class ComposerStaticInitAppstore public static $classMap = array ( 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', 'OCA\\Appstore\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', - 'OCA\\Appstore\\Controller\\AppSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AppSettingsController.php', + 'OCA\\Appstore\\Controller\\ApiController' => __DIR__ . '/..' . '/../lib/Controller/ApiController.php', + 'OCA\\Appstore\\Controller\\DiscoverController' => __DIR__ . '/..' . '/../lib/Controller/DiscoverController.php', + 'OCA\\Appstore\\Controller\\PageController' => __DIR__ . '/..' . '/../lib/Controller/PageController.php', 'OCA\\Appstore\\Search\\AppSearch' => __DIR__ . '/..' . '/../lib/Search/AppSearch.php', - 'OCA\\Settings\\ResponseDefinitions' => __DIR__ . '/..' . '/../lib/ResponseDefinitions.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/apps/appstore/lib/Controller/ApiController.php b/apps/appstore/lib/Controller/ApiController.php new file mode 100644 index 0000000000000..adc7688cd5638 --- /dev/null +++ b/apps/appstore/lib/Controller/ApiController.php @@ -0,0 +1,443 @@ +l10nFactory->findLanguage(), 0, 2); + + $categories = $this->categoryFetcher->get(); + $categories = array_map(fn ($category) => [ + 'id' => $category['id'], + 'displayName' => $category['translations'][$currentLanguage]['name'] ?? $category['translations']['en']['name'], + ], $categories); + + return new DataResponse(array_values($categories)); + } + + /** + * Get all available apps + */ + #[ApiRoute('GET', '/api/v1/apps')] + public function listApps(): DataResponse { + $apps = $this->getAllApps(); + + $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []); + if (!is_array($ignoreMaxApps)) { + $this->logger->warning('The value given for app_install_overwrite is not an array. Ignoring...'); + $ignoreMaxApps = []; + } + + // Extend existing app details + $apps = array_map(function (array $appData) use ($ignoreMaxApps) { + if (isset($appData['appstoreData'])) { + $appstoreData = $appData['appstoreData']; + $appData['screenshot'] = $this->createProxyPreviewUrl($appstoreData['screenshots'][0]['url'] ?? ''); + $appData['category'] = $appstoreData['categories']; + $appData['releases'] = $appstoreData['releases']; + } + + $newVersion = $this->installer->isUpdateAvailable($appData['id']); + if ($newVersion) { + $appData['update'] = $newVersion; + } + + // fix groups to be an array + $groups = []; + if (is_string($appData['groups'])) { + $groups = json_decode($appData['groups']); + // ensure 'groups' is an array + if (!is_array($groups)) { + $groups = [$groups]; + } + } + $appData['groups'] = $groups; + $appData['canUnInstall'] = !$appData['active'] && $appData['removable']; + + // analyze dependencies + $ignoreMax = in_array($appData['id'], $ignoreMaxApps); + $missing = $this->dependencyAnalyzer->analyze($appData, $ignoreMax); + $appData['canInstall'] = empty($missing); + $appData['missingDependencies'] = $missing; + + $appData['missingMinOwnCloudVersion'] = !isset($appData['dependencies']['nextcloud']['@attributes']['min-version']); + $appData['missingMaxOwnCloudVersion'] = !isset($appData['dependencies']['nextcloud']['@attributes']['max-version']); + $appData['isCompatible'] = $this->dependencyAnalyzer->isMarkedCompatible($appData); + + return $appData; + }, $apps); + + usort($apps, $this->sortApps(...)); + + return new DataResponse(array_values($apps)); + } + + /** + * Enable one apps + * + * App will be enabled for specific groups only if $groups is defined + * + * @param string $appId - The app to enable + * @param array $groups - The groups to enable the app for + * @return DataResponse + */ + #[PasswordConfirmationRequired] + #[ApiRoute('POST', '/api/v1/apps/enable')] + public function enableApp(string $appId, array $groups = []): DataResponse { + try { + $updateRequired = false; + + $appId = $this->appManager->cleanAppId($appId); + + // Check if app is already downloaded + if (!$this->installer->isDownloaded($appId)) { + $this->installer->downloadApp($appId); + } + + $this->installer->installApp($appId); + + if (count($groups) > 0) { + $this->appManager->enableAppForGroups($appId, $this->getGroupList($groups)); + } else { + $this->appManager->enableApp($appId); + } + $updateRequired = $updateRequired || $this->appManager->isUpgradeRequired($appId); + return new DataResponse(['update_required' => $updateRequired]); + } catch (\Throwable $e) { + $this->logger->error('could not enable app', ['exception' => $e]); + throw new OCSException('could not enable app', Http::STATUS_INTERNAL_SERVER_ERROR, $e); + } + } + + /** + * Disable an app + */ + #[PasswordConfirmationRequired] + #[ApiRoute('POST', '/api/v1/apps/disable')] + public function disableApp(string $appId): DataResponse { + try { + $appId = $this->appManager->cleanAppId($appId); + $this->appManager->disableApp($appId); + return new DataResponse([]); + } catch (\Exception $e) { + $this->logger->error('could not disable app', ['exception' => $e]); + throw new OCSException('could not disable app', Http::STATUS_INTERNAL_SERVER_ERROR, $e); + } + } + + /** + * Uninstall an app + */ + #[PasswordConfirmationRequired] + #[ApiRoute('POST', '/api/v1/apps/uninstall')] + public function uninstallApp(string $appId): DataResponse { + $appId = $this->appManager->cleanAppId($appId); + $result = $this->installer->removeApp($appId); + if ($result !== false) { + // If this app was force enabled, remove the force-enabled-state + $this->appManager->removeOverwriteNextcloudRequirement($appId); + $this->appManager->clearAppsCache(); + return new DataResponse([]); + } + throw new OCSException('could not remove app', Http::STATUS_INTERNAL_SERVER_ERROR); + } + + /** + * Update an app + */ + #[PasswordConfirmationRequired] + #[ApiRoute('POST', '/api/v1/apps/update')] + public function updateApp(string $appId): DataResponse { + $appId = $this->appManager->cleanAppId($appId); + + $this->config->setSystemValue('maintenance', true); + try { + $result = $this->installer->updateAppstoreApp($appId); + $this->config->setSystemValue('maintenance', false); + if ($result === false) { + throw new \Exception('Update failed'); + } + } catch (\Exception $ex) { + $this->config->setSystemValue('maintenance', false); + throw new OCSException('could not update app', Http::STATUS_INTERNAL_SERVER_ERROR, $ex); + } + + return new DataResponse([]); + } + /** + * Force enable an app. + * + * @return JSONResponse + */ + #[PasswordConfirmationRequired] + #[ApiRoute('POST', '/api/v1/apps/force')] + public function force(string $appId): DataResponse { + $appId = $this->appManager->cleanAppId($appId); + $this->appManager->overwriteNextcloudRequirement($appId); + return new DataResponse([]); + } + + /** + * Convert URL to proxied URL so CSP is no problem + */ + private function createProxyPreviewUrl(string $url): string { + if ($url === '') { + return ''; + } + return 'https://usercontent.apps.nextcloud.com/' . base64_encode($url); + } + + private function fetchApps() { + $appClass = new \OC_App(); + $apps = $appClass->listAllApps(); + foreach ($apps as $app) { + $app['installed'] = true; + + if (isset($app['screenshot'][0])) { + $appScreenshot = $app['screenshot'][0] ?? null; + if (is_array($appScreenshot)) { + // Screenshot with thumbnail + $appScreenshot = $appScreenshot['@value']; + } + + $app['screenshot'] = $this->createProxyPreviewUrl($appScreenshot); + } + $this->allApps[$app['id']] = $app; + } + + $apps = $this->getAppsForCategory(''); + $supportedApps = $this->subscriptionRegistry->delegateGetSupportedApps(); + foreach ($apps as $app) { + $app['appstore'] = true; + if (!array_key_exists($app['id'], $this->allApps)) { + $this->allApps[$app['id']] = $app; + } else { + $this->allApps[$app['id']] = array_merge($app, $this->allApps[$app['id']]); + } + + if (in_array($app['id'], $supportedApps)) { + $this->allApps[$app['id']]['level'] = \OC_App::supportedApp; + } + } + + // add bundle information + $bundles = $this->bundleFetcher->getBundles(); + foreach ($bundles as $bundle) { + foreach ($bundle->getAppIdentifiers() as $identifier) { + foreach ($this->allApps as &$app) { + if ($app['id'] === $identifier) { + $app['bundleIds'][] = $bundle->getIdentifier(); + continue; + } + } + } + } + } + + private function getAllApps() { + if (empty($this->allApps)) { + $this->fetchApps(); + } + return $this->allApps; + } + + /** + * Get all apps for a category from the app store + * + * @param string $requestedCategory + * @return array + * @throws \Exception + */ + private function getAppsForCategory($requestedCategory = ''): array { + $versionParser = new VersionParser(); + $formattedApps = []; + $apps = $this->appFetcher->get(); + foreach ($apps as $app) { + // Skip all apps not in the requested category + if ($requestedCategory !== '') { + $isInCategory = false; + foreach ($app['categories'] as $category) { + if ($category === $requestedCategory) { + $isInCategory = true; + } + } + if (!$isInCategory) { + continue; + } + } + + if (!isset($app['releases'][0]['rawPlatformVersionSpec'])) { + continue; + } + $nextCloudVersion = $versionParser->getVersion($app['releases'][0]['rawPlatformVersionSpec']); + $nextCloudVersionDependencies = []; + if ($nextCloudVersion->getMinimumVersion() !== '') { + $nextCloudVersionDependencies['nextcloud']['@attributes']['min-version'] = $nextCloudVersion->getMinimumVersion(); + } + if ($nextCloudVersion->getMaximumVersion() !== '') { + $nextCloudVersionDependencies['nextcloud']['@attributes']['max-version'] = $nextCloudVersion->getMaximumVersion(); + } + $phpVersion = $versionParser->getVersion($app['releases'][0]['rawPhpVersionSpec']); + + try { + $this->appManager->getAppPath($app['id']); + $existsLocally = true; + } catch (AppPathNotFoundException) { + $existsLocally = false; + } + + $phpDependencies = []; + if ($phpVersion->getMinimumVersion() !== '') { + $phpDependencies['php']['@attributes']['min-version'] = $phpVersion->getMinimumVersion(); + } + if ($phpVersion->getMaximumVersion() !== '') { + $phpDependencies['php']['@attributes']['max-version'] = $phpVersion->getMaximumVersion(); + } + if (isset($app['releases'][0]['minIntSize'])) { + $phpDependencies['php']['@attributes']['min-int-size'] = $app['releases'][0]['minIntSize']; + } + $authors = ''; + foreach ($app['authors'] as $key => $author) { + $authors .= $author['name']; + if ($key !== count($app['authors']) - 1) { + $authors .= ', '; + } + } + + $currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2); + $enabledValue = $this->appConfig->getValueString($app['id'], 'enabled', 'no'); + $groups = null; + if ($enabledValue !== 'no' && $enabledValue !== 'yes') { + $groups = $enabledValue; + } + + $currentVersion = ''; + if ($this->appManager->isEnabledForAnyone($app['id'])) { + $currentVersion = $this->appManager->getAppVersion($app['id']); + } else { + $currentVersion = $app['releases'][0]['version']; + } + + $formattedApps[] = [ + 'id' => $app['id'], + 'app_api' => false, + 'name' => $app['translations'][$currentLanguage]['name'] ?? $app['translations']['en']['name'], + 'description' => $app['translations'][$currentLanguage]['description'] ?? $app['translations']['en']['description'], + 'summary' => $app['translations'][$currentLanguage]['summary'] ?? $app['translations']['en']['summary'], + 'license' => $app['releases'][0]['licenses'], + 'author' => $authors, + 'shipped' => $this->appManager->isShipped($app['id']), + 'version' => $currentVersion, + 'types' => [], + 'documentation' => [ + 'admin' => $app['adminDocs'], + 'user' => $app['userDocs'], + 'developer' => $app['developerDocs'] + ], + 'website' => $app['website'], + 'bugs' => $app['issueTracker'], + 'dependencies' => array_merge( + $nextCloudVersionDependencies, + $phpDependencies + ), + 'level' => ($app['isFeatured'] === true) ? 200 : 100, + 'missingMaxOwnCloudVersion' => false, + 'missingMinOwnCloudVersion' => false, + 'canInstall' => true, + 'screenshot' => isset($app['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/' . base64_encode($app['screenshots'][0]['url']) : '', + 'score' => $app['ratingOverall'], + 'ratingNumOverall' => $app['ratingNumOverall'], + 'ratingNumThresholdReached' => $app['ratingNumOverall'] > 5, + 'removable' => $existsLocally, + 'active' => $this->appManager->isEnabledForUser($app['id']), + 'needsDownload' => !$existsLocally, + 'groups' => $groups, + 'fromAppStore' => true, + 'appstoreData' => $app, + ]; + } + + return $formattedApps; + } + + private function getGroupList(array $groups) { + $groupManager = Server::get(IGroupManager::class); + $groupsList = []; + foreach ($groups as $group) { + $groupItem = $groupManager->get($group); + if ($groupItem instanceof IGroup) { + $groupsList[] = $groupManager->get($group); + } + } + return $groupsList; + } + + private function sortApps($a, $b) { + $a = (string)$a['name']; + $b = (string)$b['name']; + if ($a === $b) { + return 0; + } + return ($a < $b) ? -1 : 1; + } +} diff --git a/apps/appstore/lib/Controller/AppSettingsController.php b/apps/appstore/lib/Controller/AppSettingsController.php deleted file mode 100644 index 4982768328637..0000000000000 --- a/apps/appstore/lib/Controller/AppSettingsController.php +++ /dev/null @@ -1,681 +0,0 @@ -appData = $appDataFactory->get('appstore'); - } - - /** - * @psalm-suppress UndefinedClass AppAPI is shipped since 30.0.1 - * - * @return TemplateResponse - */ - #[NoCSRFRequired] - public function viewApps(): TemplateResponse { - $this->navigationManager->setActiveEntry('core_apps'); - - $this->initialState->provideInitialState('appstoreEnabled', $this->config->getSystemValueBool('appstoreenabled', true)); - $this->initialState->provideInitialState('appstoreBundles', $this->getBundles()); - $this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual')); - $this->initialState->provideInitialState('appstoreUpdateCount', count($this->getAppsWithUpdates())); - - if ($this->appManager->isEnabledForAnyone('app_api')) { - try { - Server::get(ExAppsPageService::class)->provideAppApiState($this->initialState); - } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { - } - } - - $policy = new ContentSecurityPolicy(); - $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); - - $templateResponse = new TemplateResponse('settings', 'settings/empty', ['pageTitle' => $this->l10n->t('Settings')]); - $templateResponse->setContentSecurityPolicy($policy); - - Util::addScript('appstore', 'main'); - - return $templateResponse; - } - - /** - * Get all active entries for the app discover section - */ - #[NoCSRFRequired] - public function getAppDiscoverJSON(): JSONResponse { - $data = $this->discoverFetcher->get(true); - return new JSONResponse(array_values($data)); - } - - /** - * Get a image for the app discover section - this is proxied for privacy and CSP reasons - * - * @param string $image - * @throws \Exception - */ - #[NoCSRFRequired] - public function getAppDiscoverMedia(string $fileName, ILimiter $limiter, IUserSession $session): Response { - $getEtag = $this->discoverFetcher->getETag() ?? date('Y-m'); - $etag = trim($getEtag, '"'); - - $folder = null; - try { - $folder = $this->appData->getFolder('app-discover-cache'); - $this->cleanUpImageCache($folder, $etag); - } catch (\Throwable $e) { - $folder = $this->appData->newFolder('app-discover-cache'); - } - - // Get the current cache folder - try { - $folder = $folder->getFolder($etag); - } catch (NotFoundException $e) { - $folder = $folder->newFolder($etag); - } - - $info = pathinfo($fileName); - $hashName = md5($fileName); - $allFiles = $folder->getDirectoryListing(); - // Try to find the file - $file = array_filter($allFiles, function (ISimpleFile $file) use ($hashName) { - return str_starts_with($file->getName(), $hashName); - }); - // Get the first entry - $file = reset($file); - // If not found request from Web - if ($file === false) { - $user = $session->getUser(); - // this route is not public thus we can assume a user is logged-in - assert($user !== null); - // Register a user request to throttle fetching external data - // this will prevent using the server for DoS of other systems. - $limiter->registerUserRequest( - 'settings-discover-media', - // allow up to 24 media requests per hour - // this should be a sane default when a completely new section is loaded - // keep in mind browsers request all files from a source-set - 24, - 60 * 60, - $user, - ); - - if (!$this->checkCanDownloadMedia($fileName)) { - $this->logger->warning('Tried to load media files for app discover section from untrusted source'); - return new NotFoundResponse(Http::STATUS_BAD_REQUEST); - } - - try { - $client = $this->clientService->newClient(); - $fileResponse = $client->get($fileName); - $contentType = $fileResponse->getHeader('Content-Type'); - $extension = $info['extension'] ?? ''; - $file = $folder->newFile($hashName . '.' . base64_encode($contentType) . '.' . $extension, $fileResponse->getBody()); - } catch (\Throwable $e) { - $this->logger->warning('Could not load media file for app discover section', ['media_src' => $fileName, 'exception' => $e]); - return new NotFoundResponse(); - } - } else { - // File was found so we can get the content type from the file name - $contentType = base64_decode(explode('.', $file->getName())[1] ?? ''); - } - - $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $contentType]); - // cache for 7 days - $response->cacheFor(604800, false, true); - return $response; - } - - private function checkCanDownloadMedia(string $filename): bool { - $urlInfo = parse_url($filename); - if (!isset($urlInfo['host']) || !isset($urlInfo['path'])) { - return false; - } - - // Always allowed hosts - if ($urlInfo['host'] === 'nextcloud.com') { - return true; - } - - // Hosts that need further verification - // Github is only allowed if from our organization - $ALLOWED_HOSTS = ['github.com', 'raw.githubusercontent.com']; - if (!in_array($urlInfo['host'], $ALLOWED_HOSTS)) { - return false; - } - - if (str_starts_with($urlInfo['path'], '/nextcloud/') || str_starts_with($urlInfo['path'], '/nextcloud-gmbh/')) { - return true; - } - - return false; - } - - /** - * Remove orphaned folders from the image cache that do not match the current etag - * @param ISimpleFolder $folder The folder to clear - * @param string $etag The etag (directory name) to keep - */ - private function cleanUpImageCache(ISimpleFolder $folder, string $etag): void { - // Cleanup old cache folders - $allFiles = $folder->getDirectoryListing(); - foreach ($allFiles as $dir) { - try { - if ($dir->getName() !== $etag) { - $dir->delete(); - } - } catch (NotPermittedException $e) { - // ignore folder for now - } - } - } - - private function getAppsWithUpdates() { - $appClass = new \OC_App(); - $apps = $appClass->listAllApps(); - foreach ($apps as $key => $app) { - $newVersion = $this->installer->isUpdateAvailable($app['id']); - if ($newVersion === false) { - unset($apps[$key]); - } - } - return $apps; - } - - private function getBundles() { - $result = []; - $bundles = $this->bundleFetcher->getBundles(); - foreach ($bundles as $bundle) { - $result[] = [ - 'name' => $bundle->getName(), - 'id' => $bundle->getIdentifier(), - 'appIdentifiers' => $bundle->getAppIdentifiers() - ]; - } - return $result; - } - - /** - * Get all available categories - * - * @return JSONResponse - */ - public function listCategories(): JSONResponse { - return new JSONResponse($this->getAllCategories()); - } - - private function getAllCategories() { - $currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2); - - $categories = $this->categoryFetcher->get(); - return array_map(fn ($category) => [ - 'id' => $category['id'], - 'displayName' => $category['translations'][$currentLanguage]['name'] ?? $category['translations']['en']['name'], - ], $categories); - } - - /** - * Convert URL to proxied URL so CSP is no problem - */ - private function createProxyPreviewUrl(string $url): string { - if ($url === '') { - return ''; - } - return 'https://usercontent.apps.nextcloud.com/' . base64_encode($url); - } - - private function fetchApps() { - $appClass = new \OC_App(); - $apps = $appClass->listAllApps(); - foreach ($apps as $app) { - $app['installed'] = true; - - if (isset($app['screenshot'][0])) { - $appScreenshot = $app['screenshot'][0] ?? null; - if (is_array($appScreenshot)) { - // Screenshot with thumbnail - $appScreenshot = $appScreenshot['@value']; - } - - $app['screenshot'] = $this->createProxyPreviewUrl($appScreenshot); - } - $this->allApps[$app['id']] = $app; - } - - $apps = $this->getAppsForCategory(''); - $supportedApps = $appClass->getSupportedApps(); - foreach ($apps as $app) { - $app['appstore'] = true; - if (!array_key_exists($app['id'], $this->allApps)) { - $this->allApps[$app['id']] = $app; - } else { - $this->allApps[$app['id']] = array_merge($app, $this->allApps[$app['id']]); - } - - if (in_array($app['id'], $supportedApps)) { - $this->allApps[$app['id']]['level'] = \OC_App::supportedApp; - } - } - - // add bundle information - $bundles = $this->bundleFetcher->getBundles(); - foreach ($bundles as $bundle) { - foreach ($bundle->getAppIdentifiers() as $identifier) { - foreach ($this->allApps as &$app) { - if ($app['id'] === $identifier) { - $app['bundleIds'][] = $bundle->getIdentifier(); - continue; - } - } - } - } - } - - private function getAllApps() { - return $this->allApps; - } - - /** - * Get all available apps in a category - * - * @return JSONResponse - * @throws \Exception - */ - public function listApps(): JSONResponse { - $this->fetchApps(); - $apps = $this->getAllApps(); - - $dependencyAnalyzer = Server::get(DependencyAnalyzer::class); - - $ignoreMaxApps = $this->config->getSystemValue('app_install_overwrite', []); - if (!is_array($ignoreMaxApps)) { - $this->logger->warning('The value given for app_install_overwrite is not an array. Ignoring...'); - $ignoreMaxApps = []; - } - - // Extend existing app details - $apps = array_map(function (array $appData) use ($dependencyAnalyzer, $ignoreMaxApps) { - if (isset($appData['appstoreData'])) { - $appstoreData = $appData['appstoreData']; - $appData['screenshot'] = $this->createProxyPreviewUrl($appstoreData['screenshots'][0]['url'] ?? ''); - $appData['category'] = $appstoreData['categories']; - $appData['releases'] = $appstoreData['releases']; - } - - $newVersion = $this->installer->isUpdateAvailable($appData['id']); - if ($newVersion) { - $appData['update'] = $newVersion; - } - - // fix groups to be an array - $groups = []; - if (is_string($appData['groups'])) { - $groups = json_decode($appData['groups']); - // ensure 'groups' is an array - if (!is_array($groups)) { - $groups = [$groups]; - } - } - $appData['groups'] = $groups; - $appData['canUnInstall'] = !$appData['active'] && $appData['removable']; - - // fix licence vs license - if (isset($appData['license']) && !isset($appData['licence'])) { - $appData['licence'] = $appData['license']; - } - - $ignoreMax = in_array($appData['id'], $ignoreMaxApps); - - // analyse dependencies - $missing = $dependencyAnalyzer->analyze($appData, $ignoreMax); - $appData['canInstall'] = empty($missing); - $appData['missingDependencies'] = $missing; - - $appData['missingMinOwnCloudVersion'] = !isset($appData['dependencies']['nextcloud']['@attributes']['min-version']); - $appData['missingMaxOwnCloudVersion'] = !isset($appData['dependencies']['nextcloud']['@attributes']['max-version']); - $appData['isCompatible'] = $dependencyAnalyzer->isMarkedCompatible($appData); - - return $appData; - }, $apps); - - usort($apps, [$this, 'sortApps']); - - return new JSONResponse(['apps' => $apps, 'status' => 'success']); - } - - /** - * Get all apps for a category from the app store - * - * @param string $requestedCategory - * @return array - * @throws \Exception - */ - private function getAppsForCategory($requestedCategory = ''): array { - $versionParser = new VersionParser(); - $formattedApps = []; - $apps = $this->appFetcher->get(); - foreach ($apps as $app) { - // Skip all apps not in the requested category - if ($requestedCategory !== '') { - $isInCategory = false; - foreach ($app['categories'] as $category) { - if ($category === $requestedCategory) { - $isInCategory = true; - } - } - if (!$isInCategory) { - continue; - } - } - - if (!isset($app['releases'][0]['rawPlatformVersionSpec'])) { - continue; - } - $nextCloudVersion = $versionParser->getVersion($app['releases'][0]['rawPlatformVersionSpec']); - $nextCloudVersionDependencies = []; - if ($nextCloudVersion->getMinimumVersion() !== '') { - $nextCloudVersionDependencies['nextcloud']['@attributes']['min-version'] = $nextCloudVersion->getMinimumVersion(); - } - if ($nextCloudVersion->getMaximumVersion() !== '') { - $nextCloudVersionDependencies['nextcloud']['@attributes']['max-version'] = $nextCloudVersion->getMaximumVersion(); - } - $phpVersion = $versionParser->getVersion($app['releases'][0]['rawPhpVersionSpec']); - - try { - $this->appManager->getAppPath($app['id']); - $existsLocally = true; - } catch (AppPathNotFoundException) { - $existsLocally = false; - } - - $phpDependencies = []; - if ($phpVersion->getMinimumVersion() !== '') { - $phpDependencies['php']['@attributes']['min-version'] = $phpVersion->getMinimumVersion(); - } - if ($phpVersion->getMaximumVersion() !== '') { - $phpDependencies['php']['@attributes']['max-version'] = $phpVersion->getMaximumVersion(); - } - if (isset($app['releases'][0]['minIntSize'])) { - $phpDependencies['php']['@attributes']['min-int-size'] = $app['releases'][0]['minIntSize']; - } - $authors = ''; - foreach ($app['authors'] as $key => $author) { - $authors .= $author['name']; - if ($key !== count($app['authors']) - 1) { - $authors .= ', '; - } - } - - $currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2); - $enabledValue = $this->config->getAppValue($app['id'], 'enabled', 'no'); - $groups = null; - if ($enabledValue !== 'no' && $enabledValue !== 'yes') { - $groups = $enabledValue; - } - - $currentVersion = ''; - if ($this->appManager->isEnabledForAnyone($app['id'])) { - $currentVersion = $this->appManager->getAppVersion($app['id']); - } else { - $currentVersion = $app['releases'][0]['version']; - } - - $formattedApps[] = [ - 'id' => $app['id'], - 'app_api' => false, - 'name' => $app['translations'][$currentLanguage]['name'] ?? $app['translations']['en']['name'], - 'description' => $app['translations'][$currentLanguage]['description'] ?? $app['translations']['en']['description'], - 'summary' => $app['translations'][$currentLanguage]['summary'] ?? $app['translations']['en']['summary'], - 'license' => $app['releases'][0]['licenses'], - 'author' => $authors, - 'shipped' => $this->appManager->isShipped($app['id']), - 'version' => $currentVersion, - 'default_enable' => '', - 'types' => [], - 'documentation' => [ - 'admin' => $app['adminDocs'], - 'user' => $app['userDocs'], - 'developer' => $app['developerDocs'] - ], - 'website' => $app['website'], - 'bugs' => $app['issueTracker'], - 'detailpage' => $app['website'], - 'dependencies' => array_merge( - $nextCloudVersionDependencies, - $phpDependencies - ), - 'level' => ($app['isFeatured'] === true) ? 200 : 100, - 'missingMaxOwnCloudVersion' => false, - 'missingMinOwnCloudVersion' => false, - 'canInstall' => true, - 'screenshot' => isset($app['screenshots'][0]['url']) ? 'https://usercontent.apps.nextcloud.com/' . base64_encode($app['screenshots'][0]['url']) : '', - 'score' => $app['ratingOverall'], - 'ratingNumOverall' => $app['ratingNumOverall'], - 'ratingNumThresholdReached' => $app['ratingNumOverall'] > 5, - 'removable' => $existsLocally, - 'active' => $this->appManager->isEnabledForUser($app['id']), - 'needsDownload' => !$existsLocally, - 'groups' => $groups, - 'fromAppStore' => true, - 'appstoreData' => $app, - ]; - } - - return $formattedApps; - } - - /** - * @param string $appId - * @param array $groups - * @return JSONResponse - */ - #[PasswordConfirmationRequired] - public function enableApp(string $appId, array $groups = []): JSONResponse { - return $this->enableApps([$appId], $groups); - } - - /** - * Enable one or more apps - * - * apps will be enabled for specific groups only if $groups is defined - * - * @param array $appIds - * @param array $groups - * @return JSONResponse - */ - #[PasswordConfirmationRequired] - public function enableApps(array $appIds, array $groups = []): JSONResponse { - try { - $updateRequired = false; - - foreach ($appIds as $appId) { - $appId = $this->appManager->cleanAppId($appId); - - // Check if app is already downloaded - if (!$this->installer->isDownloaded($appId)) { - $this->installer->downloadApp($appId); - } - - $this->installer->installApp($appId); - - if (count($groups) > 0) { - $this->appManager->enableAppForGroups($appId, $this->getGroupList($groups)); - } else { - $this->appManager->enableApp($appId); - } - $updateRequired = $updateRequired || $this->appManager->isUpgradeRequired($appId); - } - return new JSONResponse(['data' => ['update_required' => $updateRequired]]); - } catch (\Throwable $e) { - $this->logger->error('could not enable apps', ['exception' => $e]); - return new JSONResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_INTERNAL_SERVER_ERROR); - } - } - - private function getGroupList(array $groups) { - $groupManager = Server::get(IGroupManager::class); - $groupsList = []; - foreach ($groups as $group) { - $groupItem = $groupManager->get($group); - if ($groupItem instanceof IGroup) { - $groupsList[] = $groupManager->get($group); - } - } - return $groupsList; - } - - /** - * @param string $appId - * @return JSONResponse - */ - #[PasswordConfirmationRequired] - public function disableApp(string $appId): JSONResponse { - return $this->disableApps([$appId]); - } - - /** - * @param array $appIds - * @return JSONResponse - */ - #[PasswordConfirmationRequired] - public function disableApps(array $appIds): JSONResponse { - try { - foreach ($appIds as $appId) { - $appId = $this->appManager->cleanAppId($appId); - $this->appManager->disableApp($appId); - } - return new JSONResponse([]); - } catch (\Exception $e) { - $this->logger->error('could not disable app', ['exception' => $e]); - return new JSONResponse(['data' => ['message' => $e->getMessage()]], Http::STATUS_INTERNAL_SERVER_ERROR); - } - } - - /** - * @param string $appId - * @return JSONResponse - */ - #[PasswordConfirmationRequired] - public function uninstallApp(string $appId): JSONResponse { - $appId = $this->appManager->cleanAppId($appId); - $result = $this->installer->removeApp($appId); - if ($result !== false) { - // If this app was force enabled, remove the force-enabled-state - $this->appManager->removeOverwriteNextcloudRequirement($appId); - $this->appManager->clearAppsCache(); - return new JSONResponse(['data' => ['appid' => $appId]]); - } - return new JSONResponse(['data' => ['message' => $this->l10n->t('Could not remove app.')]], Http::STATUS_INTERNAL_SERVER_ERROR); - } - - /** - * @param string $appId - * @return JSONResponse - */ - public function updateApp(string $appId): JSONResponse { - $appId = $this->appManager->cleanAppId($appId); - - $this->config->setSystemValue('maintenance', true); - try { - $result = $this->installer->updateAppstoreApp($appId); - $this->config->setSystemValue('maintenance', false); - } catch (\Exception $ex) { - $this->config->setSystemValue('maintenance', false); - return new JSONResponse(['data' => ['message' => $ex->getMessage()]], Http::STATUS_INTERNAL_SERVER_ERROR); - } - - if ($result !== false) { - return new JSONResponse(['data' => ['appid' => $appId]]); - } - return new JSONResponse(['data' => ['message' => $this->l10n->t('Could not update app.')]], Http::STATUS_INTERNAL_SERVER_ERROR); - } - - private function sortApps($a, $b) { - $a = (string)$a['name']; - $b = (string)$b['name']; - if ($a === $b) { - return 0; - } - return ($a < $b) ? -1 : 1; - } - - public function force(string $appId): JSONResponse { - $appId = $this->appManager->cleanAppId($appId); - $this->appManager->overwriteNextcloudRequirement($appId); - return new JSONResponse(); - } -} diff --git a/apps/appstore/lib/Controller/DiscoverController.php b/apps/appstore/lib/Controller/DiscoverController.php new file mode 100644 index 0000000000000..181c621ff8c28 --- /dev/null +++ b/apps/appstore/lib/Controller/DiscoverController.php @@ -0,0 +1,181 @@ +appData = $appDataFactory->get(Application::APP_ID); + } + + /** + * Get all active entries for the app discover section + */ + #[NoCSRFRequired] + #[FrontpageRoute('GET', '/api/v1/discover')] + public function getAppDiscoverJSON(): JSONResponse { + $data = $this->discoverFetcher->get(true); + return new JSONResponse(array_values($data)); + } + + /** + * Get a image for the app discover section - this is proxied for privacy and CSP reasons + * + * @param string $fileName - The image file name + */ + #[NoCSRFRequired] + #[FrontpageRoute('GET', '/api/v1/discover/media')] + public function getAppDiscoverMedia(string $fileName, ILimiter $limiter, IUserSession $session): FileDisplayResponse|NotFoundResponse { + $getEtag = $this->discoverFetcher->getETag() ?? date('Y-m'); + $etag = trim($getEtag, '"'); + + $folder = null; + try { + $folder = $this->appData->getFolder('app-discover-cache'); + $this->cleanUpImageCache($folder, $etag); + } catch (\Throwable $e) { + $folder = $this->appData->newFolder('app-discover-cache'); + } + + // Get the current cache folder + try { + $folder = $folder->getFolder($etag); + } catch (NotFoundException $e) { + $folder = $folder->newFolder($etag); + } + + $info = pathinfo($fileName); + $hashName = md5($fileName); + $allFiles = $folder->getDirectoryListing(); + // Try to find the file + $file = array_filter($allFiles, function (ISimpleFile $file) use ($hashName) { + return str_starts_with($file->getName(), $hashName); + }); + // Get the first entry + $file = reset($file); + // If not found request from Web + if ($file === false) { + $user = $session->getUser(); + // this route is not public thus we can assume a user is logged-in + assert($user !== null); + // Register a user request to throttle fetching external data + // this will prevent using the server for DoS of other systems. + $limiter->registerUserRequest( + 'settings-discover-media', + // allow up to 24 media requests per hour + // this should be a sane default when a completely new section is loaded + // keep in mind browsers request all files from a source-set + 24, + 60 * 60, + $user, + ); + + if (!$this->checkCanDownloadMedia($fileName)) { + $this->logger->warning('Tried to load media files for app discover section from untrusted source'); + return new NotFoundResponse(Http::STATUS_BAD_REQUEST); + } + + try { + $client = $this->clientService->newClient(); + $fileResponse = $client->get($fileName); + $contentType = $fileResponse->getHeader('Content-Type'); + $extension = $info['extension'] ?? ''; + $file = $folder->newFile($hashName . '.' . base64_encode($contentType) . '.' . $extension, $fileResponse->getBody()); + } catch (\Throwable $e) { + $this->logger->warning('Could not load media file for app discover section', ['media_src' => $fileName, 'exception' => $e]); + return new NotFoundResponse(); + } + } else { + // File was found so we can get the content type from the file name + $contentType = base64_decode(explode('.', $file->getName())[1] ?? ''); + } + + $response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $contentType]); + // cache for 7 days + $response->cacheFor(604800, false, true); + return $response; + } + + private function checkCanDownloadMedia(string $filename): bool { + $urlInfo = parse_url($filename); + if (!isset($urlInfo['host']) || !isset($urlInfo['path'])) { + return false; + } + + // Always allowed hosts + if ($urlInfo['host'] === 'nextcloud.com') { + return true; + } + + // Hosts that need further verification + // Github is only allowed if from our organization + $ALLOWED_HOSTS = ['github.com', 'raw.githubusercontent.com']; + if (!in_array($urlInfo['host'], $ALLOWED_HOSTS)) { + return false; + } + + if (str_starts_with($urlInfo['path'], '/nextcloud/') || str_starts_with($urlInfo['path'], '/nextcloud-gmbh/')) { + return true; + } + + return false; + } + + /** + * Remove orphaned folders from the image cache that do not match the current etag + * @param ISimpleFolder $folder The folder to clear + * @param string $etag The etag (directory name) to keep + */ + private function cleanUpImageCache(ISimpleFolder $folder, string $etag): void { + // Cleanup old cache folders + $allFiles = $folder->getDirectoryListing(); + foreach ($allFiles as $dir) { + try { + if ($dir->getName() !== $etag) { + $dir->delete(); + } + } catch (NotPermittedException $e) { + // ignore folder for now + } + } + } +} diff --git a/apps/appstore/lib/Controller/PageController.php b/apps/appstore/lib/Controller/PageController.php new file mode 100644 index 0000000000000..5462494d46a9d --- /dev/null +++ b/apps/appstore/lib/Controller/PageController.php @@ -0,0 +1,110 @@ + ''], root: '')] + #[FrontpageRoute('GET', '/settings/apps/{category}/{id}', defaults: ['category' => '', 'id' => ''], root: '')] + public function viewApps(): TemplateResponse { + $this->navigationManager->setActiveEntry('core_apps'); + + $this->initialState->provideInitialState('appstoreEnabled', $this->config->getSystemValueBool('appstoreenabled', true)); + $this->initialState->provideInitialState('appstoreBundles', $this->getBundles()); + $this->initialState->provideInitialState('appstoreDeveloperDocs', $this->urlGenerator->linkToDocs('developer-manual')); + $this->initialState->provideInitialState('appstoreUpdateCount', count($this->getAppsWithUpdates())); + + if ($this->appManager->isEnabledForAnyone('app_api')) { + try { + Server::get(ExAppsPageService::class)->provideAppApiState($this->initialState); + } catch (\Psr\Container\NotFoundExceptionInterface|\Psr\Container\ContainerExceptionInterface $e) { + } + } + + $policy = new ContentSecurityPolicy(); + $policy->addAllowedImageDomain('https://usercontent.apps.nextcloud.com'); + + $templateResponse = new TemplateResponse(Application::APP_ID, 'empty', ['pageTitle' => $this->l10n->t('App store')]); + $templateResponse->setContentSecurityPolicy($policy); + + Util::addStyle(Application::APP_ID, 'main'); + Util::addScript(Application::APP_ID, 'main'); + + return $templateResponse; + } + + + private function getAppsWithUpdates() { + $appClass = new \OC_App(); + $apps = $appClass->listAllApps(); + foreach ($apps as $key => $app) { + $newVersion = $this->installer->isUpdateAvailable($app['id']); + if ($newVersion === false) { + unset($apps[$key]); + } + } + return $apps; + } + + private function getBundles() { + $result = []; + $bundles = $this->bundleFetcher->getBundles(); + foreach ($bundles as $bundle) { + $result[] = [ + 'name' => $bundle->getName(), + 'id' => $bundle->getIdentifier(), + 'appIdentifiers' => $bundle->getAppIdentifiers() + ]; + } + return $result; + } +} diff --git a/apps/appstore/lib/Search/AppSearch.php b/apps/appstore/lib/Search/AppSearch.php index 5e6c3fe78992b..3efa8dca35316 100644 --- a/apps/appstore/lib/Search/AppSearch.php +++ b/apps/appstore/lib/Search/AppSearch.php @@ -8,6 +8,7 @@ */ namespace OCA\Appstore\Search; +use OCA\Appstore\AppInfo\Application; use OCP\IL10N; use OCP\INavigationManager; use OCP\IUser; @@ -24,7 +25,7 @@ public function __construct( } public function getId(): string { - return 'settings_apps'; + return Application::APP_ID; } public function getName(): string { @@ -32,7 +33,7 @@ public function getName(): string { } public function getOrder(string $route, array $routeParameters): int { - return $route === 'settings.AppSettings.viewApps' ? -50 : 100; + return $route === 'appstore.AppSettings.viewApps' ? -50 : 100; } public function search(IUser $user, ISearchQuery $query): SearchResult { From f38d73d9bab987a94a45ef2a8e6c8ddab2055d89 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 27 Dec 2025 13:52:38 +0100 Subject: [PATCH 5/7] refactor(appstore): migrate daemon selection dialog to Typescript and Vue 3 Signed-off-by: Ferdinand Thiessen --- .../AppAPI/DaemonSelectionEntry.vue | 87 ------------------- .../DaemonSelectionDialog.vue | 65 +++++++------- .../DaemonSelectionDialogList.vue} | 82 ++++++++--------- .../DaemonSelectionDialogListEntry.vue | 69 +++++++++++++++ 4 files changed, 145 insertions(+), 158 deletions(-) delete mode 100644 apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue rename apps/appstore/src/components/{AppAPI => DaemonSelectionDialog}/DaemonSelectionDialog.vue (50%) rename apps/appstore/src/components/{AppAPI/DaemonSelectionList.vue => DaemonSelectionDialog/DaemonSelectionDialogList.vue} (65%) create mode 100644 apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialogListEntry.vue diff --git a/apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue b/apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue deleted file mode 100644 index d89cd9baeff25..0000000000000 --- a/apps/appstore/src/components/AppAPI/DaemonSelectionEntry.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - - diff --git a/apps/appstore/src/components/AppAPI/DaemonSelectionDialog.vue b/apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialog.vue similarity index 50% rename from apps/appstore/src/components/AppAPI/DaemonSelectionDialog.vue rename to apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialog.vue index 354c2a27cd6bc..33425526b796e 100644 --- a/apps/appstore/src/components/AppAPI/DaemonSelectionDialog.vue +++ b/apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialog.vue @@ -2,45 +2,48 @@ - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - SPDX-License-Identifier: AGPL-3.0-or-later --> + + + - - diff --git a/apps/appstore/src/components/AppAPI/DaemonSelectionList.vue b/apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialogList.vue similarity index 65% rename from apps/appstore/src/components/AppAPI/DaemonSelectionList.vue rename to apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialogList.vue index f3d39458ac122..2597378618ca4 100644 --- a/apps/appstore/src/components/AppAPI/DaemonSelectionList.vue +++ b/apps/appstore/src/components/DaemonSelectionDialog/DaemonSelectionDialogList.vue @@ -2,16 +2,54 @@ - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors - SPDX-License-Identifier: AGPL-3.0-or-later --> + + + - - diff --git a/apps/appstore/src/components/AppStoreDiscover/AppType.vue b/apps/appstore/src/components/DiscoverType/DiscoverTypeApp.vue similarity index 57% rename from apps/appstore/src/components/AppStoreDiscover/AppType.vue rename to apps/appstore/src/components/DiscoverType/DiscoverTypeApp.vue index eec761bd65c3c..fb8d1b107d455 100644 --- a/apps/appstore/src/components/AppStoreDiscover/AppType.vue +++ b/apps/appstore/src/components/DiscoverType/DiscoverTypeApp.vue @@ -3,15 +3,8 @@ - SPDX-License-Identifier: AGPL-3.0-or-later --> From d0810b47aa7a366ba4a5a48d84971a9a8e753d17 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 27 Dec 2025 13:58:47 +0100 Subject: [PATCH 7/7] fixup --- apps/appstore/src/AppstoreApp.vue | 48 +++++ apps/appstore/src/{app-types.ts => apps.d.ts} | 32 +++- apps/appstore/src/apps.js | 10 -- .../{AppList => }/AppDaemonBadge.vue | 0 apps/appstore/src/components/AppImage.vue | 61 +++++++ .../{AppList => }/AppLevelBadge.vue | 0 apps/appstore/src/components/AppLink.vue | 83 +++++++++ .../src/components/AppList/AppListItem.vue | 108 +++++++++++ .../src/components/AppList/AppListVersion.vue | 22 +++ .../AppList/{AppItem.vue => AppTable.vue} | 16 +- .../src/components/{AppList => }/AppScore.vue | 0 apps/appstore/src/composables/useAppIcon.ts | 11 +- .../AppstoreCategoryIcons.ts => constants.ts} | 25 ++- apps/appstore/src/constants/AppsConstants.js | 18 -- apps/appstore/src/main.ts | 38 +--- apps/appstore/src/mixins/AppManagement.js | 16 +- apps/appstore/src/router/index.ts | 12 +- apps/appstore/src/router/routes.ts | 15 +- apps/appstore/src/service/api.ts | 51 ++++++ apps/appstore/src/store/api.js | 67 ------- apps/appstore/src/store/apps-store.ts | 92 ---------- apps/appstore/src/store/apps.js | 2 +- apps/appstore/src/store/apps.ts | 112 ++++++++++++ .../src/store/{app-api-store.ts => exApps.ts} | 169 ++++++++---------- apps/appstore/src/store/index.js | 39 ---- apps/appstore/src/store/updates.ts | 63 +++++++ apps/appstore/src/views/App.vue | 16 -- apps/appstore/src/views/AppstoreBrowse.vue | 83 +++++++++ .../{AppStore.vue => AppstoreManage.vue} | 4 +- ...eNavigation.vue => AppstoreNavigation.vue} | 41 ++--- ...ppStoreSidebar.vue => AppstoreSidebar.vue} | 129 +++++++------ package-lock.json | 7 +- package.json | 1 + 33 files changed, 872 insertions(+), 519 deletions(-) create mode 100644 apps/appstore/src/AppstoreApp.vue rename apps/appstore/src/{app-types.ts => apps.d.ts} (78%) delete mode 100644 apps/appstore/src/apps.js rename apps/appstore/src/components/{AppList => }/AppDaemonBadge.vue (100%) create mode 100644 apps/appstore/src/components/AppImage.vue rename apps/appstore/src/components/{AppList => }/AppLevelBadge.vue (100%) create mode 100644 apps/appstore/src/components/AppLink.vue create mode 100644 apps/appstore/src/components/AppList/AppListItem.vue create mode 100644 apps/appstore/src/components/AppList/AppListVersion.vue rename apps/appstore/src/components/AppList/{AppItem.vue => AppTable.vue} (94%) rename apps/appstore/src/components/{AppList => }/AppScore.vue (100%) rename apps/appstore/src/{constants/AppstoreCategoryIcons.ts => constants.ts} (62%) delete mode 100644 apps/appstore/src/constants/AppsConstants.js create mode 100644 apps/appstore/src/service/api.ts delete mode 100644 apps/appstore/src/store/api.js delete mode 100644 apps/appstore/src/store/apps-store.ts create mode 100644 apps/appstore/src/store/apps.ts rename apps/appstore/src/store/{app-api-store.ts => exApps.ts} (65%) delete mode 100644 apps/appstore/src/store/index.js create mode 100644 apps/appstore/src/store/updates.ts delete mode 100644 apps/appstore/src/views/App.vue create mode 100644 apps/appstore/src/views/AppstoreBrowse.vue rename apps/appstore/src/views/{AppStore.vue => AppstoreManage.vue} (93%) rename apps/appstore/src/views/{AppStoreNavigation.vue => AppstoreNavigation.vue} (82%) rename apps/appstore/src/views/{AppStoreSidebar.vue => AppstoreSidebar.vue} (61%) diff --git a/apps/appstore/src/AppstoreApp.vue b/apps/appstore/src/AppstoreApp.vue new file mode 100644 index 0000000000000..e54ccdec7b691 --- /dev/null +++ b/apps/appstore/src/AppstoreApp.vue @@ -0,0 +1,48 @@ + + + + + + + diff --git a/apps/appstore/src/app-types.ts b/apps/appstore/src/apps.d.ts similarity index 78% rename from apps/appstore/src/app-types.ts rename to apps/appstore/src/apps.d.ts index 97dbecf31c4c6..a457ed91b8668 100644 --- a/apps/appstore/src/app-types.ts +++ b/apps/appstore/src/apps.d.ts @@ -27,7 +27,16 @@ export interface IAppstoreAppRelease { } } -export interface IAppstoreApp { +export interface IAppstoreAppData extends Record { + ratingOverall: number + ratingNumOverall: number + ratingRecent: number + ratingNumRecent: number + + releases: IAppstoreAppRelease[] +} + +export interface IAppstoreAppResponse { id: string name: string summary: string @@ -38,10 +47,12 @@ export interface IAppstoreApp { version: string category: string | string[] - preview?: string screenshot?: string - app_api: boolean + score: number + ratingNumThresholdReached: boolean + + app_api: false active: boolean internal: boolean removable: boolean @@ -52,10 +63,14 @@ export interface IAppstoreApp { needsDownload: boolean update?: string - appstoreData: Record + appstoreData?: IAppstoreAppData releases?: IAppstoreAppRelease[] } +export interface IAppstoreApp extends IAppstoreAppResponse { + loading?: boolean +} + export interface IComputeDevice { id: string label: string @@ -81,10 +96,10 @@ export interface IDeployDaemon { export interface IExAppStatus { action: string deploy: number - deploy_start_time: number - error: string + deploy_start_time?: number + error?: string init: number - init_start_time: number + init_start_time?: number type: string } @@ -111,8 +126,9 @@ export interface IAppstoreExAppRelease extends IAppstoreAppRelease { } export interface IAppstoreExApp extends IAppstoreApp { + app_api: true daemon: IDeployDaemon | null | undefined status: IExAppStatus | Record - error: string + error?: string releases: IAppstoreExAppRelease[] } diff --git a/apps/appstore/src/apps.js b/apps/appstore/src/apps.js deleted file mode 100644 index b6431c943b8fc..0000000000000 --- a/apps/appstore/src/apps.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -import rebuildNavigation from './service/rebuild-navigation.js' - -window.OC.Settings = window.OC.Settings || {} -window.OC.Settings.Apps = window.OC.Settings.Apps || { - rebuildNavigation, -} diff --git a/apps/appstore/src/components/AppList/AppDaemonBadge.vue b/apps/appstore/src/components/AppDaemonBadge.vue similarity index 100% rename from apps/appstore/src/components/AppList/AppDaemonBadge.vue rename to apps/appstore/src/components/AppDaemonBadge.vue diff --git a/apps/appstore/src/components/AppImage.vue b/apps/appstore/src/components/AppImage.vue new file mode 100644 index 0000000000000..6912c9f9843d2 --- /dev/null +++ b/apps/appstore/src/components/AppImage.vue @@ -0,0 +1,61 @@ + + + + + diff --git a/apps/appstore/src/components/AppList/AppLevelBadge.vue b/apps/appstore/src/components/AppLevelBadge.vue similarity index 100% rename from apps/appstore/src/components/AppList/AppLevelBadge.vue rename to apps/appstore/src/components/AppLevelBadge.vue diff --git a/apps/appstore/src/components/AppLink.vue b/apps/appstore/src/components/AppLink.vue new file mode 100644 index 0000000000000..107a8dc24814a --- /dev/null +++ b/apps/appstore/src/components/AppLink.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/apps/appstore/src/components/AppList/AppListItem.vue b/apps/appstore/src/components/AppList/AppListItem.vue new file mode 100644 index 0000000000000..860ea051fa815 --- /dev/null +++ b/apps/appstore/src/components/AppList/AppListItem.vue @@ -0,0 +1,108 @@ + + + + + + diff --git a/apps/appstore/src/components/AppList/AppListVersion.vue b/apps/appstore/src/components/AppList/AppListVersion.vue new file mode 100644 index 0000000000000..35a2f0dd27bce --- /dev/null +++ b/apps/appstore/src/components/AppList/AppListVersion.vue @@ -0,0 +1,22 @@ + + + + + diff --git a/apps/appstore/src/components/AppList/AppItem.vue b/apps/appstore/src/components/AppList/AppTable.vue similarity index 94% rename from apps/appstore/src/components/AppList/AppItem.vue rename to apps/appstore/src/components/AppList/AppTable.vue index ba95d924a9c59..fbe2c882ae489 100644 --- a/apps/appstore/src/components/AppList/AppItem.vue +++ b/apps/appstore/src/components/AppList/AppTable.vue @@ -129,7 +129,7 @@ @@ -139,13 +139,12 @@ import { mdiCogOutline } from '@mdi/js' import NcButton from '@nextcloud/vue/components/NcButton' import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' -import DaemonSelectionDialog from '../AppAPI/DaemonSelectionDialog.vue' -import SvgFilterMixin from '../SvgFilterMixin.vue' +import DaemonSelectionDialog from '../DaemonSelectionDialog/DaemonSelectionDialog.vue' import AppLevelBadge from './AppLevelBadge.vue' import AppScore from './AppScore.vue' import AppManagement from '../../mixins/AppManagement.js' -import { useAppApiStore } from '../../store/app-api-store.ts' -import { useAppsStore } from '../../store/apps-store.js' +import { useAppsStore } from '../../store/apps.ts' +import { useAppApiStore } from '../../store/exApps.ts' export default { name: 'AppItem', @@ -157,7 +156,7 @@ export default { DaemonSelectionDialog, }, - mixins: [AppManagement, SvgFilterMixin], + mixins: [AppManagement], props: { app: { type: Object, @@ -281,7 +280,6 @@ export default { diff --git a/apps/appstore/src/views/AppStore.vue b/apps/appstore/src/views/AppstoreManage.vue similarity index 93% rename from apps/appstore/src/views/AppStore.vue rename to apps/appstore/src/views/AppstoreManage.vue index 1e26d394e3f78..c456add5f5022 100644 --- a/apps/appstore/src/views/AppStore.vue +++ b/apps/appstore/src/views/AppstoreManage.vue @@ -33,7 +33,7 @@ import NcEmptyContent from '@nextcloud/vue/components/NcEmptyContent' import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon' import AppList from '../components/AppList.vue' import AppStoreDiscoverSection from '../components/AppStoreDiscover/AppStoreDiscoverSection.vue' -import { APPS_SECTION_ENUM } from '../constants/AppsConstants.js' +import { APPSTORE_CATEGORY_NAMES } from '../constants.ts' import { useAppApiStore } from '../store/app-api-store.ts' import { useAppsStore } from '../store/apps-store.ts' @@ -46,7 +46,7 @@ const appApiStore = useAppApiStore() */ const currentCategory = computed(() => route.params?.category ?? 'discover') -const viewLabel = computed(() => APPS_SECTION_ENUM[currentCategory.value] ?? store.getCategoryById(currentCategory.value)?.displayName) +const viewLabel = computed(() => APPSTORE_CATEGORY_NAMES[currentCategory.value] ?? store.getCategoryById(currentCategory.value)?.displayName) const pageHeading = t('settings', 'App Store') const pageTitle = computed(() => `${viewLabel.value} - ${pageHeading}`) // NcAppContent automatically appends the instance name diff --git a/apps/appstore/src/views/AppStoreNavigation.vue b/apps/appstore/src/views/AppstoreNavigation.vue similarity index 82% rename from apps/appstore/src/views/AppStoreNavigation.vue rename to apps/appstore/src/views/AppstoreNavigation.vue index b33636cdb7bf7..108fa24676150 100644 --- a/apps/appstore/src/views/AppStoreNavigation.vue +++ b/apps/appstore/src/views/AppstoreNavigation.vue @@ -9,8 +9,8 @@ + :to="{ name: 'apps-discover' }" + :name="APPSTORE_CATEGORY_NAMES.discover"> @@ -18,7 +18,7 @@ + :name="APPSTORE_CATEGORY_NAMES.installed"> @@ -26,7 +26,7 @@ + :name="APPSTORE_CATEGORY_NAMES.enabled"> @@ -34,18 +34,18 @@ + :name="APPSTORE_CATEGORY_NAMES.disabled"> + :name="APPSTORE_CATEGORY_NAMES.updates">