Skip to content

Commit

Permalink
feat: add a cancel button to each modal
Browse files Browse the repository at this point in the history
  • Loading branch information
youngle316 committed Aug 12, 2023
1 parent d287f95 commit e5faa5b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 13 deletions.
6 changes: 4 additions & 2 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"dark": "Dark",
"light": "Light",
"system": "System",
"modelSettingTitle": "Stream AI responses word by word (typing animation)"
"modelSettingTitle": "Stream AI responses word by word (typing animation)",
"cancel": "Cancel"
},
"response": {
"ApiKeyIsRequired": "Please enter your OpenAI API key."
Expand Down Expand Up @@ -65,6 +66,7 @@
"advancedOptions": "View Advanced Options (Context Limit etc.)",
"contextLimit": "Context Limit",
"contextLimitDes": "The number of messages to include in the context for the AI assistant. When set to 1, the AI assistant will only see and remember the most recent message.",
"all": "All"
"all": "All",
"cancel": "Cancel"
}
}
6 changes: 4 additions & 2 deletions messages/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"dark": "深色主题",
"light": "浅色主题",
"system": "跟随系统",
"modelSettingTitle": "逐字逐句地流式传输AI的回答(打字动画)"
"modelSettingTitle": "逐字逐句地流式传输AI的回答(打字动画)",
"cancel": "取消"
},
"response": {
"ApiKeyIsRequired": "请输入 OpenAI API 密钥"
Expand Down Expand Up @@ -65,6 +66,7 @@
"advancedOptions": "查看高级选项(上下文限制 等)",
"contextLimit": "上下文限制",
"contextLimitDes": "AI 助手上下文中包含的信息数量。当设置为 1 时,AI 助手将只看到并记住最近的信息。",
"all": "所有"
"all": "所有",
"cancel": "取消"
}
}
17 changes: 15 additions & 2 deletions src/app/[locale]/SettingContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const AppSetting = () => {
setIsModalOpen(false);
};

const cancelSetting = () => {
setIsModalOpen(false);
};

return (
<div>
<div className="mb-4">
Expand Down Expand Up @@ -117,10 +121,19 @@ const AppSetting = () => {
placeholder="https://api.openai.com/v1"
/>
</div>
<button type="button" className="primary-button" onClick={saveSetting}>
</form>
<div className="flex justify-center gap-2">
<button
type="button"
className="basic_button bg-blue-600 hover:bg-blue-500"
onClick={saveSetting}
>
{t("save")}
</button>
</form>
<button type="button" className="basic_button" onClick={cancelSetting}>
{t("cancel")}
</button>
</div>
</div>
);
};
Expand Down
23 changes: 16 additions & 7 deletions src/app/[locale]/chat/[chatId]/PageModelSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ function PageModelSet() {
setIsModalOpen(false);
};

const cancelSetting = () => {
setIsModalOpen(false);
};

const contextLimitChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
setContextLimit(Number(e.target.value));
};
Expand Down Expand Up @@ -123,13 +127,18 @@ function PageModelSet() {
</Disclosure>
</div>

<button
type="button"
className="primary-button"
onClick={saveModelSetting}
>
{t("save")}
</button>
<div className="flex justify-center gap-2">
<button
type="button"
className="basic_button bg-blue-600 hover:bg-blue-500"
onClick={saveModelSetting}
>
{t("save")}
</button>
<button type="button" className="basic_button" onClick={cancelSetting}>
{t("cancel")}
</button>
</div>
</div>
);
}
Expand Down

0 comments on commit e5faa5b

Please sign in to comment.