feat: Add confirmation dialog for topic deletion
This commit is contained in:
parent
81a35d129d
commit
3a936e0f26
@ -139,6 +139,7 @@
|
|||||||
"topics.pinned": "Pinned Topics",
|
"topics.pinned": "Pinned Topics",
|
||||||
"topics.title": "Topics",
|
"topics.title": "Topics",
|
||||||
"topics.unpinned": "Unpinned Topics",
|
"topics.unpinned": "Unpinned Topics",
|
||||||
|
"topics.delete.title": "Are you sure you want to delete this topic? This action cannot be undone",
|
||||||
"translate": "Translate",
|
"translate": "Translate",
|
||||||
"topics.prompt": "Topic Prompts",
|
"topics.prompt": "Topic Prompts",
|
||||||
"topics.prompt.tips": "Topic Prompts: Additional supplementary prompts provided for the current topic",
|
"topics.prompt.tips": "Topic Prompts: Additional supplementary prompts provided for the current topic",
|
||||||
|
|||||||
@ -139,6 +139,7 @@
|
|||||||
"topics.pinned": "トピックを固定",
|
"topics.pinned": "トピックを固定",
|
||||||
"topics.title": "トピック",
|
"topics.title": "トピック",
|
||||||
"topics.unpinned": "固定解除",
|
"topics.unpinned": "固定解除",
|
||||||
|
"topics.delete.title": "このトピックを削除してもよろしいですか?この操作は元に戻せません",
|
||||||
"translate": "翻訳",
|
"translate": "翻訳",
|
||||||
"topics.prompt": "トピック提示語",
|
"topics.prompt": "トピック提示語",
|
||||||
"topics.prompt.tips": "トピック提示語:現在のトピックに対して追加の補足提示語を提供",
|
"topics.prompt.tips": "トピック提示語:現在のトピックに対して追加の補足提示語を提供",
|
||||||
|
|||||||
@ -139,6 +139,7 @@
|
|||||||
"topics.pinned": "Закрепленные темы",
|
"topics.pinned": "Закрепленные темы",
|
||||||
"topics.title": "Топики",
|
"topics.title": "Топики",
|
||||||
"topics.unpinned": "Открепленные темы",
|
"topics.unpinned": "Открепленные темы",
|
||||||
|
"topics.delete.title": "Вы уверены, что хотите удалить этот топик? Это действие нельзя отменить",
|
||||||
"translate": "Перевести",
|
"translate": "Перевести",
|
||||||
"topics.prompt": "Тематические подсказки",
|
"topics.prompt": "Тематические подсказки",
|
||||||
"topics.prompt.tips": "Тематические подсказки: Дополнительные подсказки, предоставленные для текущей темы",
|
"topics.prompt.tips": "Тематические подсказки: Дополнительные подсказки, предоставленные для текущей темы",
|
||||||
|
|||||||
@ -141,6 +141,7 @@
|
|||||||
"topics.pinned": "固定话题",
|
"topics.pinned": "固定话题",
|
||||||
"topics.title": "话题",
|
"topics.title": "话题",
|
||||||
"topics.unpinned": "取消固定",
|
"topics.unpinned": "取消固定",
|
||||||
|
"topics.delete.title": "确定要删除此话题吗?此操作无法撤销",
|
||||||
"translate": "翻译",
|
"translate": "翻译",
|
||||||
"topics.prompt": "话题提示词",
|
"topics.prompt": "话题提示词",
|
||||||
"topics.prompt.tips": "话题提示词: 针对当前话题提供额外的补充提示词",
|
"topics.prompt.tips": "话题提示词: 针对当前话题提供额外的补充提示词",
|
||||||
|
|||||||
@ -139,6 +139,7 @@
|
|||||||
"topics.pinned": "固定話題",
|
"topics.pinned": "固定話題",
|
||||||
"topics.title": "話題",
|
"topics.title": "話題",
|
||||||
"topics.unpinned": "取消固定",
|
"topics.unpinned": "取消固定",
|
||||||
|
"topics.delete.title": "確定要刪除此話題嗎?此操作無法撤銷",
|
||||||
"translate": "翻譯",
|
"translate": "翻譯",
|
||||||
"topics.prompt": "話題提示詞",
|
"topics.prompt": "話題提示詞",
|
||||||
"topics.prompt.tips": "話題提示詞:針對目前話題提供額外的補充提示詞",
|
"topics.prompt.tips": "話題提示詞:針對目前話題提供額外的補充提示詞",
|
||||||
|
|||||||
@ -21,7 +21,7 @@ import store from '@renderer/store'
|
|||||||
import { setGenerating } from '@renderer/store/runtime'
|
import { setGenerating } from '@renderer/store/runtime'
|
||||||
import { Assistant, Topic } from '@renderer/types'
|
import { Assistant, Topic } from '@renderer/types'
|
||||||
import { exportTopicAsMarkdown, exportTopicToNotion, topicToMarkdown } from '@renderer/utils/export'
|
import { exportTopicAsMarkdown, exportTopicToNotion, topicToMarkdown } from '@renderer/utils/export'
|
||||||
import { Dropdown, MenuProps, Tooltip } from 'antd'
|
import { Dropdown, MenuProps, Popconfirm, Tooltip } from 'antd'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { findIndex } from 'lodash'
|
import { findIndex } from 'lodash'
|
||||||
import { FC, useCallback } from 'react'
|
import { FC, useCallback } from 'react'
|
||||||
@ -54,7 +54,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
async (topic: Topic) => {
|
async (topic: Topic) => {
|
||||||
await modelGenerating()
|
await modelGenerating()
|
||||||
const index = findIndex(assistant.topics, (t) => t.id === topic.id)
|
const index = findIndex(assistant.topics, (t) => t.id === topic.id)
|
||||||
setActiveTopic(assistant.topics[index + 1 === assistant.topics.length ? 0 : index + 1])
|
setActiveTopic(assistant.topics[index + 1 === assistant.topics.length ? index - 1 : index + 1])
|
||||||
removeTopic(topic)
|
removeTopic(topic)
|
||||||
},
|
},
|
||||||
[assistant.topics, removeTopic, setActiveTopic]
|
[assistant.topics, removeTopic, setActiveTopic]
|
||||||
@ -219,7 +219,7 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
|
|
||||||
return menus
|
return menus
|
||||||
},
|
},
|
||||||
[assistant, assistants, onClearMessages, onPinTopic, onDeleteTopic, onMoveTopic, t, updateTopic]
|
[assistant, assistants, onClearMessages, onDeleteTopic, onPinTopic, onMoveTopic, t, updateTopic]
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -244,17 +244,33 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic
|
|||||||
)}
|
)}
|
||||||
<MenuButton className="pin">{topic.pinned && <PushpinOutlined />}</MenuButton>
|
<MenuButton className="pin">{topic.pinned && <PushpinOutlined />}</MenuButton>
|
||||||
{isActive && !topic.pinned && (
|
{isActive && !topic.pinned && (
|
||||||
<MenuButton
|
<Popconfirm
|
||||||
className="menu"
|
title={t('chat.topics.delete.title')}
|
||||||
onClick={(e) => {
|
placement="top"
|
||||||
e.stopPropagation()
|
okButtonProps={{ danger: true }}
|
||||||
|
okText={t('common.delete')}
|
||||||
|
onConfirm={async (e) => {
|
||||||
|
e?.stopPropagation()
|
||||||
if (assistant.topics.length === 1) {
|
if (assistant.topics.length === 1) {
|
||||||
return onClearMessages()
|
return onClearMessages()
|
||||||
}
|
}
|
||||||
onDeleteTopic(topic)
|
await modelGenerating()
|
||||||
}}>
|
const index = findIndex(assistant.topics, (t) => t.id === topic.id)
|
||||||
<CloseOutlined />
|
setActiveTopic(assistant.topics[index + 1 === assistant.topics.length ? index - 1 : index + 1])
|
||||||
</MenuButton>
|
removeTopic(topic)
|
||||||
|
}}
|
||||||
|
onCancel={(e) => e?.stopPropagation()}>
|
||||||
|
<MenuButton
|
||||||
|
className="menu"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation()
|
||||||
|
if (assistant.topics.length === 1) {
|
||||||
|
return onClearMessages()
|
||||||
|
}
|
||||||
|
}}>
|
||||||
|
<CloseOutlined />
|
||||||
|
</MenuButton>
|
||||||
|
</Popconfirm>
|
||||||
)}
|
)}
|
||||||
</TopicListItem>
|
</TopicListItem>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user