diff --git a/src/pages/Purge.tsx b/src/pages/Purge.tsx
index c165c5a..0f6933a 100644
--- a/src/pages/Purge.tsx
+++ b/src/pages/Purge.tsx
@@ -9,6 +9,7 @@ import {
FoldersIcon,
PlayIcon,
WrenchIcon,
+ XIcon,
} from 'lucide-react'
import { useEffect, useState } from 'react'
import { useSearchParams } from 'react-router-dom'
@@ -24,6 +25,7 @@ import { usePersistedStore } from '../../lib/store'
import CronEditor from '../components/CronEditor'
import OptionsSection from '../components/OptionsSection'
import { PathField } from '../components/PathFinder'
+import TemplatesDropdown from '../components/TemplatesDropdown'
export default function Purge() {
const [searchParams] = useSearchParams()
@@ -185,6 +187,53 @@ export default function Purge() {
}
}
+ async function handleAddToTemplates(name: string) {
+ if (!!jsonError || !source) {
+ await message('Your config for this operation is incomplete or has errors.', {
+ title: 'Error',
+ kind: 'error',
+ })
+ return
+ }
+ const templates = usePersistedStore.getState().templates
+
+ const mergedOptions = {
+ filterOptions,
+ configOptions,
+ source,
+ }
+
+ const newTemplates = [
+ ...templates,
+ {
+ id: Math.floor(Date.now() / 1000).toString(),
+ name,
+ operation: 'purge',
+ options: mergedOptions,
+ } as const,
+ ]
+
+ usePersistedStore.setState({ templates: newTemplates })
+ }
+
+ async function handleSelectTemplate(templateId: string) {
+ const template = usePersistedStore
+ .getState()
+ .templates.find((template) => template.id === templateId)
+
+ if (!template) {
+ await message('Template not found', {
+ title: 'Error',
+ kind: 'error',
+ })
+ return
+ }
+
+ setFilterOptions(template.options.filterOptions)
+ setConfigOptions(template.options.configOptions)
+ setSource(template.options.source)
+ }
+
const buttonText = (() => {
if (isLoading) return 'STARTING...'
if (!source) return 'Please select a source path'
@@ -196,7 +245,7 @@ export default function Purge() {
if (isLoading) return
if (!source) return