Skip to content

Commit ecfb95a

Browse files
committed
fix(theming): deprecate OCA.Theming and move to capabilities
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent a1c72a2 commit ecfb95a

File tree

5 files changed

+211
-19
lines changed

5 files changed

+211
-19
lines changed

apps/theming/lib/Capabilities.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
use OCA\Theming\AppInfo\Application;
1010
use OCA\Theming\Service\BackgroundService;
11+
use OCA\Theming\Service\ThemesService;
1112
use OCP\Capabilities\IPublicCapability;
1213
use OCP\IConfig;
1314
use OCP\IURLGenerator;
@@ -21,18 +22,13 @@
2122
*/
2223
class Capabilities implements IPublicCapability {
2324

24-
/**
25-
* @param ThemingDefaults $theming
26-
* @param Util $util
27-
* @param IURLGenerator $url
28-
* @param IConfig $config
29-
*/
3025
public function __construct(
3126
protected ThemingDefaults $theming,
3227
protected Util $util,
3328
protected IURLGenerator $url,
3429
protected IConfig $config,
3530
protected IUserSession $userSession,
31+
protected ThemesService $themesService,
3632
) {
3733
}
3834

@@ -44,6 +40,8 @@ public function __construct(
4440
* name: string,
4541
* productName: string,
4642
* url: string,
43+
* imprintUrl: string,
44+
* privacyUrl: string,
4745
* slogan: string,
4846
* color: string,
4947
* color-text: string,
@@ -57,6 +55,13 @@ public function __construct(
5755
* background-default: bool,
5856
* logoheader: string,
5957
* favicon: string,
58+
* primaryColor: string,
59+
* backgroundColor: string,
60+
* defaultPrimaryColor: string,
61+
* defaultBackgroundColor: string,
62+
* inverted: bool,
63+
* cacheBuster: string,
64+
* enabledThemes: list<string>,
6065
* },
6166
* }
6267
*/
@@ -98,6 +103,8 @@ public function getCapabilities() {
98103
'name' => $this->theming->getName(),
99104
'productName' => $this->theming->getProductName(),
100105
'url' => $this->theming->getBaseUrl(),
106+
'imprintUrl' => $this->theming->getImprintUrl(),
107+
'privacyUrl' => $this->theming->getPrivacyUrl(),
101108
'slogan' => $this->theming->getSlogan(),
102109
'color' => $color,
103110
'color-text' => $colorText,
@@ -111,6 +118,13 @@ public function getCapabilities() {
111118
'background-default' => !$this->util->isBackgroundThemed(),
112119
'logoheader' => $this->url->getAbsoluteURL($this->theming->getLogo()),
113120
'favicon' => $this->url->getAbsoluteURL($this->theming->getLogo()),
121+
'primaryColor' => $color,
122+
'backgroundColor' => $backgroundColor,
123+
'defaultPrimaryColor' => $this->theming->getDefaultColorPrimary(),
124+
'defaultBackgroundColor' => $this->theming->getDefaultColorBackground(),
125+
'inverted' => $this->util->invertTextColor($color),
126+
'cacheBuster' => $this->util->getCacheBuster(),
127+
'enabledThemes' => $this->themesService->getEnabledThemes(),
114128
],
115129
];
116130
}

apps/theming/lib/Listener/BeforeTemplateRenderedListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function __construct(
3737
public function handle(Event $event): void {
3838
$this->initialState->provideLazyInitialState(
3939
'data',
40+
// @psalm-suppress DeprecatedClass - deprecated since 34
4041
fn () => $this->container->get(JSDataService::class),
4142
);
4243

apps/theming/lib/Service/JSDataService.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use OCA\Theming\ThemingDefaults;
1212
use OCA\Theming\Util;
1313

14+
/**
15+
* @deprecated since Nextcloud 32 — all properties are now exposed via Capabilities
16+
*/
1417
class JSDataService implements \JsonSerializable {
1518

1619
public function __construct(
@@ -40,10 +43,6 @@ public function jsonSerialize(): array {
4043

4144
'cacheBuster' => $this->util->getCacheBuster(),
4245
'enabledThemes' => $this->themesService->getEnabledThemes(),
43-
44-
// deprecated use primaryColor
45-
'color' => $this->themingDefaults->getColorPrimary(),
46-
'' => 'color is deprecated since Nextcloud 29, use primaryColor instead'
4746
];
4847
}
4948
}

apps/theming/openapi.json

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@
8181
"name",
8282
"productName",
8383
"url",
84+
"imprintUrl",
85+
"privacyUrl",
8486
"slogan",
8587
"color",
8688
"color-text",
@@ -93,7 +95,14 @@
9395
"background-plain",
9496
"background-default",
9597
"logoheader",
96-
"favicon"
98+
"favicon",
99+
"primaryColor",
100+
"backgroundColor",
101+
"defaultPrimaryColor",
102+
"defaultBackgroundColor",
103+
"inverted",
104+
"cacheBuster",
105+
"enabledThemes"
97106
],
98107
"properties": {
99108
"name": {
@@ -105,6 +114,12 @@
105114
"url": {
106115
"type": "string"
107116
},
117+
"imprintUrl": {
118+
"type": "string"
119+
},
120+
"privacyUrl": {
121+
"type": "string"
122+
},
108123
"slogan": {
109124
"type": "string"
110125
},
@@ -143,6 +158,30 @@
143158
},
144159
"favicon": {
145160
"type": "string"
161+
},
162+
"primaryColor": {
163+
"type": "string"
164+
},
165+
"backgroundColor": {
166+
"type": "string"
167+
},
168+
"defaultPrimaryColor": {
169+
"type": "string"
170+
},
171+
"defaultBackgroundColor": {
172+
"type": "string"
173+
},
174+
"inverted": {
175+
"type": "boolean"
176+
},
177+
"cacheBuster": {
178+
"type": "string"
179+
},
180+
"enabledThemes": {
181+
"type": "array",
182+
"items": {
183+
"type": "string"
184+
}
146185
}
147186
}
148187
}

0 commit comments

Comments
 (0)