@@ -52,12 +46,6 @@
class="oc-mt-s"
:min-date="DateTime.now()"
:label="$gettext('Expiry date')"
- :disabled="selectedLinkTypeIsInternal"
- :description-message="
- selectedLinkTypeIsInternal
- ? $gettext('Expiry date cannot be set for internal links')
- : undefined
- "
@date-changed="onExpiryDateChanged"
/>
@@ -187,10 +175,6 @@ export default defineComponent({
return $gettext('Share link(s)')
}
- if (unref(selectedLinkTypeIsInternal)) {
- return $gettext('Copy link')
- }
-
return $gettext('Copy link')
})
@@ -213,12 +197,6 @@ export default defineComponent({
enforcePassword: unref(passwordEnforced)
})
- const selectedLinkTypeIsInternal = computed(
- () => unref(selectedType) === SharingLinkType.Internal
- )
- const onlyInternalLinksAllowed = computed(
- () => unref(availableLinkTypes).length === 1 && unref(selectedLinkTypeIsInternal)
- )
const setAdvancedMode = () => {
isAdvancedMode.value = true
}
@@ -248,10 +226,8 @@ export default defineComponent({
}
const passwordPolicyFulfilled = computed(() => {
- if (!unref(selectedLinkTypeIsInternal)) {
- if (!passwordPolicy.check(unref(password).value)) {
- return false
- }
+ if (!passwordPolicy.check(unref(password).value)) {
+ return false
}
return true
@@ -314,14 +290,6 @@ export default defineComponent({
const updateSelectedLinkType = (type: SharingLinkType) => {
selectedType.value = type
- if (unref(selectedLinkTypeIsInternal)) {
- password.value = ''
- password.error = ''
- selectedExpiry.value = undefined
-
- // re-render password because it's the only way to remove policy messages
- passwordInputKey.value = uuidV4()
- }
}
onMounted(() => {
@@ -347,8 +315,6 @@ export default defineComponent({
selectedType,
selectedTypeIcon,
selectedTypeDescription,
- selectedLinkTypeIsInternal,
- onlyInternalLinksAllowed,
isSelectedLinkType,
updateSelectedLinkType,
updatePassword,
diff --git a/packages/web-pkg/src/components/FilesList/ContextActions.vue b/packages/web-pkg/src/components/FilesList/ContextActions.vue
index b2ce1901dd9..ccd957eb19e 100644
--- a/packages/web-pkg/src/components/FilesList/ContextActions.vue
+++ b/packages/web-pkg/src/components/FilesList/ContextActions.vue
@@ -10,7 +10,7 @@ import {
FileActionOptions,
useExtensionRegistry,
useFileActionsToggleHideShare,
- useFileActionsCopyQuickLink,
+ useFileActionsCopyPermanentLink,
useFileActionsPaste,
useFileActionsShowDetails,
useFileActionsShowShares,
@@ -47,7 +47,7 @@ export default defineComponent({
const { actions: enableSyncActions } = useFileActionsEnableSync()
const { actions: hideShareActions } = useFileActionsToggleHideShare()
const { actions: copyActions } = useFileActionsCopy()
- const { actions: createQuickLinkActions } = useFileActionsCopyQuickLink()
+ const { actions: copyPermanentLinkActions } = useFileActionsCopyPermanentLink()
const { actions: disableSyncActions } = useFileActionsDisableSync()
const { actions: deleteActions } = useFileActionsDelete()
const { actions: downloadArchiveActions } = useFileActionsDownloadArchive()
@@ -120,7 +120,7 @@ export default defineComponent({
const menuItemsShare = computed(() => {
return [
...unref(showSharesActions),
- ...unref(createQuickLinkActions),
+ ...unref(copyPermanentLinkActions),
...unref(extensionsContextActions).filter((a) => a.category === 'share')
].filter((item) => item.isVisible(unref(actionOptions)))
})
diff --git a/packages/web-pkg/src/composables/actions/files/index.ts b/packages/web-pkg/src/composables/actions/files/index.ts
index cd92f89c3a5..13832cc3884 100644
--- a/packages/web-pkg/src/composables/actions/files/index.ts
+++ b/packages/web-pkg/src/composables/actions/files/index.ts
@@ -2,7 +2,7 @@ export * from './useFileActions'
export * from './useFileActionsEnableSync'
export * from './useFileActionsToggleHideShare'
export * from './useFileActionsCopy'
-export * from './useFileActionsCopyQuicklink'
+export * from './useFileActionsCopyPermanentLink'
export * from './useFileActionsDisableSync'
export * from './useFileActionsDelete'
export * from './useFileActionsDownloadArchive'
diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsCopyPermanentLink.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsCopyPermanentLink.ts
new file mode 100644
index 00000000000..872d5d40264
--- /dev/null
+++ b/packages/web-pkg/src/composables/actions/files/useFileActionsCopyPermanentLink.ts
@@ -0,0 +1,45 @@
+import { computed } from 'vue'
+import { useGettext } from 'vue3-gettext'
+import { FileAction } from '../types'
+import { useClipboard } from '../../clipboard'
+import { useMessages } from '../../piniaStores'
+
+export const useFileActionsCopyPermanentLink = () => {
+ const { showMessage, showErrorMessage } = useMessages()
+ const { $gettext } = useGettext()
+ const { copyToClipboard } = useClipboard()
+
+ const copyLinkToClipboard = async (url: string) => {
+ try {
+ await copyToClipboard(url)
+ showMessage({ title: $gettext('The link has been copied to your clipboard.') })
+ } catch (e) {
+ console.error(e)
+ showErrorMessage({
+ title: $gettext('Copy link failed'),
+ errors: [e]
+ })
+ }
+ }
+
+ const actions = computed((): FileAction[] => [
+ {
+ name: 'copy-permanent-link',
+ icon: 'link',
+ label: () => $gettext('Copy permanent link'),
+ handler: ({ resources }) => {
+ const [resource] = resources
+ const permalink = resource.privateLink
+ return copyLinkToClipboard(permalink)
+ },
+ isVisible: ({ resources }) => {
+ return resources.length === 1
+ },
+ class: 'oc-files-actions-copy-permanent-link-trigger'
+ }
+ ])
+
+ return {
+ actions
+ }
+}
diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts
deleted file mode 100644
index e540f720b26..00000000000
--- a/packages/web-pkg/src/composables/actions/files/useFileActionsCopyQuicklink.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-import { isLinkShare } from '@ownclouders/web-client'
-import { computed, unref } from 'vue'
-import { useClientService } from '../../clientService'
-import { useGettext } from 'vue3-gettext'
-import { FileAction, FileActionOptions } from '../types'
-import { useCanShare } from '../../shares'
-import { useClipboard } from '../../clipboard'
-import { Resource, SpaceResource } from '@ownclouders/web-client'
-import { useFileActionsCreateLink } from './useFileActionsCreateLink'
-import { useMessages, useSharesStore } from '../../piniaStores'
-
-export const useFileActionsCopyQuickLink = () => {
- const { showMessage, showErrorMessage } = useMessages()
- const language = useGettext()
- const { $gettext } = language
- const clientService = useClientService()
- const { canShare } = useCanShare()
- const sharesStore = useSharesStore()
- const { copyToClipboard } = useClipboard()
-
- const { actions: createLinkActions } = useFileActionsCreateLink()
- const createQuicklinkAction = computed
(() =>
- unref(createLinkActions).find(({ name }) => name === 'create-quick-links')
- )
-
- const copyQuickLinkToClipboard = async (url: string) => {
- try {
- await copyToClipboard(url)
- showMessage({ title: $gettext('The link has been copied to your clipboard.') })
- } catch (e) {
- console.error(e)
- showErrorMessage({
- title: $gettext('Copy link failed'),
- errors: [e]
- })
- }
- }
-
- const getExistingQuickLink = async ({
- space,
- resource
- }: {
- space: SpaceResource
- resource: Resource
- }) => {
- const client = clientService.graphAuthenticated.permissions
- const { shares } = await client.listPermissions(space.id, resource.id, sharesStore.graphRoles)
- return shares.filter(isLinkShare).find(({ isQuickLink }) => isQuickLink)
- }
-
- const handler = async ({ space, resources }: FileActionOptions) => {
- const [resource] = resources
-
- const existingQuickLink = await getExistingQuickLink({ space, resource })
- if (existingQuickLink) {
- return copyQuickLinkToClipboard(existingQuickLink.webUrl)
- }
-
- return unref(createQuicklinkAction).handler({ space, resources })
- }
-
- const actions = computed((): FileAction[] => [
- {
- name: 'copy-quicklink',
- icon: 'link',
- label: () => $gettext('Copy link'),
- handler,
- isVisible: ({ space, resources }) => {
- if (resources.length !== 1) {
- return false
- }
-
- return canShare({ space, resource: resources[0] })
- },
- class: 'oc-files-actions-copy-quicklink-trigger'
- }
- ])
-
- return {
- actions
- }
-}
diff --git a/packages/web-pkg/src/composables/actions/files/useFileActionsCreateLink.ts b/packages/web-pkg/src/composables/actions/files/useFileActionsCreateLink.ts
index 4bd21c4f87b..3672b9e60c0 100644
--- a/packages/web-pkg/src/composables/actions/files/useFileActionsCreateLink.ts
+++ b/packages/web-pkg/src/composables/actions/files/useFileActionsCreateLink.ts
@@ -15,7 +15,6 @@ import {
} from '../../piniaStores'
import { useClipboard } from '../../clipboard'
import { useClientService } from '../../clientService'
-import { SharingLinkType } from '@ownclouders/web-client/graph/generated'
export const useFileActionsCreateLink = ({
enforceModal = false
@@ -90,7 +89,7 @@ export const useFileActionsCreateLink = ({
{ isQuickLink = false }: { isQuickLink?: boolean } = {}
) => {
const passwordEnforced = capabilityStore.sharingPublicPasswordEnforcedFor.read_only === true
- if (enforceModal || (passwordEnforced && unref(defaultLinkType) !== SharingLinkType.Internal)) {
+ if (enforceModal || passwordEnforced) {
dispatchModal({
title: $ngettext(
'Copy link for "%{resourceName}"',
diff --git a/packages/web-pkg/src/composables/links/useLinkTypes.ts b/packages/web-pkg/src/composables/links/useLinkTypes.ts
index 855f666a6bf..ec706e87950 100644
--- a/packages/web-pkg/src/composables/links/useLinkTypes.ts
+++ b/packages/web-pkg/src/composables/links/useLinkTypes.ts
@@ -12,19 +12,7 @@ export const useLinkTypes = () => {
const canCreatePublicLinks = computed(() => ability.can('create-all', 'PublicLink'))
- const defaultLinkType = computed(() => {
- const canCreatePublicLink = ability.can('create-all', 'PublicLink')
- if (!canCreatePublicLink) {
- return SharingLinkType.Internal
- }
-
- const defaultPermissions = capabilityStore.sharingPublicDefaultPermissions
- if (defaultPermissions === undefined || defaultPermissions === 1) {
- return SharingLinkType.View
- }
-
- return SharingLinkType.Internal
- })
+ const defaultLinkType = computed(() => SharingLinkType.View)
const isPasswordEnforcedForLinkType = (type: SharingLinkType) => {
if (type === SharingLinkType.View) {
@@ -44,12 +32,11 @@ export const useLinkTypes = () => {
const getAvailableLinkTypes = ({ isFolder }: { isFolder: boolean }): SharingLinkType[] => {
if (!unref(canCreatePublicLinks)) {
- return [SharingLinkType.Internal]
+ return []
}
if (isFolder) {
return [
- SharingLinkType.Internal,
SharingLinkType.View,
SharingLinkType.Upload,
SharingLinkType.Edit,
@@ -57,7 +44,7 @@ export const useLinkTypes = () => {
]
}
- return [SharingLinkType.Internal, SharingLinkType.View, SharingLinkType.Edit]
+ return [SharingLinkType.View, SharingLinkType.Edit]
}
// links don't have roles in graph API, hence we need to define them here
diff --git a/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts b/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts
index f0cd56105e1..6c8ff159cda 100644
--- a/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts
+++ b/packages/web-pkg/tests/unit/components/CreateLinkModal.spec.ts
@@ -42,17 +42,11 @@ describe('CreateLinkModal', () => {
await nextTick()
expect(wrapper.find(selectors.passwordInput).exists()).toBeTruthy()
})
- it('should be disabled for internal links', async () => {
- const { wrapper } = getWrapper({ defaultLinkType: SharingLinkType.Internal })
- wrapper.vm.isAdvancedMode = true
- await nextTick()
- expect(wrapper.find(selectors.passwordInput).attributes('disabled')).toBeTruthy()
- })
it('should not be rendered if user cannot create public links', () => {
const { wrapper } = getWrapper({
userCanCreatePublicLinks: false,
- availableLinkTypes: [SharingLinkType.Internal],
- defaultLinkType: SharingLinkType.Internal
+ availableLinkTypes: [],
+ defaultLinkType: SharingLinkType.View
})
expect(wrapper.find(selectors.passwordInput).exists()).toBeFalsy()
})
@@ -70,17 +64,11 @@ describe('CreateLinkModal', () => {
await nextTick()
expect(wrapper.findComponent({ name: 'oc-datepicker' }).exists()).toBeTruthy()
})
- it('should be disabled for internal links', async () => {
- const { wrapper } = getWrapper({ defaultLinkType: SharingLinkType.Internal })
- wrapper.vm.isAdvancedMode = true
- await nextTick()
- expect(wrapper.findComponent({ name: 'oc-datepicker' }).attributes('disabled')).toBeTruthy()
- })
it('should not be rendered if user cannot create public links', () => {
const { wrapper } = getWrapper({
userCanCreatePublicLinks: false,
- availableLinkTypes: [SharingLinkType.Internal],
- defaultLinkType: SharingLinkType.Internal
+ availableLinkTypes: [],
+ defaultLinkType: SharingLinkType.View
})
expect(wrapper.findComponent({ name: 'oc-datepicker' }).exists()).toBeFalsy()
})
@@ -93,11 +81,7 @@ describe('CreateLinkModal', () => {
expect(wrapper.find(selectors.linkRoleDropDownToggle).exists()).toBeFalsy()
})
it('lists all types as roles', async () => {
- const availableLinkTypes = [
- SharingLinkType.View,
- SharingLinkType.Internal,
- SharingLinkType.Edit
- ]
+ const availableLinkTypes = [SharingLinkType.View, SharingLinkType.Edit]
const { wrapper } = getWrapper({ availableLinkTypes })
wrapper.vm.isAdvancedMode = true
await nextTick()
@@ -183,7 +167,7 @@ function getWrapper({
embedModeEnabled = false,
callbackFn = undefined,
isQuickLink = false,
- availableLinkTypes = [SharingLinkType.Internal, SharingLinkType.View]
+ availableLinkTypes = [SharingLinkType.View]
}: {
resources?: Resource[]
defaultLinkType?: SharingLinkType
@@ -204,7 +188,7 @@ function getWrapper({
mock>({
defaultLinkType: ref(defaultLinkType),
getAvailableLinkTypes: () => availableLinkTypes,
- getLinkRoleByType: () => mock({ description: 'role' }),
+ getLinkRoleByType: () => mock({ description: 'role', label: '' }),
isPasswordEnforcedForLinkType: () => passwordEnforced
})
)
diff --git a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts
index 6f345723e74..28347fae3b5 100644
--- a/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts
+++ b/packages/web-pkg/tests/unit/components/FilesList/ContextActions.spec.ts
@@ -5,7 +5,7 @@ import ContextActions from '../../../../src/components/FilesList/ContextActions.
import {
useFileActionsEnableSync,
- useFileActionsCopyQuickLink,
+ useFileActionsCopyPermanentLink,
useFileActionsRename,
useFileActionsCopy
} from '../../../../src/composables'
@@ -27,7 +27,7 @@ describe.skip('ContextActions', () => {
it('render enabled actions', () => {
const enabledComposables = [
useFileActionsEnableSync,
- useFileActionsCopyQuickLink,
+ useFileActionsCopyPermanentLink,
useFileActionsRename,
useFileActionsCopy
]
diff --git a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyPermanentLink.spec.ts b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyPermanentLink.spec.ts
new file mode 100644
index 00000000000..88aa4fb5941
--- /dev/null
+++ b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyPermanentLink.spec.ts
@@ -0,0 +1,71 @@
+import { unref } from 'vue'
+import { useFileActionsCopyPermanentLink } from '../../../../../src/composables/actions/files'
+import { defaultComponentMocks, getComposableWrapper } from 'web-test-helpers'
+import { mock } from 'vitest-mock-extended'
+import { Resource, SpaceResource } from '@ownclouders/web-client'
+import { useClipboard } from '../../../../../src/composables/clipboard'
+
+vi.mock('../../../../../src/composables/clipboard', () => ({
+ useClipboard: vi.fn()
+}))
+
+describe('useFileActionsCopyPermanentLink', () => {
+ describe('isVisible property', () => {
+ it('should return false if no resource selected', () => {
+ getWrapper({
+ setup: ({ actions }) => {
+ expect(unref(actions)[0].isVisible({ space: null, resources: [] })).toBeFalsy()
+ }
+ })
+ })
+ it('should return true if one resource selected', () => {
+ getWrapper({
+ setup: ({ actions }) => {
+ expect(
+ unref(actions)[0].isVisible({ resources: [mock()], space: undefined })
+ ).toBeTruthy()
+ }
+ })
+ })
+ })
+ describe('handler', () => {
+ it('calls the copyToClipboard method with the private link of the resource', () => {
+ getWrapper({
+ setup: async ({ actions }, { mocks }) => {
+ const privateLink = 'https://example.com'
+ await unref(actions)[0].handler({
+ resources: [mock({ privateLink })],
+ space: mock()
+ })
+ expect(mocks.copyToClipboardMock).toHaveBeenCalledWith(privateLink)
+ }
+ })
+ })
+ })
+})
+
+function getWrapper({
+ setup
+}: {
+ setup: (
+ instance: ReturnType,
+ mocks: Record
+ ) => void
+}) {
+ const copyToClipboardMock = vi.fn()
+ vi.mocked(useClipboard).mockReturnValue({ copyToClipboard: copyToClipboardMock })
+ const mocks = { ...defaultComponentMocks(), copyToClipboardMock }
+
+ return {
+ wrapper: getComposableWrapper(
+ () => {
+ const instance = useFileActionsCopyPermanentLink()
+ setup(instance, { mocks })
+ },
+ {
+ mocks,
+ provide: mocks
+ }
+ )
+ }
+}
diff --git a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts b/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts
deleted file mode 100644
index 96844c005e0..00000000000
--- a/packages/web-pkg/tests/unit/composables/actions/files/useFileActionsCopyQuicklink.spec.ts
+++ /dev/null
@@ -1,144 +0,0 @@
-import { computed, unref } from 'vue'
-import {
- useFileActionsCopyQuickLink,
- useFileActionsCreateLink
-} from '../../../../../src/composables/actions/files'
-import { defaultComponentMocks, getComposableWrapper } from 'web-test-helpers'
-import { mock } from 'vitest-mock-extended'
-import { FileAction } from '../../../../../src/composables/actions'
-import { useCanShare } from '../../../../../src/composables/shares'
-import { Resource, SpaceResource } from '@ownclouders/web-client'
-import { LinkShare } from '@ownclouders/web-client'
-import { useClipboard } from '../../../../../src/composables/clipboard'
-import { useMessages } from '../../../../../src/composables/piniaStores'
-
-vi.mock('../../../../../src/composables/shares', () => ({
- useCanShare: vi.fn()
-}))
-
-vi.mock('../../../../../src/composables/actions/files/useFileActionsCreateLink', () => ({
- useFileActionsCreateLink: vi.fn()
-}))
-
-vi.mock('../../../../../src/composables/clipboard', () => ({
- useClipboard: vi.fn()
-}))
-
-describe('useFileActionsCopyQuickLink', () => {
- describe('isVisible property', () => {
- it('should return false if no resource selected', () => {
- getWrapper({
- setup: ({ actions }) => {
- expect(unref(actions)[0].isVisible({ space: null, resources: [] })).toBeFalsy()
- }
- })
- })
- it('should return false if canShare is false', () => {
- getWrapper({
- canShare: false,
- setup: ({ actions }) => {
- expect(
- unref(actions)[0].isVisible({ resources: [mock()], space: undefined })
- ).toBeFalsy()
- }
- })
- })
- it('should return true if resource can be shared', () => {
- getWrapper({
- setup: ({ actions }) => {
- expect(
- unref(actions)[0].isVisible({ resources: [mock()], space: undefined })
- ).toBeTruthy()
- }
- })
- })
- })
- describe('handler', () => {
- it('should create a new link if quick link does not yet exist', () => {
- getWrapper({
- setup: async ({ actions }, { mocks }) => {
- await unref(actions)[0].handler({
- resources: [mock()],
- space: mock()
- })
- expect(mocks.createLinkMock).toHaveBeenCalledTimes(1)
- expect(
- mocks.$clientService.graphAuthenticated.permissions.listPermissions
- ).toHaveBeenCalled()
- }
- })
- })
- it('should not create a new link if quick link does already exist', () => {
- getWrapper({
- quickLinkExists: true,
- setup: async ({ actions }, { mocks }) => {
- await unref(actions)[0].handler({
- resources: [mock()],
- space: mock()
- })
- expect(mocks.createLinkMock).not.toHaveBeenCalled()
- const { showMessage } = useMessages()
- expect(showMessage).toHaveBeenCalledTimes(1)
- }
- })
- })
- it('calls the graph root endpoint for spaces', () => {
- getWrapper({
- setup: async ({ actions }, { mocks }) => {
- await unref(actions)[0].handler({
- resources: [mock({ type: 'space' })],
- space: mock()
- })
- expect(mocks.createLinkMock).toHaveBeenCalledTimes(1)
- expect(
- mocks.$clientService.graphAuthenticated.permissions.listPermissions
- ).toHaveBeenCalled()
- }
- })
- })
- })
-})
-
-function getWrapper({
- setup,
- canShare = true,
- quickLinkExists = false
-}: {
- setup: (
- instance: ReturnType,
- mocks: Record
- ) => void
- canShare?: boolean
- quickLinkExists?: boolean
-}) {
- const createLinkMock = vi.fn()
- vi.mocked(useFileActionsCreateLink).mockReturnValue({
- actions: computed(() => [
- mock({ name: 'create-quick-links', handler: createLinkMock })
- ])
- })
- vi.mocked(useCanShare).mockReturnValue({ canShare: vi.fn(() => canShare) })
- vi.mocked(useClipboard).mockReturnValue({ copyToClipboard: vi.fn() })
-
- const mocks = { ...defaultComponentMocks(), createLinkMock }
-
- const graphClientMock = mocks.$clientService.graphAuthenticated
- graphClientMock.permissions.listPermissions.mockResolvedValue({
- shares: [mock({ isQuickLink: quickLinkExists })],
- allowedActions: [],
- allowedRoles: []
- })
-
- return {
- wrapper: getComposableWrapper(
- () => {
- const instance = useFileActionsCopyQuickLink()
- setup(instance, { mocks })
- },
- {
- mocks,
- provide: mocks
- }
- )
- }
-}
diff --git a/packages/web-pkg/tests/unit/composables/links/useLinkTypes.spec.ts b/packages/web-pkg/tests/unit/composables/links/useLinkTypes.spec.ts
index 76a0d864558..a993d86091f 100644
--- a/packages/web-pkg/tests/unit/composables/links/useLinkTypes.spec.ts
+++ b/packages/web-pkg/tests/unit/composables/links/useLinkTypes.spec.ts
@@ -11,47 +11,20 @@ describe('useLinkTypes', () => {
expect(useLinkTypes).toBeDefined()
})
describe('computed "defaultLinkType"', () => {
- it('is internal if user can not create public links', () => {
+ it('is viewer', () => {
getWrapper({
- abilities: [],
- setup: ({ defaultLinkType }) => {
- expect(unref(defaultLinkType)).toBe(SharingLinkType.Internal)
- }
- })
- })
- it('is viewer if user can create public links and no default permissions are given', () => {
- getWrapper({
- abilities: [{ action: 'create-all', subject: 'PublicLink' }],
- setup: ({ defaultLinkType }) => {
- expect(unref(defaultLinkType)).toBe(SharingLinkType.View)
- }
- })
- })
- it('is viewer if default permissions are 1', () => {
- getWrapper({
- abilities: [{ action: 'create-all', subject: 'PublicLink' }],
- defaultPermissions: 1,
setup: ({ defaultLinkType }) => {
expect(unref(defaultLinkType)).toBe(SharingLinkType.View)
}
})
})
- it('is internasl if default permissions are 0', () => {
- getWrapper({
- abilities: [{ action: 'create-all', subject: 'PublicLink' }],
- defaultPermissions: 0,
- setup: ({ defaultLinkType }) => {
- expect(unref(defaultLinkType)).toBe(SharingLinkType.Internal)
- }
- })
- })
})
describe('method "getAvailableLinkTypes"', () => {
- it('only returns the internal type if user can not create public links', () => {
+ it('is empty if the user cannot create public links', () => {
getWrapper({
abilities: [],
setup: ({ getAvailableLinkTypes }) => {
- expect(getAvailableLinkTypes({ isFolder: true })).toEqual([SharingLinkType.Internal])
+ expect(getAvailableLinkTypes({ isFolder: true })).toEqual([])
}
})
})
@@ -60,7 +33,6 @@ describe('useLinkTypes', () => {
abilities: [{ action: 'create-all', subject: 'PublicLink' }],
setup: ({ getAvailableLinkTypes }) => {
expect(getAvailableLinkTypes({ isFolder: true })).toEqual([
- SharingLinkType.Internal,
SharingLinkType.View,
SharingLinkType.Upload,
SharingLinkType.Edit,
@@ -74,7 +46,6 @@ describe('useLinkTypes', () => {
abilities: [{ action: 'create-all', subject: 'PublicLink' }],
setup: ({ getAvailableLinkTypes }) => {
expect(getAvailableLinkTypes({ isFolder: false })).toEqual([
- SharingLinkType.Internal,
SharingLinkType.View,
SharingLinkType.Edit
])
diff --git a/tests/e2e/cucumber/features/shares/internalLink.feature b/tests/e2e/cucumber/features/shares/internalLink.feature
index 6948998e711..0de1343472f 100644
--- a/tests/e2e/cucumber/features/shares/internalLink.feature
+++ b/tests/e2e/cucumber/features/shares/internalLink.feature
@@ -1,7 +1,7 @@
Feature: internal link share
- Scenario: share a link with internal role
+ Scenario: opening a link with internal role
Given "Admin" creates following users using API
| id |
| Alice |
@@ -13,11 +13,9 @@ Feature: internal link share
And "Alice" shares the following resource using API
| resource | recipient | type | role |
| myfolder | Brian | user | Can edit |
- And "Alice" opens the "files" app
- And "Alice" creates a public link of following resource using the sidebar panel
- | resource | password |
- | myfolder | %public% |
- When "Alice" edits the public link named "Link" of resource "myfolder" changing role to "Invited people"
+ And "Alice" creates a public link of following resource using API
+ | resource | role |
+ | myfolder | Invited people |
And "Brian" opens the public link "Link"
And "Brian" logs in from the internal link
And "Brian" navigates to the shared with me page
diff --git a/tests/e2e/cucumber/features/shares/link.feature b/tests/e2e/cucumber/features/shares/link.feature
index 00508a816d4..3d75cd5218d 100644
--- a/tests/e2e/cucumber/features/shares/link.feature
+++ b/tests/e2e/cucumber/features/shares/link.feature
@@ -95,25 +95,6 @@ Feature: link
And "Alice" logs out
- Scenario: Quick link
- Given "Alice" logs in
- And "Alice" creates the following folders in personal space using API
- | name |
- | folderPublic |
- And "Alice" creates the following files into personal space using API
- | pathToFile | content |
- | folderPublic/lorem.txt | lorem ipsum |
-
- And "Alice" opens the "files" app
- When "Alice" creates quick link of the resource "folderPublic" with password "%public%" from the context menu
- And "Anonymous" opens the public link "Link"
- And "Anonymous" unlocks the public link with password "%public%"
- And "Anonymous" downloads the following public link resources using the sidebar panel
- | resource | type |
- | lorem.txt | file |
- And "Alice" logs out
-
-
Scenario: public link for folder and file (by authenticated user)
Given "Admin" creates following user using API
| id |
diff --git a/tests/e2e/cucumber/features/spaces/internalLink.feature b/tests/e2e/cucumber/features/spaces/internalLink.feature
deleted file mode 100644
index 8cea2b512a0..00000000000
--- a/tests/e2e/cucumber/features/spaces/internalLink.feature
+++ /dev/null
@@ -1,49 +0,0 @@
-Feature: internal link share in project space
-
- Scenario: share a link with internal role
- Given "Admin" creates following users using API
- | id |
- | Alice |
- | Brian |
- | Carol |
- And "Admin" assigns following roles to the users using API
- | id | role |
- | Alice | Space Admin |
- And "Alice" logs in
- And "Alice" creates the following project space using API
- | name | id |
- | Marketing | marketing.1 |
- And "Alice" creates the following folder in space "Marketing" using API
- | name |
- | myfolder |
- And "Alice" creates the following file in space "Marketing" using API
- | name | content |
- | myfolder/plan.txt | secret plan |
- And "Alice" adds the following members to the space "Marketing" using API
- | user | role | shareType |
- | Brian | Can edit | user |
- | Carol | Can view | user |
- And "Alice" navigates to the project space "marketing.1"
- # internal link to space
-
- And "Alice" creates a public link for the space with password "%public%" using the sidebar panel
- And "Alice" renames the most recently created public link of space to "spaceLink"
- And "Alice" edits the public link named "spaceLink" of the space changing role to "Invited people"
- # internal link to folder
- And "Alice" creates a public link of following resource using the sidebar panel
- | resource | role | password |
- | myfolder | Invited people | %public% |
- And "Alice" logs out
-
- And "Brian" opens the public link "Link"
- And "Brian" logs in from the internal link
- And "Brian" uploads the following resource in internal link named "Link"
- | resource |
- | simple.pdf |
- And "Brian" logs out
-
- When "Carol" opens the public link "spaceLink"
- And "Carol" logs in from the internal link
- And "Carol" opens folder "myfolder"
- Then "Carol" should not be able to edit file "simple.pdf"
- And "Carol" logs out
diff --git a/tests/e2e/cucumber/features/spaces/publicLink.feature b/tests/e2e/cucumber/features/spaces/publicLink.feature
index dee179cdedb..3c322594dc3 100644
--- a/tests/e2e/cucumber/features/spaces/publicLink.feature
+++ b/tests/e2e/cucumber/features/spaces/publicLink.feature
@@ -93,29 +93,6 @@ Feature: spaces public link
And "David" logs out
- Scenario: Quick link
- Given "Admin" creates following users using API
- | id |
- | Alice |
- And "Admin" assigns following roles to the users using API
- | id | role |
- | Alice | Space Admin |
- When "Alice" logs in
- And "Alice" creates the following project space using API
- | name | id |
- | team | team.1 |
- And "Alice" creates the following file in space "team" using API
- | name | content |
- | file.txt | some text |
- And "Alice" navigates to the project space "team.1"
- When "Alice" creates quick link of the resource "file.txt" with password "%public%" from the context menu
- And "Anonymous" opens the public link "Link"
- And "Anonymous" unlocks the public link with password "%public%"
- Then "Anonymous" is in a text-editor
- And "Anonymous" closes the file viewer
- And "Alice" logs out
-
-
Scenario: crud operation to public link for space
Given "Admin" creates following users using API
| id |
diff --git a/tests/e2e/cucumber/steps/ui/shares.ts b/tests/e2e/cucumber/steps/ui/shares.ts
index d8075b6f189..670637cbe78 100644
--- a/tests/e2e/cucumber/steps/ui/shares.ts
+++ b/tests/e2e/cucumber/steps/ui/shares.ts
@@ -192,25 +192,6 @@ When(
}
)
-When(
- '{string} creates quick link of the resource {string} with password {string} from the context menu',
- async function (
- this: World,
- stepUser: string,
- resource: string,
- password: string
- ): Promise {
- const { page } = this.actorsEnvironment.getActor({ key: stepUser })
- const shareObject = new objects.applicationFiles.Share({ page })
- const linkObject = new objects.applicationFiles.Link({ page })
- password = password === '%public%' ? linkObject.securePassword : password
- await shareObject.createQuickLink({
- resource,
- password
- })
- }
-)
-
When(
'{string} should not be able to open the folder/file {string}',
async function (this: World, stepUser: string, resource: string): Promise {
diff --git a/tests/e2e/support/objects/app-files/share/actions.ts b/tests/e2e/support/objects/app-files/share/actions.ts
index 0f17749be93..527bba89c83 100644
--- a/tests/e2e/support/objects/app-files/share/actions.ts
+++ b/tests/e2e/support/objects/app-files/share/actions.ts
@@ -1,11 +1,8 @@
-import { Page, expect, Locator } from '@playwright/test'
+import { Page, Locator } from '@playwright/test'
import util from 'util'
import Collaborator, { ICollaborator, IAccessDetails } from './collaborator'
import { sidebar } from '../utils'
import { clickResource } from '../resource/actions'
-import { clearCurrentPopup, createLinkArgs } from '../link/actions'
-import { config } from '../../../../config.js'
-import { createdLinkStore } from '../../../store'
import { User } from '../../../types'
import { locatorUtils } from '../../../utils'
@@ -146,9 +143,6 @@ export const clickActionInContextMenu = async (
page.locator(util.format(actionsTriggerButton, resource, action)).click()
])
break
- case 'copy-quicklink':
- await page.locator(util.format(actionsTriggerButton, resource, action)).click()
- break
case 'disable-sync':
await Promise.all([
page.waitForResponse(
@@ -206,47 +200,6 @@ export const checkSharee = async (args: ShareArgs): Promise => {
}
}
-export const createQuickLink = async (args: createLinkArgs): Promise => {
- const { page, resource, password } = args
- let url = ''
- const linkName = 'Link'
-
- await clickActionInContextMenu({ page, resource }, 'copy-quicklink')
- await page.locator(advancedModeButton).click()
- await page.locator(passwordInput).fill(password)
-
- await Promise.all([
- page.waitForResponse(
- (res) =>
- res.url().includes('createLink') &&
- res.request().method() === 'POST' &&
- res.status() === 200
- ),
- page.locator(createLinkButton).click()
- ])
- if (config.backendUrl.startsWith('https')) {
- // here is flaky https://github.com/owncloud/web/issues/9941
- // sometimes test doesn't have time to pick up the correct buffer
- await page.waitForTimeout(500)
- const clipBoardText = await page.evaluate(() => navigator.clipboard.readText())
- url = clipBoardText.match(/https?:\/\/[^ ]+/)[0]
- expect(url).toContain(config.baseUrlOcis)
- } else {
- const quickLinkUrlLocator = util.format(publicLinkInputField, linkName)
- if (!(await page.locator(quickLinkUrlLocator).isVisible())) {
- await openSharingPanel(page, resource)
- }
- url = await page.locator(quickLinkUrlLocator).textContent()
- }
-
- await clearCurrentPopup(page)
-
- if (url && !createdLinkStore.has(linkName)) {
- createdLinkStore.set(linkName, { name: linkName, url })
- }
- return url
-}
-
export interface setDenyShareArgs {
page: Page
resource: string
diff --git a/tests/e2e/support/objects/app-files/share/index.ts b/tests/e2e/support/objects/app-files/share/index.ts
index ccbc80fe6f4..77666aecc3d 100644
--- a/tests/e2e/support/objects/app-files/share/index.ts
+++ b/tests/e2e/support/objects/app-files/share/index.ts
@@ -1,7 +1,6 @@
import { Page, Locator } from '@playwright/test'
import * as po from './actions'
import { resourceIsNotOpenable, isAcceptedSharePresent, resourceIsSynced } from './utils'
-import { createLinkArgs } from '../link/actions'
import { ICollaborator, IAccessDetails } from './collaborator'
import { User } from '../../../types'
export class Share {
@@ -52,10 +51,6 @@ export class Share {
return await isAcceptedSharePresent({ page: this.#page, resource, owner })
}
- async createQuickLink(args: Omit): Promise {
- await po.createQuickLink({ ...args, page: this.#page })
- }
-
async resourceIsNotOpenable(resource: string): Promise {
return await resourceIsNotOpenable({ page: this.#page, resource })
}