jan/web/screens/Settings/Engines/DeleteEngineVariant.tsx
Faisal Amir 2a0601f75a
feat: remote engine management (#4364)
* feat: remote engine management

* chore: fix linter issue

* chore: remove unused imports

* fix: populate engines, models and legacy settings (#4403)

* fix: populate engines, models and legacy settings

* chore: legacy logics update configured remote engine

* fix: check exist path before reading

* fix: engines and models persist - race condition

* chore: update issue state

* test: update test cases

* chore: bring back Cortex extension settings

* chore: setup button gear / plus based apikey

* chore: fix remote engine from welcome screen

* chore: resolve linter issue

* chore: support request headers template

* chore: update engines using header_template instead of api_key_template

* chore: update models on changes

* fix: anthropic response template

* chore: fix welcome screen and debounce update value input

* chore: update engines list on changes

* chore: update engines list on change

* chore: update desc form add modal remote engines

* chore: bump cortex version to latest RC

* chore: fix linter

* fix: transform payload of Anthropic and OpenAI

* fix: typo

* fix: openrouter model id for auto routing

* chore: remove remote engine URL setting

* chore: add cohere engine and model support

* fix: should not clean on app launch - models list display issue

* fix: local engine check logic

* chore: bump app version to latest release 0.5.13

* test: fix failed tests

---------

Co-authored-by: Louis <louis@jan.ai>
2025-01-14 17:29:56 +07:00

77 lines
2.0 KiB
TypeScript

import { memo, useState } from 'react'
import { EngineReleased, InferenceEngine } from '@janhq/core'
import { Button, Modal, ModalClose } from '@janhq/joi'
import { Trash2Icon } from 'lucide-react'
import {
uninstallEngine,
useGetDefaultEngineVariant,
useGetInstalledEngines,
} from '@/hooks/useEngineManagement'
const DeleteEngineVariant = ({
variant,
engine,
}: {
variant: EngineReleased
engine: InferenceEngine
}) => {
const [open, setOpen] = useState(false)
const { mutate: mutateInstalledEngines } = useGetInstalledEngines(engine)
const { defaultEngineVariant } = useGetDefaultEngineVariant(engine)
return (
<Modal
title={<span>Delete {variant.name}</span>}
open={open}
onOpenChange={() => setOpen(!open)}
trigger={
<Button theme="icon" variant="outline" onClick={() => setOpen(!open)}>
<Trash2Icon
size={14}
className="text-[hsla(var(--text-secondary))]"
/>
</Button>
}
content={
<div>
<p className="text-[hsla(var(--text-secondary))]">
Are you sure you want to delete this variant?
</p>
<div className="mt-4 flex justify-end gap-x-2">
<ModalClose
asChild
onClick={(e) => {
setOpen(!open)
e.stopPropagation()
}}
>
<Button theme="ghost">No</Button>
</ModalClose>
<ModalClose asChild>
<Button
theme="destructive"
onClick={() => {
uninstallEngine(engine, {
variant: variant.name,
version: String(defaultEngineVariant?.version),
})
mutateInstalledEngines()
}}
autoFocus
>
Yes
</Button>
</ModalClose>
</div>
</div>
}
/>
)
}
export default memo(DeleteEngineVariant)