Faisal Amir 539b467141
ui: interface revamp (#429)
* feat: adding create bot functionality

Signed-off-by: James <james@jan.ai>

* update the temperature progress bar

Signed-off-by: James <james@jan.ai>

* WIP baselayout

* Mapping plugins with available preferences

* Added loader component

* WIP working another screen

* Cleanup types and avoid import one by one

* Prepare bottom bar

* Add css variables colors to enable user select the accent

* Enable change accent color

* Seperate css variable

* Fix conflict

* Add blank state of my model empty

* Restyle explore models page

* Enable user config left sidebar

* Restyle my models page

* WIP styling chat page

* Restyling chat message

* Fix conflict

* Adde form preferences setting plugins

* Fixed form bot info

* Sidebar bot chat

* Showing rightbar for both setting when user created bot

* Fix style bot info

* Using overflow auto intead of scroll

* Remove script built UI from root package

* Fix missig import

* Resolve error linter

* fix e2e tests

Signed-off-by: James <james@jan.ai>

---------

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
2023-10-24 10:59:12 +07:00

69 lines
2.2 KiB
TypeScript

import React, { useCallback } from 'react'
import { ModelStatus, ModelStatusComponent } from '../ModelStatusComponent'
import { useAtomValue } from 'jotai'
import ModelActionButton, { ModelActionType } from '../ModelActionButton'
import useStartStopModel from '@hooks/useStartStopModel'
import useDeleteModel from '@hooks/useDeleteModel'
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
import { toGigabytes } from '@utils/converter'
type Props = {
model: AssistantModel
}
const ModelRow: React.FC<Props> = ({ model }) => {
const { startModel, stopModel } = useStartStopModel()
const activeModel = useAtomValue(activeAssistantModelAtom)
const { deleteModel } = useDeleteModel()
let status = ModelStatus.Installed
if (activeModel && activeModel._id === model._id) {
status = ModelStatus.Active
}
let actionButtonType = ModelActionType.Start
if (activeModel && activeModel._id === model._id) {
actionButtonType = ModelActionType.Stop
}
const onModelActionClick = (action: ModelActionType) => {
if (action === ModelActionType.Start) {
startModel(model._id)
} else {
stopModel(model._id)
}
}
const onDeleteClick = useCallback(() => {
deleteModel(model)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [model])
return (
<tr className="bg-background/50 border-border border-b last:rounded-lg last:border-b-0">
<td className="text-muted-foreground whitespace-nowrap px-3 font-semibold">
{model.name}
<span className="ml-2 font-semibold">v{model.version}</span>
</td>
<td className="text-muted-foreground whitespace-nowrap px-3">
<div className="flex flex-col justify-start">
<span>GGUF</span>
</div>
</td>
<td className="text-muted-foreground whitespace-nowrap px-3">
{toGigabytes(model.size)}
</td>
<td className="text-muted-foreground whitespace-nowrap px-3">
<ModelStatusComponent status={status} />
</td>
<ModelActionButton
type={actionButtonType}
onActionClick={onModelActionClick}
onDeleteClick={onDeleteClick}
/>
</tr>
)
}
export default ModelRow