Skip to content

Commit

Permalink
Use @nextcloud/capabilities to obtain share api defaults
Browse files Browse the repository at this point in the history
- Remove redundant initial state added

- Call `getCapabilities()` in share config file.

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Feb 4, 2024
1 parent 73f0f7c commit 0803909
Show file tree
Hide file tree
Showing 74 changed files with 140 additions and 236 deletions.
7 changes: 0 additions & 7 deletions apps/files_sharing/lib/Listener/LoadSidebarListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,5 @@ public function handle(Event $event): void
}

Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');

$shareConfig = [
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
'defaultPermissions' => $this->shareManager->shareApiDefaultPermissions(),
];

$this->initialState->provideInitialState('shareConfig', $shareConfig);
}
}
21 changes: 9 additions & 12 deletions apps/files_sharing/src/services/ConfigService.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { loadState } from '@nextcloud/initial-state'
import { getCapabilities } from '@nextcloud/capabilities'

export default class Config {

constructor() {
this._shareConfig = loadState('files_sharing', 'shareConfig', {})
this._capabilities = getCapabilities()
}

/**
Expand All @@ -38,7 +37,7 @@ export default class Config {
* @memberof Config
*/
get defaultPermissions() {
return this._shareConfig.defaultPermissions
return this._capabilities.files_sharing?.default_permissions
}

/**
Expand All @@ -49,7 +48,7 @@ export default class Config {
* @memberof Config
*/
get isPublicUploadEnabled() {
return this._shareConfig.allowPublicUploads
return this._capabilities.files_sharing?.public.upload
}

/**
Expand Down Expand Up @@ -224,11 +223,10 @@ export default class Config {
* @memberof Config
*/
get isMailShareAllowed() {
const capabilities = OC.getCapabilities()
// eslint-disable-next-line camelcase
return capabilities?.files_sharing?.sharebymail !== undefined
return this._capabilities?.files_sharing?.sharebymail !== undefined
// eslint-disable-next-line camelcase
&& capabilities?.files_sharing?.public?.enabled === true
&& this._capabilities?.files_sharing?.public?.enabled === true
}

/**
Expand Down Expand Up @@ -283,7 +281,7 @@ export default class Config {
* @memberof Config
*/
get isPasswordForMailSharesRequired() {
return (OC.getCapabilities().files_sharing.sharebymail === undefined) ? false : OC.getCapabilities().files_sharing.sharebymail.password.enforced
return (this._capabilities.files_sharing.sharebymail === undefined) ? false : this._capabilities.files_sharing.sharebymail.password.enforced
}

/**
Expand All @@ -292,7 +290,7 @@ export default class Config {
* @memberof Config
*/
get shouldAlwaysShowUnique() {
return (OC.getCapabilities().files_sharing?.sharee?.always_show_unique === true)
return (this._capabilities.files_sharing?.sharee?.always_show_unique === true)
}

/**
Expand Down Expand Up @@ -337,8 +335,7 @@ export default class Config {
* @memberof Config
*/
get passwordPolicy() {
const capabilities = OC.getCapabilities()
return capabilities.password_policy ? capabilities.password_policy : {}
return this._capabilities.password_policy ? this._capabilities.password_policy : {}
}

}
2 changes: 1 addition & 1 deletion core/css/server.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/css/server.css.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/6799-6799.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

139 changes: 26 additions & 113 deletions dist/core-common.js.LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ object-assign
* 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
* Copyright jQuery Foundation and other contributors; Licensed MIT */

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */

/**
*
*
Expand All @@ -481,6 +483,28 @@ object-assign
*
*/

/**
* @copyright 2019 Christoph Wurst <[email protected]>
*
* @author Christoph Wurst <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright 2019 Christoph Wurst <[email protected]>
*
Expand Down Expand Up @@ -860,117 +884,7 @@ object-assign
*/

/**
* @copyright Copyright (c) 2022 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
*
* @author Ferdinand Thiessen <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
*
* @author Ferdinand Thiessen <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
*
* @author Ferdinand Thiessen <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2023 Ferdinand Thiessen <[email protected]>
*
* @author Ferdinand Thiessen <[email protected]>
* @author John Molakvoæ <[email protected]>
*
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

/**
* @copyright Copyright (c) 2023 John Molakvoæ <[email protected]>
* @copyright Copyright (c) 2021 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
*
Expand All @@ -992,10 +906,9 @@ object-assign
*/

/**
* @copyright Copyright (c) 2023 John Molakvoæ <[email protected]>
* @copyright Copyright (c) 2022 John Molakvoæ <[email protected]>
*
* @author John Molakvoæ <[email protected]>
* @author Ferdinand Thiessen <[email protected]>
*
* @license AGPL-3.0-or-later
*
Expand Down
2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-profile.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-profile.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unified-search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-unified-search.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-unsupported-browser-redirect.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/core-unsupported-browser-redirect.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 0803909

Please sign in to comment.