fix(ui): allow manual WSL UNC workspace selection on Windows
This commit is contained in:
@@ -67,6 +67,7 @@ const DirectoryBrowserDialog: Component<DirectoryBrowserDialogProps> = (props) =
|
|||||||
const [rootPath, setRootPath] = createSignal("")
|
const [rootPath, setRootPath] = createSignal("")
|
||||||
const [loading, setLoading] = createSignal(false)
|
const [loading, setLoading] = createSignal(false)
|
||||||
const [error, setError] = createSignal<string | null>(null)
|
const [error, setError] = createSignal<string | null>(null)
|
||||||
|
const [pathInput, setPathInput] = createSignal("")
|
||||||
const [creatingFolder, setCreatingFolder] = createSignal(false)
|
const [creatingFolder, setCreatingFolder] = createSignal(false)
|
||||||
const [directoryChildren, setDirectoryChildren] = createSignal<Map<string, FileSystemEntry[]>>(new Map())
|
const [directoryChildren, setDirectoryChildren] = createSignal<Map<string, FileSystemEntry[]>>(new Map())
|
||||||
const [loadingPaths, setLoadingPaths] = createSignal<Set<string>>(new Set())
|
const [loadingPaths, setLoadingPaths] = createSignal<Set<string>>(new Set())
|
||||||
@@ -77,10 +78,12 @@ const DirectoryBrowserDialog: Component<DirectoryBrowserDialogProps> = (props) =
|
|||||||
const inFlightRequests = new Map<string, Promise<FileSystemListingMetadata>>()
|
const inFlightRequests = new Map<string, Promise<FileSystemListingMetadata>>()
|
||||||
|
|
||||||
function resetState() {
|
function resetState() {
|
||||||
|
setRootPath("")
|
||||||
setDirectoryChildren(new Map<string, FileSystemEntry[]>())
|
setDirectoryChildren(new Map<string, FileSystemEntry[]>())
|
||||||
setLoadingPaths(new Set<string>())
|
setLoadingPaths(new Set<string>())
|
||||||
setCurrentPathKey(null)
|
setCurrentPathKey(null)
|
||||||
setCurrentMetadata(null)
|
setCurrentMetadata(null)
|
||||||
|
setPathInput("")
|
||||||
metadataCache.clear()
|
metadataCache.clear()
|
||||||
inFlightRequests.clear()
|
inFlightRequests.clear()
|
||||||
setError(null)
|
setError(null)
|
||||||
@@ -249,7 +252,36 @@ const DirectoryBrowserDialog: Component<DirectoryBrowserDialogProps> = (props) =
|
|||||||
return metadata.displayPath
|
return metadata.displayPath
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createEffect(() => {
|
||||||
|
const absolutePath = currentAbsolutePath()
|
||||||
|
if (absolutePath) {
|
||||||
|
setPathInput(absolutePath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const canSelectCurrent = createMemo(() => Boolean(currentAbsolutePath()))
|
const canSelectCurrent = createMemo(() => Boolean(currentAbsolutePath()))
|
||||||
|
const canSubmitPath = createMemo(() => pathInput().trim().length > 0)
|
||||||
|
|
||||||
|
async function handlePathSubmit() {
|
||||||
|
const target = pathInput().trim()
|
||||||
|
if (!target) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await navigateTo(target)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleSelectCurrent() {
|
||||||
|
const target = pathInput().trim()
|
||||||
|
if (target && target !== currentAbsolutePath()) {
|
||||||
|
await navigateTo(target)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const absolute = currentAbsolutePath()
|
||||||
|
if (absolute) {
|
||||||
|
props.onSelect(absolute)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function handleEntrySelect(entry: FileSystemEntry) {
|
function handleEntrySelect(entry: FileSystemEntry) {
|
||||||
const absolutePath = entry.absolutePath
|
const absolutePath = entry.absolutePath
|
||||||
@@ -338,19 +370,26 @@ const DirectoryBrowserDialog: Component<DirectoryBrowserDialogProps> = (props) =
|
|||||||
<div class="directory-browser-current">
|
<div class="directory-browser-current">
|
||||||
<div class="directory-browser-current-meta">
|
<div class="directory-browser-current-meta">
|
||||||
<span class="directory-browser-current-label">{t("directoryBrowser.currentFolder")}</span>
|
<span class="directory-browser-current-label">{t("directoryBrowser.currentFolder")}</span>
|
||||||
<span class="directory-browser-current-path">{currentAbsolutePath()}</span>
|
<input
|
||||||
|
type="text"
|
||||||
|
value={pathInput()}
|
||||||
|
onInput={(event) => setPathInput(event.currentTarget.value)}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter") {
|
||||||
|
event.preventDefault()
|
||||||
|
void handlePathSubmit()
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
spellcheck={false}
|
||||||
|
class="selector-input directory-browser-current-path"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="directory-browser-current-actions">
|
<div class="directory-browser-current-actions">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="selector-button selector-button-secondary directory-browser-select directory-browser-current-select"
|
class="selector-button selector-button-secondary directory-browser-select directory-browser-current-select"
|
||||||
disabled={!canSelectCurrent() || creatingFolder()}
|
disabled={(!canSelectCurrent() && !canSubmitPath()) || creatingFolder()}
|
||||||
onClick={() => {
|
onClick={() => void handleSelectCurrent()}
|
||||||
const absolute = currentAbsolutePath()
|
|
||||||
if (absolute) {
|
|
||||||
props.onSelect(absolute)
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{t("directoryBrowser.selectCurrent")}
|
{t("directoryBrowser.selectCurrent")}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -58,6 +58,14 @@ const FolderSelectionView: Component<FolderSelectionViewProps> = (props) => {
|
|||||||
const [isSavingServer, setIsSavingServer] = createSignal(false)
|
const [isSavingServer, setIsSavingServer] = createSignal(false)
|
||||||
const [connectingServerId, setConnectingServerId] = createSignal<string | null>(null)
|
const [connectingServerId, setConnectingServerId] = createSignal<string | null>(null)
|
||||||
const nativeDialogsAvailable = supportsNativeDialogs()
|
const nativeDialogsAvailable = supportsNativeDialogs()
|
||||||
|
const prefersBuiltInFolderBrowser = () => {
|
||||||
|
if (!nativeDialogsAvailable || typeof navigator === "undefined") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const platform = ((navigator as any).userAgentData?.platform as string | undefined) ?? navigator.platform ?? navigator.userAgent
|
||||||
|
return /win/i.test(platform)
|
||||||
|
}
|
||||||
let recentListRef: HTMLDivElement | undefined
|
let recentListRef: HTMLDivElement | undefined
|
||||||
|
|
||||||
type LanguageOption = { value: Locale; label: string }
|
type LanguageOption = { value: Locale; label: string }
|
||||||
@@ -380,7 +388,7 @@ const FolderSelectionView: Component<FolderSelectionViewProps> = (props) => {
|
|||||||
async function handleBrowse() {
|
async function handleBrowse() {
|
||||||
if (isLoading()) return
|
if (isLoading()) return
|
||||||
setFocusMode("new")
|
setFocusMode("new")
|
||||||
if (nativeDialogsAvailable) {
|
if (nativeDialogsAvailable && !prefersBuiltInFolderBrowser()) {
|
||||||
const fallbackPath = folders()[0]?.path
|
const fallbackPath = folders()[0]?.path
|
||||||
const selected = await openNativeFolderDialog({
|
const selected = await openNativeFolderDialog({
|
||||||
title: t("folderSelection.dialog.title"),
|
title: t("folderSelection.dialog.title"),
|
||||||
|
|||||||
Reference in New Issue
Block a user