Tip on Delete
Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
+47
-7
@@ -1,4 +1,5 @@
|
||||
import { Accordion, AccordionItem, Avatar, Button } from '@heroui/react'
|
||||
import { useAutoAnimate } from '@formkit/auto-animate/react'
|
||||
import { Accordion, AccordionItem, Alert, Avatar, Button } from '@heroui/react'
|
||||
import { message } from '@tauri-apps/plugin-dialog'
|
||||
import cronstrue from 'cronstrue'
|
||||
import {
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
getConfigFlags,
|
||||
getCurrentGlobalFlags,
|
||||
getFilterFlags,
|
||||
getRemote,
|
||||
startDelete,
|
||||
} from '../../lib/rclone/api'
|
||||
import { RCLONE_CONFIG_DEFAULTS } from '../../lib/rclone/constants'
|
||||
@@ -24,6 +26,17 @@ import CronEditor from '../components/CronEditor'
|
||||
import OptionsSection from '../components/OptionsSection'
|
||||
import { PathField } from '../components/PathFinder'
|
||||
|
||||
const SUPPORTS_PURGE = [
|
||||
'box',
|
||||
'dropbox',
|
||||
'gcs',
|
||||
'drive',
|
||||
'azureblob',
|
||||
'onedrive',
|
||||
'protondrive',
|
||||
'webdav',
|
||||
]
|
||||
|
||||
export default function Delete() {
|
||||
const [searchParams] = useSearchParams()
|
||||
|
||||
@@ -49,12 +62,15 @@ export default function Delete() {
|
||||
|
||||
const [currentGlobalOptions, setCurrentGlobalOptions] = useState<any[]>([])
|
||||
|
||||
const [supportsPurge, setSupportsPurge] = useState(false)
|
||||
const [animationParent] = useAutoAnimate()
|
||||
|
||||
const sourceRemoteName = getRemoteName(sourceFs)
|
||||
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: when unlocking, we don't want to re-run the effect
|
||||
useEffect(() => {
|
||||
const storeData = usePersistedStore.getState()
|
||||
|
||||
const sourceRemote = getRemoteName(sourceFs?.[0])
|
||||
|
||||
let mergedFilterDefaults = {}
|
||||
let mergedConfigDefaults = {}
|
||||
|
||||
@@ -85,7 +101,7 @@ export default function Delete() {
|
||||
}
|
||||
|
||||
// Only merge defaults for remote paths
|
||||
if (sourceRemote) mergeRemoteDefaults(sourceRemote)
|
||||
if (sourceRemoteName) mergeRemoteDefaults(sourceRemoteName)
|
||||
|
||||
if (Object.keys(mergedFilterDefaults).length > 0 && !filterOptionsLocked) {
|
||||
setFilterOptionsJson(JSON.stringify(mergedFilterDefaults, null, 2))
|
||||
@@ -94,7 +110,14 @@ export default function Delete() {
|
||||
if (Object.keys(mergedConfigDefaults).length > 0 && !configOptionsLocked) {
|
||||
setConfigOptionsJson(JSON.stringify(mergedConfigDefaults, null, 2))
|
||||
}
|
||||
}, [sourceFs])
|
||||
}, [sourceRemoteName])
|
||||
|
||||
useEffect(() => {
|
||||
if (!sourceRemoteName) return
|
||||
getRemote(sourceRemoteName).then((remote) =>
|
||||
setSupportsPurge(SUPPORTS_PURGE.includes(remote.type))
|
||||
)
|
||||
}, [sourceRemoteName])
|
||||
|
||||
useEffect(() => {
|
||||
getCurrentGlobalFlags().then((flags) => setCurrentGlobalOptions(flags))
|
||||
@@ -192,14 +215,19 @@ export default function Delete() {
|
||||
return (
|
||||
<div className="flex flex-col h-screen gap-10 pt-10">
|
||||
{/* Main Content */}
|
||||
<div className="flex flex-col flex-1 w-full max-w-3xl gap-6 mx-auto">
|
||||
<div
|
||||
className="flex flex-col flex-1 w-full max-w-3xl gap-6 mx-auto"
|
||||
ref={animationParent}
|
||||
>
|
||||
{/* Path Display */}
|
||||
<PathField
|
||||
path={sourceFs || ''}
|
||||
setPath={setSourceFs}
|
||||
label="Path"
|
||||
placeholder="Enter a remote:/path to delete"
|
||||
showPicker={false}
|
||||
showPicker={true}
|
||||
allowedKeys={['REMOTES', 'FAVORITES']}
|
||||
showFiles={true}
|
||||
/>
|
||||
|
||||
{/* <div className="flex flex-col gap-2 pt-2 -mb-5">
|
||||
@@ -208,6 +236,18 @@ export default function Delete() {
|
||||
</Switch>
|
||||
</div> */}
|
||||
|
||||
{supportsPurge && (
|
||||
<Alert
|
||||
color="primary"
|
||||
title="LET ME SHARE A TIP"
|
||||
variant="faded"
|
||||
className="min-h-none h-fit max-h-fit"
|
||||
>
|
||||
If you're deleting a entire folder, "{sourceRemoteName}" supports Purge
|
||||
which is more efficient!
|
||||
</Alert>
|
||||
)}
|
||||
|
||||
<Accordion>
|
||||
<AccordionItem
|
||||
key="filters"
|
||||
|
||||
@@ -380,6 +380,18 @@ export default function Mount() {
|
||||
<div className="sticky bottom-0 z-50 flex items-center justify-center flex-none gap-5 p-4 border-t border-neutral-500/20 bg-neutral-900/50 backdrop-blur-lg">
|
||||
{isMounted ? (
|
||||
<>
|
||||
<Button
|
||||
fullWidth={true}
|
||||
size="lg"
|
||||
onPress={async () => {
|
||||
await getCurrentWindow().hide()
|
||||
await getCurrentWindow().destroy()
|
||||
}}
|
||||
data-focus-visible="false"
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
fullWidth={true}
|
||||
size="lg"
|
||||
|
||||
+1
-1
@@ -210,7 +210,7 @@ export default function Purge() {
|
||||
label="Path"
|
||||
placeholder="Enter a remote:/path to purge"
|
||||
showPicker={true}
|
||||
allowedKeys={['REMOTES']}
|
||||
allowedKeys={['REMOTES', 'FAVORITES']}
|
||||
showFiles={false}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user