3333use OCP \User \Backend \ICountUsersBackend ;
3434use OCA \UpdateNotification \UpdateChecker ;
3535use OCP \AppFramework \Http \TemplateResponse ;
36+ use OCP \AppFramework \Services \IInitialState ;
3637use OCP \IConfig ;
3738use OCP \IDateTimeFormatter ;
3839use OCP \IGroupManager ;
4445use Psr \Log \LoggerInterface ;
4546
4647class Admin implements ISettings {
47- /** @var IConfig */
48- private $ config ;
49- /** @var UpdateChecker */
50- private $ updateChecker ;
51- /** @var IGroupManager */
52- private $ groupManager ;
53- /** @var IDateTimeFormatter */
54- private $ dateTimeFormatter ;
55- /** @var IFactory */
56- private $ l10nFactory ;
57- /** @var IRegistry */
58- private $ subscriptionRegistry ;
59- /** @var IUserManager */
60- private $ userManager ;
61- /** @var LoggerInterface */
62- private $ logger ;
48+ private IConfig $ config ;
49+ private UpdateChecker $ updateChecker ;
50+ private IGroupManager $ groupManager ;
51+ private IDateTimeFormatter $ dateTimeFormatter ;
52+ private IFactory $ l10nFactory ;
53+ private IRegistry $ subscriptionRegistry ;
54+ private IUserManager $ userManager ;
55+ private LoggerInterface $ logger ;
56+ private IInitialState $ initialState ;
6357
6458 public function __construct (
6559 IConfig $ config ,
@@ -69,7 +63,8 @@ public function __construct(
6963 IFactory $ l10nFactory ,
7064 IRegistry $ subscriptionRegistry ,
7165 IUserManager $ userManager ,
72- LoggerInterface $ logger
66+ LoggerInterface $ logger ,
67+ IInitialState $ initialState
7368 ) {
7469 $ this ->config = $ config ;
7570 $ this ->updateChecker = $ updateChecker ;
@@ -79,11 +74,9 @@ public function __construct(
7974 $ this ->subscriptionRegistry = $ subscriptionRegistry ;
8075 $ this ->userManager = $ userManager ;
8176 $ this ->logger = $ logger ;
77+ $ this ->initialState = $ initialState ;
8278 }
8379
84- /**
85- * @return TemplateResponse
86- */
8780 public function getForm (): TemplateResponse {
8881 $ lastUpdateCheckTimestamp = $ this ->config ->getAppValue ('core ' , 'lastupdatedat ' );
8982 $ lastUpdateCheck = $ this ->dateTimeFormatter ->formatDateTime ($ lastUpdateCheckTimestamp );
@@ -131,12 +124,9 @@ public function getForm(): TemplateResponse {
131124 'notifyGroups ' => $ this ->getSelectedGroups ($ notifyGroups ),
132125 'hasValidSubscription ' => $ hasValidSubscription ,
133126 ];
127+ $ this ->initialState ->provideInitialState ('data ' , $ params );
134128
135- $ params = [
136- 'json ' => json_encode ($ params ),
137- ];
138-
139- return new TemplateResponse ('updatenotification ' , 'admin ' , $ params , '' );
129+ return new TemplateResponse ('updatenotification ' , 'admin ' , [], '' );
140130 }
141131
142132 protected function filterChanges (array $ changes ): array {
@@ -162,8 +152,8 @@ protected function filterChanges(array $changes): array {
162152 }
163153
164154 /**
165- * @param array $groupIds
166- * @return array
155+ * @param list<string> $groupIds
156+ * @return array{id: string, displayname: string}
167157 */
168158 protected function getSelectedGroups (array $ groupIds ): array {
169159 $ result = [];
@@ -174,26 +164,16 @@ protected function getSelectedGroups(array $groupIds): array {
174164 continue ;
175165 }
176166
177- $ result [] = ['value ' => $ group ->getGID (), 'label ' => $ group ->getDisplayName ()];
167+ $ result [] = ['id ' => $ group ->getGID (), 'displayname ' => $ group ->getDisplayName ()];
178168 }
179169
180170 return $ result ;
181171 }
182172
183- /**
184- * @return string the section ID, e.g. 'sharing'
185- */
186173 public function getSection (): string {
187174 return 'overview ' ;
188175 }
189176
190- /**
191- * @return int whether the form should be rather on the top or bottom of
192- * the admin section. The forms are arranged in ascending order of the
193- * priority values. It is required to return a value between 0 and 100.
194- *
195- * E.g.: 70
196- */
197177 public function getPriority (): int {
198178 return 11 ;
199179 }
0 commit comments