chore: update create assistant link

This commit is contained in:
Steven
2023-04-18 00:27:27 +08:00
parent 74ebcd0799
commit 7b4482025a
4 changed files with 52 additions and 20 deletions

View File

@ -6,6 +6,7 @@ import { Conversation } from "@/types";
import TextField from "./kit/TextField";
import Modal from "./kit/Modal";
import Select from "./kit/Select";
import Icon from "./Icon";
interface Props {
conversation: Conversation;
@ -52,9 +53,16 @@ const UpdateConversationModal = (props: Props) => {
<Select className="w-full" value={assistantId} itemList={assistantItems} onValueChange={(value) => setAssistantId(value)} />
{currentAssistant && (
<div className="w-full flex flex-col justify-start items-start">
<p className="block text-sm text-gray-700 mt-1 ml-3">{currentAssistant.description}</p>
<p className="block text-sm text-gray-700 mt-2 mx-3">{currentAssistant.description}</p>
</div>
)}
<a
className="mt-1 mx-3 text-sm text-blue-600 underline hover:opacity-80"
href="https://github.com/sqlchat/sqlchat/tree/main/assistants"
target="_blank"
>
{t("assistant.create-your-bot")} <Icon.FiExternalLink className="inline-block -mt-0.5" />
</a>
</div>
<div className="w-full flex flex-row justify-end items-center mt-4 space-x-2">
<button className="btn btn-outline" onClick={close}>

View File

@ -23,7 +23,8 @@
"select-database": "Select your database"
},
"assistant": {
"self": "Bot"
"self": "Bot",
"create-your-bot": "Can't find the bot you need? Create one"
},
"execution": {
"title": "Execute SQL",

View File

@ -23,7 +23,8 @@
"select-database": "选择数据库"
},
"assistant": {
"self": "机器人"
"self": "机器人",
"create-your-bot": "找不到需要的机器人?创建一个"
},
"execution": {
"title": "执行 SQL",

View File

@ -1,5 +1,7 @@
import { merge } from "lodash-es";
import { create } from "zustand";
import { Connection, Database } from "@/types";
import { persist } from "zustand/middleware";
import { Connection, Database, Timestamp } from "@/types";
interface ExecuteQueryContext {
connection: Connection;
@ -7,25 +9,45 @@ interface ExecuteQueryContext {
statement: string;
}
interface QueryHistory {
context: ExecuteQueryContext;
createdAt: Timestamp;
}
interface QueryState {
context?: ExecuteQueryContext;
showDrawer: boolean;
queryHistory: QueryHistory[];
context?: ExecuteQueryContext;
toggleDrawer: (show?: boolean) => void;
setContext: (context: ExecuteQueryContext | undefined) => void;
}
export const useQueryStore = create<QueryState>()((set) => ({
showDrawer: false,
toggleDrawer: (show) => {
set((state) => ({
...state,
showDrawer: show ?? !state.showDrawer,
}));
},
setContext: (context) => {
set((state) => ({
...state,
context,
}));
},
}));
export const useQueryStore = create<QueryState>()(
persist(
(set) => ({
showDrawer: false,
queryHistory: [],
toggleDrawer: (show) => {
set((state) => ({
...state,
showDrawer: show ?? !state.showDrawer,
}));
},
setContext: (context) => {
set((state) => ({
...state,
context,
}));
},
}),
{
name: "query-storage",
merge: (persistedState, currentState) => {
return {
...merge(currentState, persistedState),
context: undefined,
};
},
}
)
);