Skip to content

Commit

Permalink
Use enso paths in cloud browser (#11001)
Browse files Browse the repository at this point in the history
Fixes #10947

(cherry picked from commit 32f10a5)
  • Loading branch information
farmaazon authored and jdunkerley committed Sep 10, 2024
1 parent 3cef865 commit 0b6aaee
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
updated actual code][10857]
- [Added fullscreen modes to documentation editor and code editor][10876]
- [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
projects.][11014]

Expand All @@ -23,6 +24,7 @@
[10857]: https://github.com/enso-org/enso/pull/10857
[10876]: https://github.com/enso-org/enso/pull/10876
[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

#### Enso Standard Library
Expand Down
35 changes: 16 additions & 19 deletions app/gui2/src/components/widgets/FileBrowserWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const emit = defineEmits<{
pathSelected: [path: string]
}>()
const { prefetch, ensureQueryData } = useBackendQueryPrefetching()
const { ensureQueryData } = useBackendQueryPrefetching()
// === Current Directory ===
Expand All @@ -33,6 +33,12 @@ const directoryStack = ref<Directory[]>([
},
])
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 ===
Expand Down Expand Up @@ -75,15 +81,6 @@ interface 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 ===
watch(directories, (directories) => {
Expand All @@ -94,11 +91,6 @@ watch(directories, (directories) => {
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 ===
function enterDir(dir: DirectoryAsset) {
Expand All @@ -114,17 +106,22 @@ function chooseFile(file: FileAsset) {
}
const isBusy = computed(
() => isPending.value || (selectedFile.value && selectedFileDetails.isPending.value),
() => isPending.value || (selectedFile.value && currentUser.isPending.value),
)
const anyError = computed(() =>
isError.value ? error
: selectedFileDetails.isError.value ? selectedFileDetails.error
: currentUser.isError.value ? currentUser.error
: undefined,
)
watch(selectedFileDetails.data, (details) => {
if (details) emit('pathSelected', details.file.path)
const selectedFilePath = computed(
() =>
selectedFile.value && currentPath.value && `${currentPath.value}/${selectedFile.value.title}`,
)
watch(selectedFilePath, (path) => {
if (path) emit('pathSelected', path)
})
</script>

Expand Down

0 comments on commit 0b6aaee

Please sign in to comment.