mirror of
https://github.com/enso-org/enso.git
synced 2024-12-19 15:12:26 +03:00
Fix getFileDetails
and getProjectDetails
(#11787)
- Fix https://github.com/enso-org/cloud-v2/issues/1617 - Set `staleTime: 0` to queries to ensure they are always refetched. - Close https://github.com/enso-org/cloud-v2/issues/1579 - Add `&presigned=true` flag to request server to generate a presigned URL. # Important Notes None
This commit is contained in:
parent
8749719c19
commit
f6a900191a
@ -1687,6 +1687,7 @@ export default abstract class Backend {
|
||||
abstract getProjectDetails(
|
||||
projectId: ProjectId,
|
||||
directoryId: DirectoryId | null,
|
||||
getPresignedUrl?: boolean,
|
||||
): Promise<Project>
|
||||
/** Return Language Server logs for a project session. */
|
||||
abstract getProjectSessionLogs(
|
||||
@ -1723,7 +1724,11 @@ export default abstract class Backend {
|
||||
/** Change the name of a file. */
|
||||
abstract updateFile(fileId: FileId, body: UpdateFileRequestBody, title: string): Promise<void>
|
||||
/** Return file details. */
|
||||
abstract getFileDetails(fileId: FileId, title: string): Promise<FileDetails>
|
||||
abstract getFileDetails(
|
||||
fileId: FileId,
|
||||
title: string,
|
||||
getPresignedUrl?: boolean,
|
||||
): Promise<FileDetails>
|
||||
/** Create a Datalink. */
|
||||
abstract createDatalink(body: CreateDatalinkRequestBody): Promise<DatalinkInfo>
|
||||
/** Return a Datalink. */
|
||||
|
@ -488,7 +488,12 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
|
||||
case backendModule.AssetType.project: {
|
||||
try {
|
||||
const details = await queryClient.fetchQuery(
|
||||
backendQueryOptions(backend, 'getProjectDetails', [asset.id, asset.parentId]),
|
||||
backendQueryOptions(
|
||||
backend,
|
||||
'getProjectDetails',
|
||||
[asset.id, asset.parentId, true],
|
||||
{ staleTime: 0 },
|
||||
),
|
||||
)
|
||||
if (details.url != null) {
|
||||
await backend.download(details.url, `${asset.title}.enso-project`)
|
||||
@ -504,7 +509,9 @@ export function RealAssetInternalRow(props: RealAssetRowInternalProps) {
|
||||
case backendModule.AssetType.file: {
|
||||
try {
|
||||
const details = await queryClient.fetchQuery(
|
||||
backendQueryOptions(backend, 'getFileDetails', [asset.id, asset.title]),
|
||||
backendQueryOptions(backend, 'getFileDetails', [asset.id, asset.title, true], {
|
||||
staleTime: 0,
|
||||
}),
|
||||
)
|
||||
if (details.url != null) {
|
||||
await backend.download(details.url, asset.title)
|
||||
|
@ -767,8 +767,15 @@ export default class RemoteBackend extends Backend {
|
||||
* Return details for a project.
|
||||
* @throws An error if a non-successful status code (not 200-299) was received.
|
||||
*/
|
||||
override async getProjectDetails(projectId: backend.ProjectId): Promise<backend.Project> {
|
||||
const path = remoteBackendPaths.getProjectDetailsPath(projectId)
|
||||
override async getProjectDetails(
|
||||
projectId: backend.ProjectId,
|
||||
_directoryId: null,
|
||||
getPresignedUrl = false,
|
||||
): Promise<backend.Project> {
|
||||
const paramsString = new URLSearchParams({
|
||||
presigned: `${getPresignedUrl}`,
|
||||
}).toString()
|
||||
const path = `${remoteBackendPaths.getProjectDetailsPath(projectId)}?${paramsString}`
|
||||
const response = await this.get<backend.ProjectRaw>(path)
|
||||
if (!responseIsSuccessful(response)) {
|
||||
return await this.throw(response, 'getProjectDetailsBackendError')
|
||||
@ -959,8 +966,12 @@ export default class RemoteBackend extends Backend {
|
||||
override async getFileDetails(
|
||||
fileId: backend.FileId,
|
||||
title: string,
|
||||
getPresignedUrl = false,
|
||||
): Promise<backend.FileDetails> {
|
||||
const path = remoteBackendPaths.getFileDetailsPath(fileId)
|
||||
const searchParams = new URLSearchParams({
|
||||
presigned: `${getPresignedUrl}`,
|
||||
}).toString()
|
||||
const path = `${remoteBackendPaths.getFileDetailsPath(fileId)}?${searchParams}`
|
||||
const response = await this.get<backend.FileDetails>(path)
|
||||
if (!responseIsSuccessful(response)) {
|
||||
return await this.throw(response, 'getFileDetailsBackendError', title)
|
||||
|
Loading…
Reference in New Issue
Block a user