Skip to content
2 changes: 1 addition & 1 deletion .woodpecker.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OpenCloud to use in pipelines
OPENCLOUD_COMMITID=6e909bf3d7f1fd309bda787d48dd9e89ebd35501
OPENCLOUD_COMMITID=2670f24605dd0f97b89329f5a2f2f99d5107bc68
OPENCLOUD_BRANCH=main
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function getWrapper(space: SpaceResource) {
const mocks = defaultComponentMocks({
currentRoute: mock<RouteLocation>({ path: '/files', name: '' })
})
mocks.$previewService.getSupportedMimeTypes.mockReturnValue([])

return {
wrapper: mount(SpaceContextActions, {
props: {
Expand Down
8 changes: 4 additions & 4 deletions packages/web-client/src/graph/driveItems/driveItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ export const DriveItemsFactory = ({
await driveItemApiFactory.deleteDriveItem(driveId, itemId, requestOptions)
},

async listSharedByMe(requestOptions) {
const { data } = await meDriveApiFactory.listSharedByMe(requestOptions)
async listSharedByMe(options, requestOptions) {
const { data } = await meDriveApiFactory.listSharedByMe(options?.expand, requestOptions)
return data?.value || []
},

async listSharedWithMe(requestOptions) {
const { data } = await meDriveApiFactory.listSharedWithMe(requestOptions)
async listSharedWithMe(options, requestOptions) {
const { data } = await meDriveApiFactory.listSharedWithMe(options?.expand, requestOptions)
return data?.value || []
}
}
Expand Down
14 changes: 12 additions & 2 deletions packages/web-client/src/graph/driveItems/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ export interface GraphDriveItems {
itemId: string,
requestOptions?: GraphRequestOptions
) => Promise<void>
listSharedByMe: (requestOptions?: GraphRequestOptions) => Promise<DriveItem[]>
listSharedWithMe: (requestOptions?: GraphRequestOptions) => Promise<DriveItem[]>
listSharedByMe: (
options?: {
expand?: Set<'thumbnails'>
},
requestOptions?: GraphRequestOptions
) => Promise<DriveItem[]>
listSharedWithMe: (
options?: {
expand?: Set<'thumbnails'>
},
requestOptions?: GraphRequestOptions
) => Promise<DriveItem[]>
}
58 changes: 44 additions & 14 deletions packages/web-client/src/graph/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8628,10 +8628,11 @@ export const MeDriveApiAxiosParamCreator = function (configuration?: Configurati
/**
* The `driveItems` returned from the `sharedByMe` method always include the `permissions` relation that indicates they are shared items.
* @summary Get a list of driveItem objects shared by the current user.
* @param {Set<ListSharedByMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listSharedByMe: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
listSharedByMe: async ($expand?: Set<ListSharedByMeExpandEnum>, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/v1beta1/me/drive/sharedByMe`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -8650,6 +8651,10 @@ export const MeDriveApiAxiosParamCreator = function (configuration?: Configurati
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)

if ($expand) {
localVarQueryParameter['$expand'] = Array.from($expand).join(COLLECTION_FORMATS.csv);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
Expand All @@ -8664,10 +8669,11 @@ export const MeDriveApiAxiosParamCreator = function (configuration?: Configurati
/**
* The `driveItems` returned from the `sharedWithMe` method always include the `remoteItem` facet that indicates they are items from a different drive.
* @summary Get a list of driveItem objects shared with the owner of a drive.
* @param {Set<ListSharedWithMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listSharedWithMe: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
listSharedWithMe: async ($expand?: Set<ListSharedWithMeExpandEnum>, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/v1beta1/me/drive/sharedWithMe`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
Expand All @@ -8686,6 +8692,10 @@ export const MeDriveApiAxiosParamCreator = function (configuration?: Configurati
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)

if ($expand) {
localVarQueryParameter['$expand'] = Array.from($expand).join(COLLECTION_FORMATS.csv);
}



setSearchParams(localVarUrlObj, localVarQueryParameter);
Expand Down Expand Up @@ -8722,23 +8732,25 @@ export const MeDriveApiFp = function(configuration?: Configuration) {
/**
* The `driveItems` returned from the `sharedByMe` method always include the `permissions` relation that indicates they are shared items.
* @summary Get a list of driveItem objects shared by the current user.
* @param {Set<ListSharedByMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listSharedByMe(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CollectionOfDriveItems1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listSharedByMe(options);
async listSharedByMe($expand?: Set<ListSharedByMeExpandEnum>, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CollectionOfDriveItems1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listSharedByMe($expand, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['MeDriveApi.listSharedByMe']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
* The `driveItems` returned from the `sharedWithMe` method always include the `remoteItem` facet that indicates they are items from a different drive.
* @summary Get a list of driveItem objects shared with the owner of a drive.
* @param {Set<ListSharedWithMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listSharedWithMe(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CollectionOfDriveItems1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listSharedWithMe(options);
async listSharedWithMe($expand?: Set<ListSharedWithMeExpandEnum>, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CollectionOfDriveItems1>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listSharedWithMe($expand, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['MeDriveApi.listSharedWithMe']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
Expand All @@ -8765,20 +8777,22 @@ export const MeDriveApiFactory = function (configuration?: Configuration, basePa
/**
* The `driveItems` returned from the `sharedByMe` method always include the `permissions` relation that indicates they are shared items.
* @summary Get a list of driveItem objects shared by the current user.
* @param {Set<ListSharedByMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listSharedByMe(options?: RawAxiosRequestConfig): AxiosPromise<CollectionOfDriveItems1> {
return localVarFp.listSharedByMe(options).then((request) => request(axios, basePath));
listSharedByMe($expand?: Set<ListSharedByMeExpandEnum>, options?: RawAxiosRequestConfig): AxiosPromise<CollectionOfDriveItems1> {
return localVarFp.listSharedByMe($expand, options).then((request) => request(axios, basePath));
},
/**
* The `driveItems` returned from the `sharedWithMe` method always include the `remoteItem` facet that indicates they are items from a different drive.
* @summary Get a list of driveItem objects shared with the owner of a drive.
* @param {Set<ListSharedWithMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listSharedWithMe(options?: RawAxiosRequestConfig): AxiosPromise<CollectionOfDriveItems1> {
return localVarFp.listSharedWithMe(options).then((request) => request(axios, basePath));
listSharedWithMe($expand?: Set<ListSharedWithMeExpandEnum>, options?: RawAxiosRequestConfig): AxiosPromise<CollectionOfDriveItems1> {
return localVarFp.listSharedWithMe($expand, options).then((request) => request(axios, basePath));
},
};
};
Expand All @@ -8804,26 +8818,42 @@ export class MeDriveApi extends BaseAPI {
/**
* The `driveItems` returned from the `sharedByMe` method always include the `permissions` relation that indicates they are shared items.
* @summary Get a list of driveItem objects shared by the current user.
* @param {Set<ListSharedByMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof MeDriveApi
*/
public listSharedByMe(options?: RawAxiosRequestConfig) {
return MeDriveApiFp(this.configuration).listSharedByMe(options).then((request) => request(this.axios, this.basePath));
public listSharedByMe($expand?: Set<ListSharedByMeExpandEnum>, options?: RawAxiosRequestConfig) {
return MeDriveApiFp(this.configuration).listSharedByMe($expand, options).then((request) => request(this.axios, this.basePath));
}

/**
* The `driveItems` returned from the `sharedWithMe` method always include the `remoteItem` facet that indicates they are items from a different drive.
* @summary Get a list of driveItem objects shared with the owner of a drive.
* @param {Set<ListSharedWithMeExpandEnum>} [$expand] Expand related entities
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof MeDriveApi
*/
public listSharedWithMe(options?: RawAxiosRequestConfig) {
return MeDriveApiFp(this.configuration).listSharedWithMe(options).then((request) => request(this.axios, this.basePath));
public listSharedWithMe($expand?: Set<ListSharedWithMeExpandEnum>, options?: RawAxiosRequestConfig) {
return MeDriveApiFp(this.configuration).listSharedWithMe($expand, options).then((request) => request(this.axios, this.basePath));
}
}

/**
* @export
*/
export const ListSharedByMeExpandEnum = {
Thumbnails: 'thumbnails'
} as const;
export type ListSharedByMeExpandEnum = typeof ListSharedByMeExpandEnum[keyof typeof ListSharedByMeExpandEnum];
/**
* @export
*/
export const ListSharedWithMeExpandEnum = {
Thumbnails: 'thumbnails'
} as const;
export type ListSharedWithMeExpandEnum = typeof ListSharedWithMeExpandEnum[keyof typeof ListSharedWithMeExpandEnum];


/**
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/resource/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ export function buildResource(
image: convertObjectToCamelCaseKeys(resource.props[DavProperty.Image]),
photo: convertObjectToCamelCaseKeys(resource.props[DavProperty.Photo]),
extraProps,
hasPreview: () => resource.props[DavProperty.HasPreview] === 1,
canUpload: function () {
return this.permissions.indexOf(DavPermission.FolderCreateable) >= 0
},
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface Resource {
remoteItemId?: string
remoteItemPath?: string

hasPreview?(): boolean
canCreate?(): boolean
canUpload?({ user }: { user?: User }): boolean
canDownload?(): boolean
Expand Down
2 changes: 2 additions & 0 deletions packages/web-client/src/helpers/share/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export function buildIncomingShareResource({
sharePermissions,
outgoing: false,
privateLink: urlJoin(serverUrl, 'f', driveItem.remoteItem.id),
hasPreview: () => !!driveItem.thumbnails,
canRename: () => driveItem['@client.synchronize'],
canDownload: () => sharePermissions.includes(GraphSharePermission.readContent),
canUpload: () => sharePermissions.includes(GraphSharePermission.createUpload),
Expand Down Expand Up @@ -217,6 +218,7 @@ export function buildOutgoingShareResource({
mimeType: driveItem.file?.mimeType || 'httpd/unix-directory',
outgoing: true,
privateLink: urlJoin(serverUrl, 'f', driveItem.id),
hasPreview: () => !!driveItem.thumbnails,
canRename: () => true,
canDownload: () => true,
canUpload: () => true,
Expand Down
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/space/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ export function buildSpaceImageResource(space: SpaceResource): Resource {
mimeType: space.spaceImageData.file.mimeType,
type: 'file',
webDavPath: urlJoin(space.webDavPath, '.space', space.spaceImageData.name),
hasPreview: () => true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this correct (space images always have preview)

canDownload: () => true
} as Resource
}
4 changes: 3 additions & 1 deletion packages/web-client/src/webdav/constants/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const DavPropertyMapping = {
Highlights: defString('highlights' as const),
MetaPathForUser: defString('meta-path-for-user' as const),
RemoteItemId: defString('remote-item-id' as const),
HasPreview: defNumber('has-preview' as const),

ShareId: defString('shareid' as const),
ShareRoot: defString('shareroot' as const),
Expand Down Expand Up @@ -148,7 +149,8 @@ export abstract class DavProperties {
DavProperty.Audio,
DavProperty.Location,
DavProperty.Image,
DavProperty.Photo
DavProperty.Photo,
DavProperty.HasPreview
]

static readonly PublicLink: DavPropertyValue[] = DavProperties.Default.concat([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ export const useFileActionsSetImage = () => {
if (!resources[0].mimeType) {
return false
}
if (!previewService.isMimetypeSupported(resources[0].mimeType, true)) {
return false
}

if (!isLocationSpacesActive(router, 'files-spaces-generic')) {
return false
Expand Down
2 changes: 0 additions & 2 deletions packages/web-pkg/src/composables/piniaStores/capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export const useCapabilityStore = defineStore('capabilities', () => {

const filesAppProviders = computed(() => unref(capabilities).files.app_providers)
const filesFavorites = computed(() => unref(capabilities).files.favorites)
const filesThumbnail = computed(() => unref(capabilities).files.thumbnail)
const filesArchivers = computed(() => unref(capabilities).files.archivers)
const filesPrivateLinks = computed(() => unref(capabilities).files.privateLinks)
const filesPermanentDeletion = computed(() => unref(capabilities).files.permanent_deletion)
Expand Down Expand Up @@ -159,7 +158,6 @@ export const useCapabilityStore = defineStore('capabilities', () => {
graphUsersReadOnlyAttributes,
filesAppProviders,
filesFavorites,
filesThumbnail,
filesArchivers,
filesPrivateLinks,
filesPermanentDeletion,
Expand Down
13 changes: 10 additions & 3 deletions packages/web-pkg/src/composables/resources/useLoadPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,11 @@ export const useLoadPreview = (viewMode?: Ref<string>) => {

if (isProjectSpaceResource(resource) && (!resource.spaceImageData || resource.disabled)) {
if (unref(defaultSpaceImageBlobURL)) {
resource.thumbnail = unref(defaultSpaceImageBlobURL)
return unref(defaultSpaceImageBlobURL)
spacesStore.updateSpaceField({
id: resource.id,
field: 'thumbnail',
value: unref(defaultSpaceImageBlobURL)
})
}

try {
Expand All @@ -112,7 +115,11 @@ export const useLoadPreview = (viewMode?: Ref<string>) => {
spacesStore.setDefaultSpaceImageBlobURL(
URL.createObjectURL(defaultSpaceImageBlobURLResponse.data)
)
resource.thumbnail = unref(defaultSpaceImageBlobURL)
spacesStore.updateSpaceField({
id: resource.id,
field: 'thumbnail',
value: unref(defaultSpaceImageBlobURL)
})
return unref(defaultSpaceImageBlobURL)
} catch {
return null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class FolderLoaderSharedViaLink implements FolderLoader {
}

const value = yield* call(
clientService.graphAuthenticated.driveItems.listSharedByMe({ signal: signal1 })
clientService.graphAuthenticated.driveItems.listSharedByMe(
{ expand: new Set(['thumbnails']) },
{ signal: signal1 }
)
)

const resources = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class FolderLoaderSharedWithMe implements FolderLoader {
}

const value = yield* call(
clientService.graphAuthenticated.driveItems.listSharedWithMe({ signal: signal1 })
clientService.graphAuthenticated.driveItems.listSharedWithMe(
{ expand: new Set(['thumbnails']) },
{ signal: signal1 }
)
)

const resources = value.map((driveItem) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export class FolderLoaderSharedWithOthers implements FolderLoader {
}

const value = yield* call(
clientService.graphAuthenticated.driveItems.listSharedByMe({ signal: signal1 })
clientService.graphAuthenticated.driveItems.listSharedByMe(
{ expand: new Set(['thumbnails']) },
{ signal: signal1 }
)
)

const resources = value
Expand Down
Loading