mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-23 04:09:49 +00:00
feat: add model deselection functionality in ComboFormModal and ComboDetailPage (#889)
- Implemented handleDeselectModel function to allow users to deselect models in both ComboFormModal and ComboDetailPage. - Updated ModelSelectModal to handle deselection and visually indicate selected models. - Enhanced user experience by allowing models to be removed from the selection without closing the modal.
This commit is contained in:
@@ -390,6 +390,10 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders, kindF
|
||||
}
|
||||
};
|
||||
|
||||
const handleDeselectModel = (model) => {
|
||||
setModels(models.filter((m) => m !== model.value));
|
||||
};
|
||||
|
||||
const handleRemoveModel = (index) => {
|
||||
setModels(models.filter((_, i) => i !== index));
|
||||
};
|
||||
@@ -502,10 +506,13 @@ function ComboFormModal({ isOpen, combo, onClose, onSave, activeProviders, kindF
|
||||
isOpen={showModelSelect}
|
||||
onClose={() => setShowModelSelect(false)}
|
||||
onSelect={handleAddModel}
|
||||
onDeselect={handleDeselectModel}
|
||||
activeProviders={activeProviders}
|
||||
modelAliases={modelAliases}
|
||||
title="Add Model to Combo"
|
||||
kindFilter={kindFilter}
|
||||
addedModelValues={models}
|
||||
closeOnSelect={false}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -126,6 +126,14 @@ export default function ComboDetailPage() {
|
||||
await saveCombo({ models: next });
|
||||
};
|
||||
|
||||
const handleDeselectModel = async (model) => {
|
||||
const value = model?.value || model;
|
||||
if (!value || !providers.includes(value)) return;
|
||||
const next = providers.filter((p) => p !== value);
|
||||
setProviders(next);
|
||||
await saveCombo({ models: next });
|
||||
};
|
||||
|
||||
const handleRemoveProvider = async (idx) => {
|
||||
const next = providers.filter((_, i) => i !== idx);
|
||||
setProviders(next);
|
||||
@@ -389,10 +397,13 @@ export default function ComboDetailPage() {
|
||||
isOpen={showPicker}
|
||||
onClose={() => setShowPicker(false)}
|
||||
onSelect={handleAddModel}
|
||||
onDeselect={handleDeselectModel}
|
||||
activeProviders={connections}
|
||||
modelAliases={modelAliases}
|
||||
title={`Add ${kindLabel} Model`}
|
||||
kindFilter={combo.kind}
|
||||
addedModelValues={providers}
|
||||
closeOnSelect={false}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user