refactor(react/promoted_attributes): use simplified class name handling

This commit is contained in:
Elian Doran 2025-11-23 13:12:42 +02:00
parent 709a47bc6b
commit cd164049b7
No known key found for this signature in database

View File

@ -115,12 +115,15 @@ function PromotedAttributeCell(props: CellProps) {
}, [ props.shouldFocus ]); }, [ props.shouldFocus ]);
let correspondingInput: ComponentChild; let correspondingInput: ComponentChild;
let className: string | undefined;
switch (valueAttr.type) { switch (valueAttr.type) {
case "label": case "label":
correspondingInput = <LabelInput inputId={inputId} {...props} />; correspondingInput = <LabelInput inputId={inputId} {...props} />;
className = `promoted-attribute-label-${definition.labelType}`;
break; break;
case "relation": case "relation":
correspondingInput = <RelationInput inputId={inputId} {...props} />; correspondingInput = <RelationInput inputId={inputId} {...props} />;
className = "promoted-attribute-relation";
break; break;
default: default:
ws.logError(t(`promoted_attributes.unknown_attribute_type`, { type: valueAttr.type })); ws.logError(t(`promoted_attributes.unknown_attribute_type`, { type: valueAttr.type }));
@ -128,8 +131,7 @@ function PromotedAttributeCell(props: CellProps) {
} }
return ( return (
<div className={clsx("promoted-attribute-cell", <div className={clsx("promoted-attribute-cell", className)}>
valueAttr.type === "label" ? `promoted-attribute-label-${definition.labelType}` : "promoted-attribute-relation")}>
{definition.labelType !== "boolean" && <label for={inputId}>{definition.promotedAlias ?? valueName}</label>} {definition.labelType !== "boolean" && <label for={inputId}>{definition.promotedAlias ?? valueName}</label>}
{correspondingInput} {correspondingInput}
<ActionCell /> <ActionCell />