fix: Improve tool metadata and dropdown state management (#7257)
* 🐛 (component.py): Fix issue where tags attribute may not exist on tool object 🐛 (index.tsx): Fix bug where value may not be included in options before setting it * 🐛 (component.py): fix issue where tags list is empty if tool.tags is not defined, now default to [tool.name] to ensure at least one tag is present --------- Co-authored-by: Edwin Jose <edwin.jose@datastax.com>
This commit is contained in:
parent
9bb2878760
commit
ce5a4ff786
2 changed files with 7 additions and 1 deletions
|
|
@ -1166,7 +1166,7 @@ class Component(CustomComponent):
|
||||||
{
|
{
|
||||||
"name": tool.name,
|
"name": tool.name,
|
||||||
"description": tool.description,
|
"description": tool.description,
|
||||||
"tags": tool.tags,
|
"tags": tool.tags if hasattr(tool, "tags") and tool.tags else [tool.name],
|
||||||
"status": True, # Initialize all tools with status True
|
"status": True, # Initialize all tools with status True
|
||||||
}
|
}
|
||||||
for tool in tools
|
for tool in tools
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,12 @@ export default function Dropdown({
|
||||||
const [refreshOptions, setRefreshOptions] = useState(false);
|
const [refreshOptions, setRefreshOptions] = useState(false);
|
||||||
const refButton = useRef<HTMLButtonElement>(null);
|
const refButton = useRef<HTMLButtonElement>(null);
|
||||||
|
|
||||||
|
value = useMemo(() => {
|
||||||
|
if (!options.includes(value)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}, [value, options]);
|
||||||
// Initialize utilities and constants
|
// Initialize utilities and constants
|
||||||
const placeholderName = name
|
const placeholderName = name
|
||||||
? formatPlaceholderName(name)
|
? formatPlaceholderName(name)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue