fix(electrobun): fix PathBrowser process.env.HOME, add dual browse buttons
- PathBrowser: resolveHome() via files.homeDir RPC (was process.env.HOME) - ProjectWizard: two browse buttons — 📂 native dialog + 🔍 in-app browser - In-app browser uses display toggle (rule 55), dirs-only filter - Native dialog: Electrobun Utils.openFileDialog (GTK chooser) - In-app browser: themed, dirs sorted first, proper breadcrumbs
This commit is contained in:
parent
bfc63bb595
commit
46b4893d2d
2 changed files with 20 additions and 2 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
let { onSelect, onClose }: Props = $props();
|
let { onSelect, onClose }: Props = $props();
|
||||||
|
|
||||||
const HOME = '/home/' + (typeof window !== 'undefined' ? '' : '');
|
let HOME = $state('/home');
|
||||||
const SHORTCUTS = [
|
const SHORTCUTS = [
|
||||||
{ label: 'Home', path: '~' },
|
{ label: 'Home', path: '~' },
|
||||||
{ label: 'Desktop', path: '~/Desktop' },
|
{ label: 'Desktop', path: '~/Desktop' },
|
||||||
|
|
@ -40,11 +40,22 @@
|
||||||
entries.filter(e => e.type === 'dir' && (filter === '' || e.name.toLowerCase().includes(filter.toLowerCase())))
|
entries.filter(e => e.type === 'dir' && (filter === '' || e.name.toLowerCase().includes(filter.toLowerCase())))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Load home dir from backend on first use
|
||||||
|
async function resolveHome(): Promise<string> {
|
||||||
|
if (HOME !== '/home') return HOME;
|
||||||
|
try {
|
||||||
|
const r = await appRpc.request['files.homeDir']({});
|
||||||
|
if (r?.path) HOME = r.path;
|
||||||
|
} catch {}
|
||||||
|
return HOME;
|
||||||
|
}
|
||||||
|
|
||||||
async function loadDir(dirPath: string) {
|
async function loadDir(dirPath: string) {
|
||||||
loading = true;
|
loading = true;
|
||||||
error = '';
|
error = '';
|
||||||
try {
|
try {
|
||||||
const expandedPath = dirPath.replace(/^~/, process.env.HOME ?? '/home');
|
const home = await resolveHome();
|
||||||
|
const expandedPath = dirPath.replace(/^~/, home);
|
||||||
const result = await appRpc.request['files.list']({ path: expandedPath });
|
const result = await appRpc.request['files.list']({ path: expandedPath });
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
error = result.error;
|
error = result.error;
|
||||||
|
|
|
||||||
|
|
@ -293,13 +293,20 @@
|
||||||
bind:value={localPath}
|
bind:value={localPath}
|
||||||
oninput={() => validatePath(localPath)} />
|
oninput={() => validatePath(localPath)} />
|
||||||
<button class="wz-browse-btn" onclick={handleNativeBrowse}
|
<button class="wz-browse-btn" onclick={handleNativeBrowse}
|
||||||
|
title="Open system folder picker"
|
||||||
aria-label={t('wizard.step1.browse' as any)}>📂</button>
|
aria-label={t('wizard.step1.browse' as any)}>📂</button>
|
||||||
|
<button class="wz-browse-btn" onclick={() => showBrowser = !showBrowser}
|
||||||
|
title="In-app folder browser"
|
||||||
|
aria-label="Browse">🔍</button>
|
||||||
{#if pathValid !== 'idle'}
|
{#if pathValid !== 'idle'}
|
||||||
<span class="wz-validation" style:color={validationColor(pathValid)}>
|
<span class="wz-validation" style:color={validationColor(pathValid)}>
|
||||||
{validationIcon(pathValid)}
|
{validationIcon(pathValid)}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
<div style:display={showBrowser ? 'block' : 'none'}>
|
||||||
|
<PathBrowser onSelect={handleBrowserSelect} onClose={() => showBrowser = false} />
|
||||||
|
</div>
|
||||||
{#if pathValid === 'valid' && isGitRepo}
|
{#if pathValid === 'valid' && isGitRepo}
|
||||||
<span class="wz-badge git-badge">{t('wizard.step1.gitDetected' as any)} ({gitBranch})</span>
|
<span class="wz-badge git-badge">{t('wizard.step1.gitDetected' as any)} ({gitBranch})</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue