aboutsummaryrefslogtreecommitdiffstats
path: root/apps/theming/lib/Controller
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2023-09-25 14:21:23 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2023-10-20 00:24:17 +0200
commite9d4036389097708a6075d8882c32b1c7db4fb0f (patch)
tree97216c9a992ca14660193d5b0926fc72997bd044 /apps/theming/lib/Controller
parent363d9ebb130862d5fc5617e94b1c369caf02553f (diff)
downloadnextcloud-server-e9d4036389097708a6075d8882c32b1c7db4fb0f.tar.gz
nextcloud-server-e9d4036389097708a6075d8882c32b1c7db4fb0f.zip
feat(theming): Allow to configure default apps and app order in frontend settings
* Also add API for setting the value using ajax. * Add cypress tests for app order and defaul apps Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/theming/lib/Controller')
-rw-r--r--apps/theming/lib/Controller/ThemingController.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php
index 1d6d5100a46..e8f6ec6289b 100644
--- a/apps/theming/lib/Controller/ThemingController.php
+++ b/apps/theming/lib/Controller/ThemingController.php
@@ -38,6 +38,7 @@
*/
namespace OCA\Theming\Controller;
+use InvalidArgumentException;
use OCA\Theming\ImageManager;
use OCA\Theming\Service\ThemesService;
use OCA\Theming\ThemingDefaults;
@@ -181,6 +182,47 @@ class ThemingController extends Controller {
}
/**
+ * @AuthorizedAdminSetting(settings=OCA\Theming\Settings\Admin)
+ * @param string $setting
+ * @param mixed $value
+ * @return DataResponse
+ * @throws NotPermittedException
+ */
+ public function updateAppMenu($setting, $value) {
+ $error = null;
+ switch ($setting) {
+ case 'defaultApps':
+ if (is_array($value)) {
+ try {
+ $this->appManager->setDefaultApps($value);
+ } catch (InvalidArgumentException $e) {
+ $error = $this->l10n->t('Invalid app given');
+ }
+ } else {
+ $error = $this->l10n->t('Invalid type for setting "defaultApp" given');
+ }
+ break;
+ default:
+ $error = $this->l10n->t('Invalid setting key');
+ }
+ if ($error !== null) {
+ return new DataResponse([
+ 'data' => [
+ 'message' => $error,
+ ],
+ 'status' => 'error'
+ ], Http::STATUS_BAD_REQUEST);
+ }
+
+ return new DataResponse([
+ 'data' => [
+ 'message' => $this->l10n->t('Saved'),
+ ],
+ 'status' => 'success'
+ ]);
+ }
+
+ /**
* Check that a string is a valid http/https url
*/
private function isValidUrl(string $url): bool {
@@ -299,6 +341,7 @@ class ThemingController extends Controller {
*/
public function undoAll(): DataResponse {
$this->themingDefaults->undoAll();
+ $this->appManager->setDefaultApps([]);
return new DataResponse(
[