From 45ee319a4e539c5aaa926feb52352a99afd2758e Mon Sep 17 00:00:00 2001 From: Ruben van der Linde Date: Wed, 18 Mar 2026 10:38:47 +0100 Subject: [PATCH 01/16] feat: Add OpenRegister dependency check and enforce scoped CSS Show NcEmptyContent empty state when OpenRegister is not installed, with install button for admins. Add ESLint rule enforcing scoped styles in Vue files, move global CSS to src/assets/app.css. --- eslint.config.js | 1 + lib/Controller/SettingsController.php | 14 +++- src/App.vue | 106 +++++++++++++++++++++----- src/assets/app.css | 15 ++++ src/main.js | 1 + src/store/modules/settings.js | 21 +++++ 6 files changed, 140 insertions(+), 18 deletions(-) create mode 100644 src/assets/app.css diff --git a/eslint.config.js b/eslint.config.js index 58c388f0..7498b39b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -53,6 +53,7 @@ module.exports = defineConfig([ rules: { 'jsdoc/require-jsdoc': 'off', 'vue/first-attribute-linebreak': 'off', + 'vue/enforce-style-attribute': ['error', { allow: ['scoped'] }], '@typescript-eslint/no-explicit-any': 'off', 'n/no-missing-import': 'off', }, diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index a2d9a553..d1421154 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -26,6 +26,8 @@ use OCP\IRequest; use Psr\Container\ContainerInterface; use OCP\App\IAppManager; +use OCP\IGroupManager; +use OCP\IUserSession; use OCA\SoftwareCatalog\Service\SettingsService; use OCA\SoftwareCatalog\Service\OrganizationSyncService; use OCA\SoftwareCatalog\Service\ArchiMateService; @@ -54,6 +56,8 @@ class SettingsController extends Controller * @param IAppConfig $config The app configuration. * @param ContainerInterface $container The container. * @param IAppManager $appManager The app manager. + * @param IGroupManager $groupManager The group manager. + * @param IUserSession $userSession The user session. * @param SettingsService $settingsService The settings service. * @param OrganizationSyncService $organizationSyncService The organization sync service. * @param ArchiMateService $archiMateService The ArchiMate import/export service. @@ -66,6 +70,8 @@ public function __construct( private readonly IAppConfig $config, private readonly ContainerInterface $container, private readonly IAppManager $appManager, + private readonly IGroupManager $groupManager, + private readonly IUserSession $userSession, private readonly SettingsService $settingsService, private readonly OrganizationSyncService $organizationSyncService, private readonly ArchiMateService $archiMateService, @@ -124,8 +130,14 @@ public function getConfigurationService(): ?\OCA\OpenRegister\Service\Configurat public function index(): JSONResponse { try { + $user = $this->userSession->getUser(); + $isAdmin = $user !== null && $this->groupManager->isAdmin($user->getUID()); + // Delegate all business logic to service. - $data = $this->settingsService->getAllSettings(); + $data = $this->settingsService->getAllSettings(); + $data['openRegisters'] = in_array(needle: 'openregister', haystack: $this->appManager->getInstalledApps()); + $data['isAdmin'] = $isAdmin; + return new JSONResponse($data); } catch (\Exception $e) { $this->logger->error( diff --git a/src/App.vue b/src/App.vue index 66e12040..2f6a7877 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,38 +1,76 @@ + + diff --git a/src/assets/app.css b/src/assets/app.css new file mode 100644 index 00000000..0c555173 --- /dev/null +++ b/src/assets/app.css @@ -0,0 +1,15 @@ +/** + * Global (unscoped) styles for Software Catalogus. + * + * Styles that must be unscoped (e.g. overriding library components) belong here + * instead of in Vue