hide disabled config buttons to avoid confusion (#184 )
This commit is contained in:
@@ -489,8 +489,10 @@ function ConfigCard({
|
|||||||
locateConfigMutation: any
|
locateConfigMutation: any
|
||||||
exportConfigMutation: any
|
exportConfigMutation: any
|
||||||
}) {
|
}) {
|
||||||
|
const isActive = configFile.id === activeConfigFile?.id
|
||||||
|
|
||||||
const disabledKeys = useMemo(() => {
|
const disabledKeys = useMemo(() => {
|
||||||
if (configFile.id !== activeConfigFile?.id) {
|
if (!isActive) {
|
||||||
return [
|
return [
|
||||||
'enable',
|
'enable',
|
||||||
'disable',
|
'disable',
|
||||||
@@ -522,7 +524,7 @@ function ConfigCard({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return disabled
|
return disabled
|
||||||
}, [configFile, activeConfigFile])
|
}, [configFile, isActive])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
@@ -676,81 +678,70 @@ function ConfigCard({
|
|||||||
</Dropdown>
|
</Dropdown>
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip content="Edit Config" color="foreground" size="lg">
|
{configFile.id !== 'default' && !isActive && !configFile.sync && (
|
||||||
<div>
|
<Tooltip content="Edit Config" color="foreground" size="lg">
|
||||||
<Button
|
<div>
|
||||||
isIconOnly={true}
|
<Button
|
||||||
variant="light"
|
isIconOnly={true}
|
||||||
size="lg"
|
variant="light"
|
||||||
onPress={() => {
|
size="lg"
|
||||||
setFocusedConfigId(configFile.id!)
|
onPress={() => {
|
||||||
setIsEditDrawerOpen(true)
|
setFocusedConfigId(configFile.id!)
|
||||||
}}
|
setIsEditDrawerOpen(true)
|
||||||
isDisabled={
|
}}
|
||||||
configFile.id === 'default' ||
|
>
|
||||||
configFile.id === activeConfigFile?.id ||
|
<PencilIcon className="w-5 h-5" />
|
||||||
Boolean(configFile.sync)
|
</Button>
|
||||||
}
|
</div>
|
||||||
>
|
</Tooltip>
|
||||||
<PencilIcon className="w-5 h-5" />
|
)}
|
||||||
</Button>
|
{configFile.id !== 'default' && (
|
||||||
</div>
|
<Tooltip content="Delete Config" color="danger" size="lg">
|
||||||
</Tooltip>
|
<div>
|
||||||
<Tooltip content="Delete Config" color="danger" size="lg">
|
<Button
|
||||||
<div>
|
isIconOnly={true}
|
||||||
<Button
|
variant="light"
|
||||||
isIconOnly={true}
|
size="lg"
|
||||||
variant="light"
|
onPress={() => {
|
||||||
size="lg"
|
setTimeout(async () => {
|
||||||
onPress={() => {
|
const confirmed = await ask(
|
||||||
setTimeout(async () => {
|
`Are you sure you want to delete config ${configFile.label}?`,
|
||||||
const confirmed = await ask(
|
{
|
||||||
`Are you sure you want to delete config ${configFile.label}?`,
|
title: 'Delete Config',
|
||||||
{
|
kind: 'warning',
|
||||||
title: 'Delete Config',
|
okLabel: 'Delete',
|
||||||
kind: 'warning',
|
cancelLabel: 'Cancel',
|
||||||
okLabel: 'Delete',
|
}
|
||||||
cancelLabel: 'Cancel',
|
)
|
||||||
|
|
||||||
|
if (!confirmed) {
|
||||||
|
return
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
if (!confirmed) {
|
if (!configFile.sync) {
|
||||||
return
|
const path = await getConfigPath({
|
||||||
}
|
id: configFile.id!,
|
||||||
|
validate: true,
|
||||||
|
})
|
||||||
|
|
||||||
if (configFile.id === 'default') {
|
await remove(path.replace('rclone.conf', ''), {
|
||||||
await message('Default config cannot be deleted', {
|
recursive: true,
|
||||||
title: 'Error',
|
})
|
||||||
kind: 'warning',
|
}
|
||||||
okLabel: 'OK',
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!configFile.sync) {
|
if (activeConfigFile?.id === configFile.id) {
|
||||||
const path = await getConfigPath({
|
useHostStore.getState().setActiveConfigFile('default')
|
||||||
id: configFile.id!,
|
}
|
||||||
validate: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
await remove(path.replace('rclone.conf', ''), {
|
useHostStore.getState().removeConfigFile(configFile.id!)
|
||||||
recursive: true,
|
}, 100)
|
||||||
})
|
}}
|
||||||
}
|
>
|
||||||
|
<Trash2Icon className="w-5 h-5" />
|
||||||
if (activeConfigFile?.id === configFile.id) {
|
</Button>
|
||||||
useHostStore.getState().setActiveConfigFile('default')
|
</div>
|
||||||
}
|
</Tooltip>
|
||||||
|
)}
|
||||||
useHostStore.getState().removeConfigFile(configFile.id!)
|
|
||||||
}, 100)
|
|
||||||
}}
|
|
||||||
isDisabled={configFile.id === 'default'}
|
|
||||||
>
|
|
||||||
<Trash2Icon className="w-5 h-5" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
<Tooltip content="Locate Config" color="foreground" size="lg">
|
<Tooltip content="Locate Config" color="foreground" size="lg">
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
Reference in New Issue
Block a user