better Commander integration
This commit is contained in:
+13
-19
@@ -4,8 +4,7 @@ import { Menu, MenuItem, PredefinedMenuItem } from '@tauri-apps/api/menu'
|
||||
import { resolveResource } from '@tauri-apps/api/path'
|
||||
import { TrayIcon, type TrayIconEvent } from '@tauri-apps/api/tray'
|
||||
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import { ask, message } from '@tauri-apps/plugin-dialog'
|
||||
import { openUrl } from '@tauri-apps/plugin-opener'
|
||||
import { message } from '@tauri-apps/plugin-dialog'
|
||||
import { platform } from '@tauri-apps/plugin-os'
|
||||
import { exit } from '@tauri-apps/plugin-process'
|
||||
import { usePersistedStore } from '../store/persisted'
|
||||
@@ -62,6 +61,18 @@ async function buildMenu() {
|
||||
menuItems.push(item)
|
||||
})
|
||||
|
||||
const commanderMenuItem = await MenuItem.new({
|
||||
id: 'commander',
|
||||
text: 'Commander',
|
||||
action: async () => {
|
||||
await openWindow({
|
||||
name: 'Commander',
|
||||
url: '/commander',
|
||||
})
|
||||
},
|
||||
})
|
||||
menuItems.push(commanderMenuItem)
|
||||
|
||||
const transfersMenuItem = await MenuItem.new({
|
||||
id: 'transfers',
|
||||
text: 'Transfers',
|
||||
@@ -116,23 +127,6 @@ async function buildMenu() {
|
||||
})
|
||||
menuItems.push(settingsItem)
|
||||
|
||||
const issuesItem = await MenuItem.new({
|
||||
id: 'issues',
|
||||
text: 'Issues?',
|
||||
action: async () => {
|
||||
const confirmed = await ask(`Please open an issue on Github and we'll get it sorted.`, {
|
||||
title: 'Sorry ):',
|
||||
kind: 'info',
|
||||
okLabel: 'Open Github',
|
||||
cancelLabel: 'Cancel',
|
||||
})
|
||||
if (confirmed) {
|
||||
await openUrl('https://github.com/rclone-ui/rclone-ui/issues')
|
||||
}
|
||||
},
|
||||
})
|
||||
menuItems.push(issuesItem)
|
||||
|
||||
const quitItem = await MenuItem.new({
|
||||
id: 'quit',
|
||||
text: 'Quit',
|
||||
|
||||
+13
-2
@@ -33,7 +33,7 @@ import {
|
||||
SearchCheckIcon,
|
||||
XCircleIcon,
|
||||
} from 'lucide-react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Group, Panel, Separator } from 'react-resizable-panels'
|
||||
import { onErrorDialog, reportError } from '../../lib/errors'
|
||||
import { getFsInfo } from '../../lib/format'
|
||||
@@ -77,6 +77,16 @@ export default function Browser() {
|
||||
|
||||
const remotes = remotesQuery.data ?? []
|
||||
const firstRemote = remotes[0] ?? null
|
||||
|
||||
const rightPanelTarget = useMemo(() => {
|
||||
const raw = new URLSearchParams(window.location.search).get('path')
|
||||
if (!raw) return null
|
||||
if (raw.includes(':/')) {
|
||||
const [remote, ...rest] = raw.split(':/')
|
||||
return { remote, path: rest.join('/') }
|
||||
}
|
||||
return { remote: 'UI_LOCAL_FS', path: raw }
|
||||
}, [])
|
||||
const handleDrop = useCallback(
|
||||
(items: SelectItem[], destination: string, _sourceSide: 'left' | 'right') => {
|
||||
setDropOperation({ items, destination })
|
||||
@@ -297,7 +307,8 @@ export default function Browser() {
|
||||
<FilePanel
|
||||
ref={rightPanelRef}
|
||||
sidebarPosition="right"
|
||||
initialRemote={firstRemote ?? 'UI_LOCAL_FS'}
|
||||
initialRemote={rightPanelTarget?.remote ?? firstRemote ?? 'UI_LOCAL_FS'}
|
||||
initialPath={rightPanelTarget?.path}
|
||||
selectionMode="both"
|
||||
allowFiles={true}
|
||||
allowMultiple={true}
|
||||
|
||||
+5
-31
@@ -10,7 +10,7 @@ import type { fetchMountList, fetchServeList } from '../lib/rclone/api'
|
||||
import rclone from '../lib/rclone/client'
|
||||
import { SERVE_TYPES } from '../lib/rclone/constants'
|
||||
import { openFullWindow } from '../lib/window'
|
||||
import { selectCurrentHost, usePersistedStore } from '../store/persisted'
|
||||
import { usePersistedStore } from '../store/persisted'
|
||||
import { COMMAND_CONFIG, COMMAND_DESCRIPTIONS, COMMAND_KEYWORDS } from './constants'
|
||||
import type {
|
||||
ToolbarActionArgs,
|
||||
@@ -788,41 +788,15 @@ const actions: ToolbarActionDefinition[] = [
|
||||
return
|
||||
}
|
||||
|
||||
const currentHost = selectCurrentHost(usePersistedStore.getState())
|
||||
const hostUrl = currentHost?.url
|
||||
|
||||
if (!hostUrl) {
|
||||
await notify({
|
||||
title: 'Error',
|
||||
body: 'No host URL found',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
let auth: string | undefined
|
||||
const authUser = currentHost?.authUser
|
||||
|
||||
if (authUser) {
|
||||
const authPassword = currentHost?.authPassword
|
||||
auth = btoa(`${authUser}:${authPassword ?? ''}`)
|
||||
}
|
||||
|
||||
const normalizedHostUrl = hostUrl.replace(TRAILING_SLASH_REGEX, '')
|
||||
const browseTargetUrl = `${normalizedHostUrl}/[${remote}:]/`
|
||||
let fullUrl = `browse.html?url=${encodeURIComponent(browseTargetUrl)}`
|
||||
|
||||
if (auth) {
|
||||
fullUrl += `&auth=${encodeURIComponent(auth)}`
|
||||
}
|
||||
|
||||
await openFullWindow({
|
||||
name: 'Browse',
|
||||
url: fullUrl,
|
||||
name: 'Commander',
|
||||
url: `/commander?path=${encodeURIComponent(`${remote}:/`)}`,
|
||||
hideTitleBar: true,
|
||||
})
|
||||
} catch (error) {
|
||||
captureException(error)
|
||||
await message('Could not open browse window. Please try again.', {
|
||||
await message('Could not open Commander window. Please try again.', {
|
||||
title: 'Error',
|
||||
kind: 'error',
|
||||
okLabel: 'OK',
|
||||
|
||||
Reference in New Issue
Block a user