fix(vwb): preserve static palette tools
This commit is contained in:
@@ -53,6 +53,13 @@ function mapCatalogAction(action: CatalogAction): ActionDefinition | null {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mergeCatalogActions(catalogActions: ActionDefinition[]): ActionDefinition[] {
|
||||||
|
const byType = new Map<ActionType, ActionDefinition>();
|
||||||
|
ACTIONS.forEach(action => byType.set(action.type, action));
|
||||||
|
catalogActions.forEach(action => byType.set(action.type, action));
|
||||||
|
return ACTIONS.map(action => byType.get(action.type) || action);
|
||||||
|
}
|
||||||
|
|
||||||
export default function ToolPalette() {
|
export default function ToolPalette() {
|
||||||
// État des catégories dépliées (toutes fermées par défaut sauf 'mouse')
|
// État des catégories dépliées (toutes fermées par défaut sauf 'mouse')
|
||||||
const [expandedCategories, setExpandedCategories] = useState<string[]>(['mouse']);
|
const [expandedCategories, setExpandedCategories] = useState<string[]>(['mouse']);
|
||||||
@@ -73,7 +80,7 @@ export default function ToolPalette() {
|
|||||||
.map((action: CatalogAction) => mapCatalogAction(action))
|
.map((action: CatalogAction) => mapCatalogAction(action))
|
||||||
.filter((action: ActionDefinition | null): action is ActionDefinition => action !== null);
|
.filter((action: ActionDefinition | null): action is ActionDefinition => action !== null);
|
||||||
if (!cancelled && mapped.length > 0) {
|
if (!cancelled && mapped.length > 0) {
|
||||||
setCatalogActions(mapped);
|
setCatalogActions(mergeCatalogActions(mapped));
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Catalogue VWB indisponible, palette statique utilisée:', error);
|
console.warn('Catalogue VWB indisponible, palette statique utilisée:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user