Use enso paths in cloud browser (#11001)

Fixes #10947
This commit is contained in:
Adam Obuchowicz 2024-09-10 00:56:52 +02:00 committed by GitHub
parent 1fdaf37add
commit 32f10a55f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 19 deletions

View File

@ -14,6 +14,7 @@
updated actual code][10857] updated actual code][10857]
- [Added fullscreen modes to documentation editor and code editor][10876] - [Added fullscreen modes to documentation editor and code editor][10876]
- [Fixed issue with node name assignment when uploading multiple files.][10979] - [Fixed issue with node name assignment when uploading multiple files.][10979]
- [Cloud file browser inserts `enso:` paths][11001]
- [Fixed issue where drag'n'dropped files were not uploaded in cloud - [Fixed issue where drag'n'dropped files were not uploaded in cloud
projects.][11014] projects.][11014]
@ -23,6 +24,7 @@
[10857]: https://github.com/enso-org/enso/pull/10857 [10857]: https://github.com/enso-org/enso/pull/10857
[10876]: https://github.com/enso-org/enso/pull/10876 [10876]: https://github.com/enso-org/enso/pull/10876
[10979]: https://github.com/enso-org/enso/pull/10979 [10979]: https://github.com/enso-org/enso/pull/10979
[11001]: https://github.com/enso-org/enso/pull/11001
[11014]: https://github.com/enso-org/enso/pull/11014 [11014]: https://github.com/enso-org/enso/pull/11014
#### Enso Standard Library #### Enso Standard Library

View File

@ -17,7 +17,7 @@ const emit = defineEmits<{
pathSelected: [path: string] pathSelected: [path: string]
}>() }>()
const { prefetch, ensureQueryData } = useBackendQueryPrefetching() const { ensureQueryData } = useBackendQueryPrefetching()
// === Current Directory === // === Current Directory ===
@ -33,6 +33,12 @@ const directoryStack = ref<Directory[]>([
}, },
]) ])
const currentDirectory = computed(() => directoryStack.value[directoryStack.value.length - 1]!) const currentDirectory = computed(() => directoryStack.value[directoryStack.value.length - 1]!)
const currentUser = useBackendQuery('usersMe', [])
const currentPath = computed(
() =>
currentUser.data.value &&
`enso://Users/${currentUser.data.value.name}${Array.from(directoryStack.value.slice(1), (frame) => '/' + frame.title).join()}`,
)
// === Directory Contents === // === Directory Contents ===
@ -75,15 +81,6 @@ interface File {
const selectedFile = ref<File>() const selectedFile = ref<File>()
function getFileDetailsArgs(parameters: ToValue<File | undefined>) {
return computed<Parameters<Backend['getFileDetails']> | undefined>(() => {
const paramsValue = toValue(parameters)
return paramsValue ? [paramsValue.id, paramsValue.title] : undefined
})
}
const selectedFileDetails = useBackendQuery('getFileDetails', getFileDetailsArgs(selectedFile))
// === Prefetching === // === Prefetching ===
watch(directories, (directories) => { watch(directories, (directories) => {
@ -94,11 +91,6 @@ watch(directories, (directories) => {
ensureQueryData('listDirectory', listDirectoryArgs(directory)) ensureQueryData('listDirectory', listDirectoryArgs(directory))
}) })
watch(files, (files) => {
// Prefetch file info to avoid lag when the user makes a selection.
for (const file of files ?? []) prefetch('getFileDetails', getFileDetailsArgs(file))
})
// === Interactivity === // === Interactivity ===
function enterDir(dir: DirectoryAsset) { function enterDir(dir: DirectoryAsset) {
@ -114,17 +106,22 @@ function chooseFile(file: FileAsset) {
} }
const isBusy = computed( const isBusy = computed(
() => isPending.value || (selectedFile.value && selectedFileDetails.isPending.value), () => isPending.value || (selectedFile.value && currentUser.isPending.value),
) )
const anyError = computed(() => const anyError = computed(() =>
isError.value ? error isError.value ? error
: selectedFileDetails.isError.value ? selectedFileDetails.error : currentUser.isError.value ? currentUser.error
: undefined, : undefined,
) )
watch(selectedFileDetails.data, (details) => { const selectedFilePath = computed(
if (details) emit('pathSelected', details.file.path) () =>
selectedFile.value && currentPath.value && `${currentPath.value}/${selectedFile.value.title}`,
)
watch(selectedFilePath, (path) => {
if (path) emit('pathSelected', path)
}) })
</script> </script>