Skip to content

Commit 82d9c6d

Browse files
committed
Use @nextcloud/capabilities to obtain share api defaults
- Remove redundant initial state added - Call `getCapabilities()` in share config file. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
1 parent 38bef81 commit 82d9c6d

72 files changed

Lines changed: 138 additions & 234 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apps/files_sharing/lib/Listener/LoadSidebarListener.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,5 @@ public function handle(Event $event): void
5151
}
5252

5353
Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
54-
55-
$shareConfig = [
56-
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
57-
'defaultPermissions' => $this->shareManager->shareApiDefaultPermissions(),
58-
];
59-
60-
$this->initialState->provideInitialState('shareConfig', $shareConfig);
6154
}
6255
}

apps/files_sharing/src/services/ConfigService.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2222
*
2323
*/
24-
25-
import { loadState } from '@nextcloud/initial-state'
24+
import { getCapabilities } from '@nextcloud/capabilities'
2625

2726
export default class Config {
2827

2928
constructor() {
30-
this._shareConfig = loadState('files_sharing', 'shareConfig', {})
29+
this._capabilities = getCapabilities()
3130
}
3231

3332
/**
@@ -38,7 +37,7 @@ export default class Config {
3837
* @memberof Config
3938
*/
4039
get defaultPermissions() {
41-
return this._shareConfig.defaultPermissions
40+
return this._capabilities.files_sharing?.default_permissions
4241
}
4342

4443
/**
@@ -49,7 +48,7 @@ export default class Config {
4948
* @memberof Config
5049
*/
5150
get isPublicUploadEnabled() {
52-
return this._shareConfig.allowPublicUploads
51+
return this._capabilities.files_sharing?.public.upload
5352
}
5453

5554
/**
@@ -224,11 +223,10 @@ export default class Config {
224223
* @memberof Config
225224
*/
226225
get isMailShareAllowed() {
227-
const capabilities = OC.getCapabilities()
228226
// eslint-disable-next-line camelcase
229-
return capabilities?.files_sharing?.sharebymail !== undefined
227+
return this._capabilities?.files_sharing?.sharebymail !== undefined
230228
// eslint-disable-next-line camelcase
231-
&& capabilities?.files_sharing?.public?.enabled === true
229+
&& this._capabilities?.files_sharing?.public?.enabled === true
232230
}
233231

234232
/**
@@ -283,7 +281,7 @@ export default class Config {
283281
* @memberof Config
284282
*/
285283
get isPasswordForMailSharesRequired() {
286-
return (OC.getCapabilities().files_sharing.sharebymail === undefined) ? false : OC.getCapabilities().files_sharing.sharebymail.password.enforced
284+
return (this._capabilities.files_sharing.sharebymail === undefined) ? false : this._capabilities.files_sharing.sharebymail.password.enforced
287285
}
288286

289287
/**
@@ -292,7 +290,7 @@ export default class Config {
292290
* @memberof Config
293291
*/
294292
get shouldAlwaysShowUnique() {
295-
return (OC.getCapabilities().files_sharing?.sharee?.always_show_unique === true)
293+
return (this._capabilities.files_sharing?.sharee?.always_show_unique === true)
296294
}
297295

298296
/**
@@ -337,8 +335,7 @@ export default class Config {
337335
* @memberof Config
338336
*/
339337
get passwordPolicy() {
340-
const capabilities = OC.getCapabilities()
341-
return capabilities.password_policy ? capabilities.password_policy : {}
338+
return this._capabilities.password_policy ? this._capabilities.password_policy : {}
342339
}
343340

344341
}

dist/6799-6799.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-app.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-app.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.js.LICENSE.txt

Lines changed: 26 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ object-assign
473473
* Includes: widget.js, position.js, data.js, disable-selection.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
474474
* Copyright jQuery Foundation and other contributors; Licensed MIT */
475475

476+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
477+
476478
/**
477479
*
478480
*
@@ -481,6 +483,28 @@ object-assign
481483
*
482484
*/
483485

486+
/**
487+
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
488+
*
489+
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
490+
*
491+
* @license AGPL-3.0-or-later
492+
*
493+
* This program is free software: you can redistribute it and/or modify
494+
* it under the terms of the GNU Affero General Public License as
495+
* published by the Free Software Foundation, either version 3 of the
496+
* License, or (at your option) any later version.
497+
*
498+
* This program is distributed in the hope that it will be useful,
499+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
500+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
501+
* GNU Affero General Public License for more details.
502+
*
503+
* You should have received a copy of the GNU Affero General Public License
504+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
505+
*
506+
*/
507+
484508
/**
485509
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
486510
*
@@ -860,117 +884,7 @@ object-assign
860884
*/
861885

862886
/**
863-
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
864-
*
865-
* @author John Molakvoæ <skjnldsv@protonmail.com>
866-
*
867-
* @license AGPL-3.0-or-later
868-
*
869-
* This program is free software: you can redistribute it and/or modify
870-
* it under the terms of the GNU Affero General Public License as
871-
* published by the Free Software Foundation, either version 3 of the
872-
* License, or (at your option) any later version.
873-
*
874-
* This program is distributed in the hope that it will be useful,
875-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
876-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
877-
* GNU Affero General Public License for more details.
878-
*
879-
* You should have received a copy of the GNU Affero General Public License
880-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
881-
*
882-
*/
883-
884-
/**
885-
* @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
886-
*
887-
* @author Ferdinand Thiessen <opensource@fthiessen.de>
888-
*
889-
* @license AGPL-3.0-or-later
890-
*
891-
* This program is free software: you can redistribute it and/or modify
892-
* it under the terms of the GNU Affero General Public License as
893-
* published by the Free Software Foundation, either version 3 of the
894-
* License, or (at your option) any later version.
895-
*
896-
* This program is distributed in the hope that it will be useful,
897-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
898-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
899-
* GNU Affero General Public License for more details.
900-
*
901-
* You should have received a copy of the GNU Affero General Public License
902-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
903-
*
904-
*/
905-
906-
/**
907-
* @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
908-
*
909-
* @author Ferdinand Thiessen <opensource@fthiessen.de>
910-
*
911-
* @license AGPL-3.0-or-later
912-
*
913-
* This program is free software: you can redistribute it and/or modify
914-
* it under the terms of the GNU Affero General Public License as
915-
* published by the Free Software Foundation, either version 3 of the
916-
* License, or (at your option) any later version.
917-
*
918-
* This program is distributed in the hope that it will be useful,
919-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
920-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
921-
* GNU Affero General Public License for more details.
922-
*
923-
* You should have received a copy of the GNU Affero General Public License
924-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
925-
*/
926-
927-
/**
928-
* @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
929-
*
930-
* @author Ferdinand Thiessen <opensource@fthiessen.de>
931-
*
932-
* @license AGPL-3.0-or-later
933-
*
934-
* This program is free software: you can redistribute it and/or modify
935-
* it under the terms of the GNU Affero General Public License as
936-
* published by the Free Software Foundation, either version 3 of the
937-
* License, or (at your option) any later version.
938-
*
939-
* This program is distributed in the hope that it will be useful,
940-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
941-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
942-
* GNU Affero General Public License for more details.
943-
*
944-
* You should have received a copy of the GNU Affero General Public License
945-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
946-
*
947-
*/
948-
949-
/**
950-
* @copyright Copyright (c) 2023 Ferdinand Thiessen <opensource@fthiessen.de>
951-
*
952-
* @author Ferdinand Thiessen <opensource@fthiessen.de>
953-
* @author John Molakvoæ <skjnldsv@protonmail.com>
954-
*
955-
* @license AGPL-3.0-or-later
956-
*
957-
* This program is free software: you can redistribute it and/or modify
958-
* it under the terms of the GNU Affero General Public License as
959-
* published by the Free Software Foundation, either version 3 of the
960-
* License, or (at your option) any later version.
961-
*
962-
* This program is distributed in the hope that it will be useful,
963-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
964-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
965-
* GNU Affero General Public License for more details.
966-
*
967-
* You should have received a copy of the GNU Affero General Public License
968-
* along with this program. If not, see <http://www.gnu.org/licenses/>.
969-
*
970-
*/
971-
972-
/**
973-
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
887+
* @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
974888
*
975889
* @author John Molakvoæ <skjnldsv@protonmail.com>
976890
*
@@ -992,10 +906,9 @@ object-assign
992906
*/
993907

994908
/**
995-
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
909+
* @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
996910
*
997911
* @author John Molakvoæ <skjnldsv@protonmail.com>
998-
* @author Ferdinand Thiessen <opensource@fthiessen.de>
999912
*
1000913
* @license AGPL-3.0-or-later
1001914
*

0 commit comments

Comments
 (0)