From 550a2c34b1ae4b8c5da3f7d5a1ad697c67e0b950 Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 28 Nov 2023 17:06:11 +0100 Subject: [PATCH] refactor: create composable for password enforcement capability --- .../src/components/SideBar/Shares/FileLinks.vue | 12 ++---------- packages/web-client/src/ocs/capabilities.ts | 13 ++++++++----- .../src/composables/capability/useCapability.ts | 13 ++++++++++++- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue index dc17fcd2f45..d3a9dd05edc 100644 --- a/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue +++ b/packages/web-app-files/src/components/SideBar/Shares/FileLinks.vue @@ -121,6 +121,7 @@ import { useCapabilityFilesSharingPublicCanEdit, useCapabilityFilesSharingPublicCanContribute, useCapabilityFilesSharingPublicAlias, + useCapabilityFilesSharingPublicPasswordEnforcedFor, useAbility, usePasswordPolicyService, getDefaultLinkPermissions @@ -229,6 +230,7 @@ export default defineComponent({ hasPublicLinkEditing: useCapabilityFilesSharingPublicCanEdit(), hasPublicLinkContribute: useCapabilityFilesSharingPublicCanContribute(), hasPublicLinkAliasSupport: useCapabilityFilesSharingPublicAlias(), + passwordEnforced: useCapabilityFilesSharingPublicPasswordEnforcedFor(), indirectLinkListCollapsed, linkListCollapsed, outgoingLinks, @@ -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 }, diff --git a/packages/web-client/src/ocs/capabilities.ts b/packages/web-client/src/ocs/capabilities.ts index 73e9abc541f..0d9fb639400 100644 --- a/packages/web-client/src/ocs/capabilities.ts +++ b/packages/web-client/src/ocs/capabilities.ts @@ -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 @@ -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 diff --git a/packages/web-pkg/src/composables/capability/useCapability.ts b/packages/web-pkg/src/composables/capability/useCapability.ts index b82aeba37c3..fd4ab9087ba 100644 --- a/packages/web-pkg/src/composables/capability/useCapability.ts +++ b/packages/web-pkg/src/composables/capability/useCapability.ts @@ -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' @@ -153,3 +154,13 @@ export const useCapabilitySearchMediaType = createCapabilityComposable( + 'files_sharing.public.password.enforced_for', + { + read_only: false, + upload_only: false, + read_write: false + } + )