Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: create composable for password enforcement capability #10081

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import {
useCapabilityFilesSharingPublicCanEdit,
useCapabilityFilesSharingPublicCanContribute,
useCapabilityFilesSharingPublicAlias,
useCapabilityFilesSharingPublicPasswordEnforcedFor,
useAbility,
usePasswordPolicyService,
getDefaultLinkPermissions
Expand Down Expand Up @@ -229,6 +230,7 @@ export default defineComponent({
hasPublicLinkEditing: useCapabilityFilesSharingPublicCanEdit(),
hasPublicLinkContribute: useCapabilityFilesSharingPublicCanContribute(),
hasPublicLinkAliasSupport: useCapabilityFilesSharingPublicAlias(),
passwordEnforced: useCapabilityFilesSharingPublicPasswordEnforcedFor(),
indirectLinkListCollapsed,
linkListCollapsed,
outgoingLinks,
Expand Down Expand Up @@ -292,16 +294,6 @@ export default defineComponent({
}
},

passwordEnforced() {
return (
this.capabilities.files_sharing.public.password?.enforced_for || {
read_only: false,
upload_only: false,
read_write: false
}
)
},

helpersEnabled() {
return this.configuration?.options?.contextHelpers
},
Expand Down
13 changes: 8 additions & 5 deletions packages/web-client/src/ocs/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export interface PasswordPolicyCapability {
min_special_characters?: number
}

export interface PasswordEnforcedForCapability {
read_only?: boolean
read_write?: boolean
upload_only?: boolean
read_write_delete?: boolean
}

export interface LastModifiedFilterCapability {
keywords?: string[]
enabled?: boolean
Expand Down Expand Up @@ -100,11 +107,7 @@ export interface Capabilities {
multiple: boolean
password: {
enforced: boolean
enforced_for: {
read_only: boolean
read_write: boolean
upload_only: boolean
}
enforced_for: PasswordEnforcedForCapability
}
send_mail: boolean
supports_upload_only: boolean
Expand Down
13 changes: 12 additions & 1 deletion packages/web-pkg/src/composables/capability/useCapability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
AppProviderCapability,
LastModifiedFilterCapability,
MediaTypeCapability,
PasswordPolicyCapability
PasswordPolicyCapability,
PasswordEnforcedForCapability
} from '@ownclouders/web-client/src/ocs/capabilities'
import { SharePermissionBit } from '@ownclouders/web-client/src/helpers'

Expand Down Expand Up @@ -153,3 +154,13 @@ export const useCapabilitySearchMediaType = createCapabilityComposable<MediaType
'search.property.mediatype',
{}
)

export const useCapabilityFilesSharingPublicPasswordEnforcedFor =
createCapabilityComposable<PasswordEnforcedForCapability>(
'files_sharing.public.password.enforced_for',
{
read_only: false,
upload_only: false,
read_write: false
}
)