mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #43024 from nextcloud/42835-use-default-perms-4new-shares
Consider admin defaults when creating shares
This commit is contained in:
commit
c5c48404df
10 changed files with 47 additions and 36 deletions
|
|
@ -48,11 +48,5 @@ class LoadSidebarListener implements IEventListener {
|
|||
}
|
||||
|
||||
Util::addScript(Application::APP_ID, 'files_sharing_tab', 'files');
|
||||
|
||||
$shareConfig = [
|
||||
'allowPublicUploads' => $this->shareManager->shareApiLinkAllowPublicUpload(),
|
||||
];
|
||||
|
||||
$this->initialState->provideInitialState('shareConfig', $shareConfig);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,23 @@
|
|||
* 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()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default share permissions, if any
|
||||
*
|
||||
* @return {boolean}
|
||||
* @readonly
|
||||
* @memberof Config
|
||||
*/
|
||||
get defaultPermissions() {
|
||||
return this._capabilities.files_sharing?.default_permissions
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -39,7 +48,7 @@ export default class Config {
|
|||
* @memberof Config
|
||||
*/
|
||||
get isPublicUploadEnabled() {
|
||||
return this._shareConfig.allowPublicUploads
|
||||
return this._capabilities.files_sharing?.public.upload
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -214,11 +223,10 @@ export default class Config {
|
|||
* @memberof Config
|
||||
*/
|
||||
get isMailShareAllowed() {
|
||||
const capabilities = 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
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -273,7 +281,7 @@ export default class Config {
|
|||
* @memberof Config
|
||||
*/
|
||||
get isPasswordForMailSharesRequired() {
|
||||
return (getCapabilities().files_sharing.sharebymail === undefined) ? false : getCapabilities().files_sharing.sharebymail.password.enforced
|
||||
return (this._capabilities.files_sharing.sharebymail === undefined) ? false : this._capabilities.files_sharing.sharebymail.password.enforced
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -282,7 +290,7 @@ export default class Config {
|
|||
* @memberof Config
|
||||
*/
|
||||
get shouldAlwaysShowUnique() {
|
||||
return (getCapabilities().files_sharing?.sharee?.always_show_unique === true)
|
||||
return (this._capabilities.files_sharing?.sharee?.always_show_unique === true)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -327,8 +335,7 @@ export default class Config {
|
|||
* @memberof Config
|
||||
*/
|
||||
get passwordPolicy() {
|
||||
const capabilities = getCapabilities()
|
||||
return capabilities.password_policy ? capabilities.password_policy : {}
|
||||
return this._capabilities.password_policy ? this._capabilities.password_policy : {}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@
|
|||
</span>
|
||||
</div>
|
||||
<div class="sharingTabDetailsView__wrapper">
|
||||
<div ref="quickPermissions"
|
||||
class="sharingTabDetailsView__quick-permissions">
|
||||
<div ref="quickPermissions" class="sharingTabDetailsView__quick-permissions">
|
||||
<div>
|
||||
<NcCheckboxRadioSwitch :button-variant="true"
|
||||
:checked.sync="sharingPermission"
|
||||
|
|
@ -743,7 +742,7 @@ export default {
|
|||
}
|
||||
|
||||
},
|
||||
initializePermissions() {
|
||||
handleShareType() {
|
||||
if (this.share.share_type) {
|
||||
this.share.type = this.share.share_type
|
||||
}
|
||||
|
|
@ -752,23 +751,34 @@ export default {
|
|||
if ('shareType' in this.share) {
|
||||
this.share.type = this.share.shareType
|
||||
}
|
||||
},
|
||||
handleDefaultPermissions() {
|
||||
if (this.isNewShare) {
|
||||
if (this.isPublicShare) {
|
||||
this.sharingPermission = BUNDLED_PERMISSIONS.READ_ONLY.toString()
|
||||
const defaultPermissions = this.config.defaultPermissions
|
||||
if (defaultPermissions === BUNDLED_PERMISSIONS.READ_ONLY || defaultPermissions === BUNDLED_PERMISSIONS.ALL) {
|
||||
this.sharingPermission = defaultPermissions.toString()
|
||||
} else {
|
||||
this.sharingPermission = BUNDLED_PERMISSIONS.ALL.toString()
|
||||
}
|
||||
|
||||
} else {
|
||||
if (this.hasCustomPermissions || this.share.setCustomPermissions) {
|
||||
this.sharingPermission = 'custom'
|
||||
this.share.permissions = defaultPermissions
|
||||
this.advancedSectionAccordionExpanded = true
|
||||
this.setCustomPermissions = true
|
||||
} else {
|
||||
this.sharingPermission = this.share.permissions.toString()
|
||||
}
|
||||
}
|
||||
},
|
||||
handleCustomPermissions() {
|
||||
if (!this.isNewShare && (this.hasCustomPermissions || this.share.setCustomPermissions)) {
|
||||
this.sharingPermission = 'custom'
|
||||
this.advancedSectionAccordionExpanded = true
|
||||
this.setCustomPermissions = true
|
||||
} else {
|
||||
this.sharingPermission = this.share.permissions.toString()
|
||||
}
|
||||
},
|
||||
initializePermissions() {
|
||||
this.handleShareType()
|
||||
this.handleDefaultPermissions()
|
||||
this.handleCustomPermissions()
|
||||
},
|
||||
async saveShare() {
|
||||
const permissionsAndAttributes = ['permissions', 'attributes', 'note', 'expireDate']
|
||||
const publicShareAttributes = ['label', 'password', 'hideDownload']
|
||||
|
|
|
|||
3
dist/636-636.js
vendored
Normal file
3
dist/636-636.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/636-636.js.map
vendored
Normal file
1
dist/636-636.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
3
dist/8231-8231.js
vendored
3
dist/8231-8231.js
vendored
File diff suppressed because one or more lines are too long
1
dist/8231-8231.js.map
vendored
1
dist/8231-8231.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue