mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 20:12:38 +08:00
feat(ModelList): add bulk add/remove functionality for models with confirmation dialog
- Implemented onAddAll and onRemoveAll functions to handle bulk actions for models. - Added confirmation dialog for adding all models to the list, enhancing user experience. - Updated translations for confirmation messages in multiple languages.
This commit is contained in:
parent
c262fd75e1
commit
d3c348f8f2
@ -214,6 +214,35 @@ const PopupContainer: React.FC<Props> = ({ provider: _provider, resolve }) => {
|
||||
|
||||
const renderTopTools = useCallback(() => {
|
||||
const isAllFilteredInProvider = list.length > 0 && list.every((model) => isModelInProvider(provider, model.id))
|
||||
|
||||
const onRemoveAll = () => {
|
||||
list.filter((model) => isModelInProvider(provider, model.id)).forEach(onRemoveModel)
|
||||
}
|
||||
|
||||
const onAddAll = () => {
|
||||
const wouldAddModel = list.filter((model) => !isModelInProvider(provider, model.id))
|
||||
window.modal.confirm({
|
||||
title: t('settings.models.manage.add_listed'),
|
||||
content: t('settings.models.manage.add_listed.confirm'),
|
||||
centered: true,
|
||||
onOk: () => {
|
||||
if (provider.id === 'new-api') {
|
||||
if (models.every(isValidNewApiModel)) {
|
||||
wouldAddModel.forEach(onAddModel)
|
||||
} else {
|
||||
NewApiBatchAddModelPopup.show({
|
||||
title: t('settings.models.add.batch_add_models'),
|
||||
batchModels: wouldAddModel,
|
||||
provider
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wouldAddModel.forEach(onAddModel)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
destroyTooltipOnHide
|
||||
@ -228,24 +257,7 @@ const PopupContainer: React.FC<Props> = ({ provider: _provider, resolve }) => {
|
||||
size="large"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
if (isAllFilteredInProvider) {
|
||||
list.filter((model) => isModelInProvider(provider, model.id)).forEach(onRemoveModel)
|
||||
} else {
|
||||
const wouldAddModel = list.filter((model) => !isModelInProvider(provider, model.id))
|
||||
if (provider.id === 'new-api') {
|
||||
if (models.every(isValidNewApiModel)) {
|
||||
wouldAddModel.forEach(onAddModel)
|
||||
} else {
|
||||
NewApiBatchAddModelPopup.show({
|
||||
title: t('settings.models.add.batch_add_models'),
|
||||
batchModels: wouldAddModel,
|
||||
provider
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wouldAddModel.forEach(onAddModel)
|
||||
}
|
||||
}
|
||||
isAllFilteredInProvider ? onRemoveAll() : onAddAll()
|
||||
}}
|
||||
disabled={loading || list.length === 0}
|
||||
/>
|
||||
|
||||
@ -2170,6 +2170,7 @@
|
||||
"models.empty": "No models found",
|
||||
"models.enable_topic_naming": "Topic Auto Naming",
|
||||
"models.manage.add_listed": "Add models to the list",
|
||||
"models.manage.add_listed.confirm": "Are you sure you want to add all models to the list?",
|
||||
"models.manage.add_whole_group": "Add the whole group",
|
||||
"models.manage.remove_listed": "Remove models from the list",
|
||||
"models.manage.remove_model": "Remove model",
|
||||
|
||||
@ -2170,6 +2170,7 @@
|
||||
"models.empty": "モデルが見つかりません",
|
||||
"models.enable_topic_naming": "トピックの自動命名",
|
||||
"models.manage.add_listed": "リストにモデルを追加",
|
||||
"models.manage.add_listed.confirm": "すべてのモデルをリストに追加しますか?",
|
||||
"models.manage.add_whole_group": "グループ全体を追加",
|
||||
"models.manage.remove_listed": "リストからモデルを削除",
|
||||
"models.manage.remove_model": "モデルを削除",
|
||||
|
||||
@ -2170,6 +2170,7 @@
|
||||
"models.empty": "Модели не найдены",
|
||||
"models.enable_topic_naming": "Автоматическое переименование топика",
|
||||
"models.manage.add_listed": "Добавить в список",
|
||||
"models.manage.add_listed.confirm": "Вы уверены, что хотите добавить все модели в список?",
|
||||
"models.manage.add_whole_group": "Добавить всю группу",
|
||||
"models.manage.remove_listed": "Удалить из списка",
|
||||
"models.manage.remove_model": "Удалить модель",
|
||||
|
||||
@ -2170,6 +2170,7 @@
|
||||
"models.empty": "没有模型",
|
||||
"models.enable_topic_naming": "话题自动重命名",
|
||||
"models.manage.add_listed": "添加列表中的模型",
|
||||
"models.manage.add_listed.confirm": "确定要添加所有模型到列表吗?",
|
||||
"models.manage.add_whole_group": "添加整个分组",
|
||||
"models.manage.remove_listed": "移除列表中的模型",
|
||||
"models.manage.remove_model": "移除模型",
|
||||
|
||||
@ -2170,6 +2170,7 @@
|
||||
"models.empty": "找不到模型",
|
||||
"models.enable_topic_naming": "話題自動重新命名",
|
||||
"models.manage.add_listed": "添加列表中的模型",
|
||||
"models.manage.add_listed.confirm": "確定要添加所有模型到列表嗎?",
|
||||
"models.manage.add_whole_group": "新增整個分組",
|
||||
"models.manage.remove_listed": "移除列表中的模型",
|
||||
"models.manage.remove_model": "移除模型",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user