Skip to content
Open
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 @@ -194,19 +194,31 @@ export default defineComponent({
type: Object,
required: false,
default: null
},
paginationPages: {
type: Number,
required: false,
default: null
},
paginationPage: {
type: Number,
required: false,
default: null
}
},
setup() {
setup(props) {
const capabilityStore = useCapabilityStore()
const configStore = useConfigStore()
const { getMatchingSpace } = useGetMatchingSpace()
const { loadPreview } = useLoadPreview()

const { paginationPages, paginationPage } = useResourcesViewDefaults<
IncomingShareResource,
any,
any[]
>()
const {
paginationPages: defaultPaginationPages,
paginationPage: defaultPaginationPage
} = useResourcesViewDefaults<IncomingShareResource, any, any[]>()

const paginationPages = computed(() => props.paginationPages ?? unref(defaultPaginationPages))
const paginationPage = computed(() => props.paginationPage ?? unref(defaultPaginationPage))

const { triggerDefaultAction } = useFileActions()
const { actions: hideShareActions } = useFileActionsToggleHideShare()
Expand Down
64 changes: 55 additions & 9 deletions packages/web-app-files/src/views/shares/SharedWithMe.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
areHiddenFilesShown ? $gettext('No hidden shares') : $gettext('No shares')
"
:grouping-settings="groupingSettings"
:pagination-pages="paginationPages"
:pagination-page="paginationPage"
/>
</template>
</files-view-wrapper>
Expand All @@ -101,13 +103,14 @@ import {
FileSideBar,
InlineFilterOption,
ItemFilter,
usePagination,
useAppsStore,
useResourcesStore
} from '@ownclouders/web-pkg'
import { AppBar, ItemFilterInline } from '@ownclouders/web-pkg'
import { queryItemAsString, useRouteQuery } from '@ownclouders/web-pkg'
import { queryItemAsString, useRouteQuery, useRouter } from '@ownclouders/web-pkg'
import SharedWithMeSection from '../../components/Shares/SharedWithMeSection.vue'
import { computed, defineComponent, onMounted, ref, unref, watch } from 'vue'
import { computed, defineComponent, onMounted, ref, unref, watch, nextTick } from 'vue'
import FilesViewWrapper from '../../components/FilesViewWrapper.vue'
import { useGetMatchingSpace, useSort } from '@ownclouders/web-pkg'
import { useGroupingSettings } from '@ownclouders/web-pkg'
Expand All @@ -134,6 +137,8 @@ export default defineComponent({
const appsStore = useAppsStore()
const resourcesStore = useResourcesStore()

const router = useRouter()

const {
areResourcesLoading,
sortFields,
Expand All @@ -143,10 +148,14 @@ export default defineComponent({
selectedResourcesIds,
sideBarActivePanel,
isSideBarOpen,
paginatedResources,
scrollToResourceFromRoute
} = useResourcesViewDefaults<IncomingShareResource, any, any>()

// Use all active resources as the base — filtering must happen before pagination
const allResources = computed(
() => resourcesStore.activeResources as unknown as IncomingShareResource[]
)

const { $gettext } = useGettext()

const areHiddenFilesShown = ref(false)
Expand All @@ -167,8 +176,8 @@ export default defineComponent({
resourcesStore.resetSelection()
}

const visibleShares = computed(() => unref(paginatedResources).filter((r) => !r.hidden))
const hiddenShares = computed(() => unref(paginatedResources).filter((r) => r.hidden))
const visibleShares = computed(() => unref(allResources).filter((r) => !r.hidden))
const hiddenShares = computed(() => unref(allResources).filter((r) => r.hidden))
const currentItems = computed(() => {
return unref(areHiddenFilesShown) ? unref(hiddenShares) : unref(visibleShares)
})
Expand Down Expand Up @@ -217,11 +226,31 @@ export default defineComponent({
}
})

const { sortBy, sortDir, items, handleSort } = useSort({
const { sortBy, sortDir, items: sortedFilteredItems, handleSort } = useSort({
items: filteredItems,
fields: sortFields
})

const {
items: paginatedFilteredItems,
total: paginationPages,
page: paginationPage
} = usePagination({ items: sortedFilteredItems, perPageStoragePrefix: 'files' })

// Reset to page 1 whenever the active filter set changes to avoid landing on an empty page
watch(
[selectedShareTypesQuery, selectedSharedByQuery, filterTerm, areHiddenFilesShown],
async () => {
await nextTick()
if (unref(paginationPage) > unref(paginationPages)) {
router.push({ query: { ...router.currentRoute.value.query, page: 1 } })
}
}
)

// Keep items alias for backward compat (e.g. scrollToResourceFromRoute)
const items = paginatedFilteredItems

const { getMatchingSpace } = useGetMatchingSpace()

const selectedShareSpace = computed(() => {
Expand All @@ -245,7 +274,7 @@ export default defineComponent({
}

const shareTypes = computed(() => {
const uniqueShareTypes = uniq(unref(paginatedResources).flatMap((i) => i.shareTypes))
const uniqueShareTypes = uniq(unref(allResources).flatMap((i) => i.shareTypes))

const ocmAvailable = appsStore.appIds.includes('open-cloud-mesh')
if (ocmAvailable && !uniqueShareTypes.includes(ShareTypes.remote.value)) {
Expand All @@ -262,10 +291,25 @@ export default defineComponent({
})

const fileOwners = computed(() => {
const flatList = unref(paginatedResources)
const flatList = unref(allResources)
.map((i) => i.sharedBy)
.flat()
return [...new Map(flatList.map((item) => [item.displayName, item])).values()]
// Deduplicate by id so users with the same display name are not merged
const uniqueById = [...new Map(flatList.map((item) => [item.id, item])).values()]
// Count how many distinct ids share the same display name
const nameCounts = uniqueById.reduce(
(acc, item) => {
acc[item.displayName] = (acc[item.displayName] || 0) + 1
return acc
},
{} as Record<string, number>
)
// Append the account id when two users share the same display name
return uniqueById.map((item) =>
nameCounts[item.displayName] > 1
? { ...item, displayName: `${item.displayName} (${item.id})` }
: item
)
})

onMounted(() => {
Expand Down Expand Up @@ -296,6 +340,8 @@ export default defineComponent({
sortBy,
sortDir,
items,
paginationPages,
paginationPage,

// CERN
...useGroupingSettings({ sortBy: sortBy, sortDir: sortDir })
Expand Down
63 changes: 37 additions & 26 deletions packages/web-app-files/src/views/spaces/DriveRedirect.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<template>
<div class="oc-flex oc-width-1-1">
<app-loading-spinner />
<div class="oc-width-1-1">
<not-found-message v-if="showNotFound" />
<app-loading-spinner v-else />
</div>
</template>

<script lang="ts">
import { computed, defineComponent, unref } from 'vue'
import { computed, defineComponent, ref, unref, watchEffect } from 'vue'
import { useRoute, useRouter, useSpacesStore } from '@ownclouders/web-pkg'
import { AppLoadingSpinner } from '@ownclouders/web-pkg'
import { urlJoin } from '@ownclouders/web-client'
import { createFileRouteOptions } from '@ownclouders/web-pkg'
import { createLocationSpaces } from '@ownclouders/web-pkg'
import NotFoundMessage from '../../components/FilesList/NotFoundMessage.vue'

// 'personal/home' is used as personal drive alias from static contexts
// (i.e. places where we can't load the actual personal space)
Expand All @@ -19,7 +20,8 @@ const fakePersonalDriveAlias = 'personal/home'
export default defineComponent({
name: 'DriveRedirect',
components: {
AppLoadingSpinner
AppLoadingSpinner,
NotFoundMessage
},
props: {
driveAliasAndItem: {
Expand All @@ -32,36 +34,45 @@ export default defineComponent({
const router = useRouter()
const route = useRoute()
const spacesStore = useSpacesStore()
const showNotFound = ref(false)

const personalSpace = computed(() => {
return spacesStore.spaces.find((space) => space.driveType === 'personal')
})

const itemPath = computed(() => {
return props.driveAliasAndItem.startsWith(fakePersonalDriveAlias)
? urlJoin(props.driveAliasAndItem.slice(fakePersonalDriveAlias.length))
: '/'
return urlJoin(props.driveAliasAndItem.slice(fakePersonalDriveAlias.length))
})

if (!unref(personalSpace)) {
router.replace(createLocationSpaces('files-spaces-projects'))
} else {
const { params, query } = createFileRouteOptions(unref(personalSpace), {
path: unref(itemPath)
})

router
.replace({
...unref(route),
params: {
...unref(route).params,
...params
},
query
watchEffect(() => {
if (
(props.driveAliasAndItem.startsWith(fakePersonalDriveAlias) ||
props.driveAliasAndItem === 'personal' ||
props.driveAliasAndItem === '') &&
unref(personalSpace)
) {
showNotFound.value = false
const { params, query } = createFileRouteOptions(unref(personalSpace), {
path: unref(itemPath)
})
// avoid NavigationDuplicated error in console
.catch(() => {})
}

router
.replace({
...unref(route),
params: {
...unref(route).params,
...params
},
query
})
// avoid NavigationDuplicated error in console
.catch(() => {})
} else {
showNotFound.value = true
}
})

return { showNotFound }
}
})
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ vi.mock('../../../../src/composables/resourcesViewDefaults')
vi.mock('@ownclouders/web-pkg', async (importOriginal) => ({
...(await importOriginal<any>()),
useSort: vi.fn().mockImplementation(() => useSortMock()),
usePagination: vi.fn().mockImplementation(({ items }) => ({
items,
total: ref(1),
page: ref(1),
perPage: ref(100)
})),
queryItemAsString: vi.fn(),
useRouteQuery: vi.fn(),
useOpenWithDefaultApp: vi.fn()
Expand Down Expand Up @@ -196,8 +202,11 @@ function getMountedWrapper({
mocks: defaultMocks,
wrapper: mount(SharedWithMe, {
global: {
plugins: [...defaultPlugins()],
plugins: [
...defaultPlugins({ piniaOptions: { resourcesStore: { resources: files } } })
],
mocks: defaultMocks,
provide: defaultMocks,
stubs: { ...defaultStubs, itemFilterInline: true, ItemFilter: true }
}
})
Expand Down
3 changes: 2 additions & 1 deletion packages/web-client/src/helpers/resource/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ const convertObjectToCamelCaseKeys = (data: Record<string, any>) => {
}

export function buildResource(resource: WebDavResponseResource): Resource {
const name = resource.props[DavProperty.Name]?.toString() || basename(resource.filename)
const name =
resource.basename || resource.props[DavProperty.Name]?.toString() || basename(resource.filename)
const id = resource.props[DavProperty.FileId]

const isFolder = resource.type === 'directory'
Expand Down
2 changes: 1 addition & 1 deletion packages/web-pkg/src/helpers/router/routeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const createFileRouteOptions = (
const config = options?.configStore || useConfigStore()
return {
params: {
driveAliasAndItem: space.getDriveAliasAndItem({ path: target.path || '' } as Resource)
driveAliasAndItem: space?.getDriveAliasAndItem({ path: target.path || '' } as Resource)
},
query: {
...(isShareSpaceResource(space) && { shareId: space.id }),
Expand Down
9 changes: 7 additions & 2 deletions packages/web-runtime/src/components/Topbar/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
v-if="appMenuExtensions.length && !isEmbedModeEnabled && !hideAppSwitcher"
:menu-items="appMenuExtensions"
/>
<router-link v-if="!hideLogo" :to="homeLink" :target="isEmbedModeEnabled ? '_blank' : null" class="oc-width-1-1 oc-logo-href">
<router-link
v-if="!hideLogo"
:to="homeLink"
:target="isEmbedModeEnabled ? '_blank' : null"
class="oc-width-1-1 oc-logo-href"
>
<oc-img :src="currentTheme.logo.topbar" :alt="sidebarLogoAlt" class="oc-logo-image" />
</router-link>
</div>
Expand Down Expand Up @@ -112,7 +117,7 @@ export default {
}
}

if (isEmbedModeEnabled) {
if (unref(isEmbedModeEnabled)) {
const currentRoute = unref(router.currentRoute)
return {
name: currentRoute.name,
Expand Down
4 changes: 2 additions & 2 deletions packages/web-runtime/src/container/versions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CapabilityStore } from '@ownclouders/web-pkg'

export const getWebVersion = (): string => {
return `ownCloud Web UI ${process.env.PACKAGE_VERSION}`
return `CERNBox Web ${process.env.PACKAGE_VERSION}`
}

export const getBackendVersion = ({
Expand All @@ -13,7 +13,7 @@ export const getBackendVersion = ({
if (!backendStatus || !backendStatus.versionstring) {
return undefined
}
const product = backendStatus.product || 'ownCloud'
const product = backendStatus.product || 'Reva'
const version = backendStatus.productversion || backendStatus.versionstring
const edition = backendStatus.edition
return `${product} ${version} ${edition}`
Expand Down
4 changes: 2 additions & 2 deletions packages/web-runtime/tests/unit/container/versions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('collect version information', () => {
process.env.PACKAGE_VERSION = '4.7.0'
})
it('provides the web version with a static string without exceptions', () => {
expect(getWebVersion()).toBe('ownCloud Web UI 4.7.0')
expect(getWebVersion()).toBe('CERNBox Web 4.7.0')
})
})
describe('backend version', () => {
Expand All @@ -29,7 +29,7 @@ describe('collect version information', () => {
versionstring: '10.8.0',
edition: 'Community'
})
expect(getBackendVersion({ capabilityStore })).toBe('ownCloud 10.8.0 Community')
expect(getBackendVersion({ capabilityStore })).toBe('Reva 10.8.0 Community')
})
it('provides the backend version as concatenation of product, version and edition', () => {
const capabilityStore = versionStore({
Expand Down