Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 174 additions & 91 deletions src/visualBuilder/components/__test__/fieldLabelWrapper.test.tsx

Large diffs are not rendered by default.

48 changes: 42 additions & 6 deletions src/visualBuilder/components/fieldLabelWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function FieldLabelWrapperComponent(
getReferenceParentMap()
]);
const entryUid = props.fieldMetadata.entry_uid;

const referenceData = referenceParentMap[entryUid];
const isReference = !!referenceData;

Expand Down Expand Up @@ -171,6 +171,19 @@ function FieldLabelWrapperComponent(
entryWorkflowStageDetails
);

const handleLinkVariant = () => {
if (fieldSchema.field_metadata?.canLinkVariant) {
visualBuilderPostMessage?.send(
VisualBuilderPostMessageEvents.OPEN_LINK_VARIANT_MODAL,
{
contentTypeUid:
props.fieldMetadata
.content_type_uid,
}
);
}
};

const currentFieldDisplayName =
displayNames?.[props.fieldMetadata.cslpValue] ??
fieldSchema.display_name;
Expand All @@ -188,8 +201,31 @@ function FieldLabelWrapperComponent(
"visual-builder__tooltip--persistent"
]
)}
data-tooltip={reason}
data-tooltip={!reason?.toLowerCase().includes("click here to link a variant")
? reason
: undefined}
>
{reason
.toLowerCase()
.includes("click here to link a variant") && (
<div
className={visualBuilderStyles()["visual-builder__custom-tooltip"]}
onClick={handleLinkVariant}
>
{(() => {
const [before, after] = reason.split(
/here/i
);
return (
<>
{before}
<span style={{ textDecoration: "underline" }}>here</span>
{after}
</>
);
})()}
</div>
)}
<InfoIcon />
</div>
) : hasParentPaths ? (
Expand Down Expand Up @@ -303,11 +339,11 @@ function FieldLabelWrapperComponent(
>
{
currentField.isReference && !dataLoading && !error ?
<div
className={classNames(
"visual-builder__reference-icon-container",
<div
className={classNames(
"visual-builder__reference-icon-container",
visualBuilderStyles()["visual-builder__reference-icon-container"]
)}
)}
>
<div
className={classNames(
Expand Down
Loading
Loading