Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,26 @@
>
<span v-text="$gettext('Reload public link')" />
</oc-button>
<oc-button
v-if="showGuestLinkButton"
id="files-list-not-found-button-go-guest-share"
type="router-link"
appearance="raw"
:to="guestLinkRoute"
>
<span v-text="$gettext('Go to the shared item')" />
</oc-button>
</template>
</no-content-message>
</template>

<script setup lang="ts">
import {
NoContentMessage,
createLocationGuest,
createLocationPublic,
createLocationSpaces,
isLocationGuestActive,
isLocationPublicActive,
isLocationSpacesActive
} from '@opencloud-eu/web-pkg'
Expand All @@ -61,14 +72,18 @@ const { space = null } = defineProps<{
const router = useRouter()
const isProjectSpace = space?.driveType === 'project'

const showPublicLinkButton = isLocationPublicActive(router, 'files-public-link')
const showPublicLinkButton = isLocationPublicActive(router, 'files-public-link') && !!space
const showGuestLinkButton = isLocationGuestActive(router, 'files-guest-link') && !!space
const showHomeButton = isLocationSpacesActive(router, 'files-spaces-generic') && !isProjectSpace
const showSpacesButton = isLocationSpacesActive(router, 'files-spaces-generic') && isProjectSpace
const homeRoute = createLocationSpaces('files-spaces-generic', {
params: {
driveAliasAndItem: 'personal'
}
})
const publicLinkRoute = createLocationPublic('files-public-link', createFileRouteOptions(space, {}))
const publicLinkRoute =
space && createLocationPublic('files-public-link', createFileRouteOptions(space, {}))
const guestLinkRoute =
space && createLocationGuest('files-guest-link', createFileRouteOptions(space, {}))
const spacesRoute = createLocationSpaces('files-spaces-projects')
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ const contextualHelper = {
} as ContextualHelper

const hasTags = computed(() => {
return tagsEnabled && capabilityStore.filesTags
// the tags endpoints are not available to guests
return tagsEnabled && capabilityStore.filesTags && !authStore.isGuestContext
})

const hasDeletionDate = computed(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
useGetMatchingSpace,
useModals,
usePasteWorker,
useAuthStore,
useResourcesStore
} from '@opencloud-eu/web-pkg'

Expand All @@ -33,6 +34,7 @@ export const useFileActionsCopy = () => {
const { startWorker } = usePasteWorker()
const { $gettext, $ngettext } = useGettext()
const { resetSelection } = useResourcesStore()
const authStore = useAuthStore()

const resourcesStore = useResourcesStore()
const { currentFolder } = storeToRefs(resourcesStore)
Expand Down Expand Up @@ -198,6 +200,10 @@ export const useFileActionsCopy = () => {
if (!resources[0].canDownload()) {
return false
}
// guests have no home, they can only copy within their share
if (authStore.isGuestContext) {
return !!unref(currentFolder)?.canCreate()
}
// copy can't be restricted in authenticated context, because
// a user always has their home dir with write access
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import {
FileAction,
FileActionOptionsWithEvent,
useAuthStore,
useInterceptModifierClick,
useMessages
} from '@opencloud-eu/web-pkg'
Expand All @@ -18,6 +19,7 @@ export const useFileActionsCopyPermanentLink = () => {
const { $gettext } = useGettext()
const { copy } = useClipboard()
const { interceptModifierClick } = useInterceptModifierClick()
const authStore = useAuthStore()

const copyLinkToClipboard = async (url: string) => {
try {
Expand Down Expand Up @@ -51,7 +53,8 @@ export const useFileActionsCopyPermanentLink = () => {
return false
}

if (isPublicSpaceResource(space)) {
// private links require a signed-in user
if (isPublicSpaceResource(space) || authStore.isGuestContext) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
extractNameWithoutExtension,
isPublicSpaceResource,
isShareSpaceResource,
Resource,
SpaceResource
} from '@opencloud-eu/web-client'
Expand Down Expand Up @@ -178,9 +179,9 @@ export const useFileActionsCreateNewFile = () => {
handler: (args) => handler(args, appFileExtension.extension, appFileExtension),
label: () => $gettext(appFileExtension.newFileMenu.menuTitle()),
isVisible: ({ space }) => {
// files created via an upload-only link couldn't be edited afterwards
// files created via an upload-only link or share couldn't be edited afterwards
if (
isPublicSpaceResource(space) &&
(isPublicSpaceResource(space) || isShareSpaceResource(space)) &&
!unref(currentFolder)?.permissions?.includes(DavPermission.Updateable)
) {
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
FileAction,
FileActionOptions,
isLocationSpacesActive,
useAuthStore,
useClientService,
useConfigStore,
useLoadingService,
Expand All @@ -23,6 +24,7 @@ export const useFileActionsDisableSync = () => {
const clientService = useClientService()
const loadingService = useLoadingService()
const configStore = useConfigStore()
const authStore = useAuthStore()
const resourcesStore = useResourcesStore()
const { updateResourceField } = resourcesStore

Expand Down Expand Up @@ -87,7 +89,7 @@ export const useFileActionsDisableSync = () => {
handler: (args) => loadingService.addTask(() => handler(args)),
label: () => $gettext('Disable sync'),
isVisible: ({ resources }) => {
if (resources.length === 0) {
if (resources.length === 0 || authStore.isGuestContext) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FileAction,
FileActionOptions,
isLocationSpacesActive,
useAuthStore,
useClientService,
useConfigStore,
useLoadingService,
Expand All @@ -22,6 +23,7 @@ export const useFileActionsEnableSync = () => {
const clientService = useClientService()
const loadingService = useLoadingService()
const configStore = useConfigStore()
const authStore = useAuthStore()

const resourcesStore = useResourcesStore()
const { updateResourceField } = resourcesStore
Expand Down Expand Up @@ -89,7 +91,7 @@ export const useFileActionsEnableSync = () => {
handler: (args) => loadingService.addTask(() => handler(args)),
label: () => $gettext('Enable sync'),
isVisible: ({ resources }) => {
if (resources.length === 0) {
if (resources.length === 0 || authStore.isGuestContext) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import PQueue from 'p-queue'
import {
FileAction,
FileActionOptions,
useAuthStore,
useClientService,
useConfigStore,
useLoadingService,
Expand All @@ -19,6 +20,7 @@ export const useFileActionsToggleHideShare = () => {
const clientService = useClientService()
const loadingService = useLoadingService()
const configStore = useConfigStore()
const authStore = useAuthStore()
const { updateResourceField, resetSelection } = useResourcesStore()

const handler = async ({ resources }: FileActionOptions<IncomingShareResource>) => {
Expand Down Expand Up @@ -78,7 +80,7 @@ export const useFileActionsToggleHideShare = () => {
handler: (args) => loadingService.addTask(() => handler(args)),
label: ({ resources }) => (resources[0].hidden ? $gettext('Unhide') : $gettext('Hide')),
isVisible: ({ resources }) => {
if (resources.length === 0) {
if (resources.length === 0 || authStore.isGuestContext) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ import { isProjectSpaceResource, isTrashResource } from '@opencloud-eu/web-clien
import {
createFileRouteOptions,
isSameResource,
createLocationGuest,
createLocationPublic,
createLocationSpaces,
createLocationTrash,
isLocationPublicActive,
isLocationTrashActive,
useRouter,
FileAction,
useAuthStore,
useResourcesStore
} from '@opencloud-eu/web-pkg'

export const useFileActionsNavigate = () => {
const router = useRouter()
const { $gettext } = useGettext()
const authStore = useAuthStore()

const resourcesStore = useResourcesStore()
const { currentFolder } = storeToRefs(resourcesStore)
Expand All @@ -27,6 +30,9 @@ export const useFileActionsNavigate = () => {
if (isLocationPublicActive(router, 'files-public-link')) {
return createLocationPublic('files-public-link')
}
if (authStore.isGuestContext) {
return createLocationGuest('files-guest-link')
}
if (isLocationTrashActive(router, 'files-trash-overview')) {
return createLocationTrash('files-trash-generic')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
useCapabilityStore,
useCanListShares,
useCanListVersions,
useResourcesStore
useResourcesStore,
useAuthStore
} from '@opencloud-eu/web-pkg'
import { isProjectSpaceResource, SpaceResource } from '@opencloud-eu/web-client'
import { Resource } from '@opencloud-eu/web-client'
Expand All @@ -39,6 +40,7 @@ export const useSideBarPanels = (): SidebarPanelExtension<SpaceResource, Resourc
const { canListShares } = useCanListShares()
const { canListVersions } = useCanListVersions()
const resourcesStore = useResourcesStore()
const authStore = useAuthStore()

return [
{
Expand Down Expand Up @@ -318,7 +320,7 @@ export const useSideBarPanels = (): SidebarPanelExtension<SpaceResource, Resourc
if (isLocationTrashActive(router, 'files-trash-generic')) {
return false
}
return true
return !authStore.isGuestContext
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/web-app-files/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export const extensions = (appInfo: ApplicationInformation) => {
return true
}

// the root of a single file share is the file itself
if (unref(currentFolder)?.isFolder === false) {
return true
}

// permission checks on the space are preferred over the current folder,
// as the current folder resets on every navigation, causing a button flicker.
const space = unref(currentSpace)
Expand Down
2 changes: 0 additions & 2 deletions packages/web-app-files/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import App from './App.vue'
import Favorites from './views/Favorites.vue'
import FilesDrop from './views/FilesDrop.vue'
import GuestLink from './views/GuestLink.vue'
import SharedWithMe from './views/shares/SharedWithMe.vue'
import SharedWithOthers from './views/shares/SharedWithOthers.vue'
import SharedViaLink from './views/shares/SharedViaLink.vue'
Expand Down Expand Up @@ -133,7 +132,6 @@ export default defineWebApplication({
App,
Favorites,
FilesDrop,
GuestLink,
SearchResults,
Shares: {
SharedViaLink,
Expand Down
62 changes: 0 additions & 62 deletions packages/web-app-files/src/views/GuestLink.vue

This file was deleted.

10 changes: 7 additions & 3 deletions packages/web-app-files/src/views/spaces/DriveRedirect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

<script setup lang="ts">
import { computed, unref } from 'vue'
import { useRoute, useRouter, useSpacesStore } from '@opencloud-eu/web-pkg'
import { useAuthStore, useRoute, useRouter, useSpacesStore } from '@opencloud-eu/web-pkg'
import { AppLoadingSpinner } from '@opencloud-eu/web-pkg'
import { urlJoin } from '@opencloud-eu/web-client'
import { createFileRouteOptions } from '@opencloud-eu/web-pkg'
import { createFileRouteOptions, createGuestHomeLocation } from '@opencloud-eu/web-pkg'
import { createLocationSpaces } from '@opencloud-eu/web-pkg'
import omit from 'lodash-es/omit'
import { RouteLocationRaw } from 'vue-router'
Expand All @@ -25,6 +25,7 @@ const { driveAliasAndItem = '' } = defineProps<{
const router = useRouter()
const route = useRoute()
const spacesStore = useSpacesStore()
const authStore = useAuthStore()

const personalSpace = computed(() => {
return spacesStore.spaces.find((space) => space.driveType === 'personal')
Expand All @@ -36,7 +37,10 @@ const itemPath = computed(() => {
: '/'
})

if (!unref(personalSpace)) {
if (authStore.isGuestContext) {
// guests are scoped to the share they were invited to
router.replace(createGuestHomeLocation({ authStore, spacesStore }))
} else if (!unref(personalSpace)) {
router.replace(createLocationSpaces('files-spaces-projects'))
} else {
const { params, query } = createFileRouteOptions(unref(personalSpace), {
Expand Down
Loading
Loading