+ {reason?.includes(DisableReason.CanLinkVariant) ? (
+
+ {(() => {
+ const [before, after] = reason.split(
+ DisableReason.UnderlinedAndClickableWord
+ );
+ return (
+ <>
+ {before}
+
+ {DisableReason.UnderlinedAndClickableWord}
+
+ {after}
+ >
+ );
+ })()}
+
+ ) : null}
+ {workflowRequestUi === "request" && reason ? (
+
+ {reason}{" "}
+ {
+ e.stopPropagation();
+ onRequestEditAccess();
+ }}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ onRequestEditAccess();
+ }
+ }}
+ >
+ Request Edit Access
+
+
+ ) : null}
+ {workflowRequestUi === "pending" && reason ? (
+
{reason}
+ ) : null}
+
+
+ );
+}
+
function FieldLabelWrapperComponent(
props: FieldLabelWrapperProps
): JSX.Element {
@@ -171,13 +281,36 @@ function FieldLabelWrapperComponent(
variantUid: props.fieldMetadata.variant,
fieldPathWithIndex: props.fieldMetadata.fieldPathWithIndex,
});
- const { isDisabled: fieldDisabled, reason } = isFieldDisabled(
+ const {
+ isDisabled: fieldDisabled,
+ reason,
+ workflowRequestUi,
+ } = isFieldDisabled(
fieldSchema,
eventDetails,
resolvedVariantPermissions,
entryAcl,
entryWorkflowStageDetails,
);
+ const handleRequestEditAccess = async () => {
+ try {
+ await visualBuilderPostMessage?.send(
+ VisualBuilderPostMessageEvents.OPEN_REQUEST_EDIT_ACCESS,
+ {
+ entryUid: props.fieldMetadata.entry_uid,
+ contentTypeUid:
+ props.fieldMetadata.content_type_uid,
+ locale: props.fieldMetadata.locale,
+ variantUid: props.fieldMetadata.variant,
+ }
+ );
+ } catch (error) {
+ console.error(
+ "Error opening request edit access flow:",
+ error
+ );
+ }
+ };
const handleLinkVariant = async () => {
try {
@@ -218,42 +351,24 @@ function FieldLabelWrapperComponent(
const hasParentPaths = !!props?.parentPaths?.length;
const isVariant = props.fieldMetadata.variant ? true : false;
+ const usePlainDataTooltip =
+ reason &&
+ !reason.includes(DisableReason.CanLinkVariant) &&
+ workflowRequestUi == null;
+
setCurrentField({
text: currentFieldDisplayName,
contentTypeName: contentTypeName ?? "",
icon: fieldDisabled ? (
-
- {reason
- .includes(DisableReason.CanLinkVariant) && (
-
- {(() => {
- const [before, after] = reason.split(
- DisableReason.UnderlinedAndClickableWord
- );
- return (
- <>
- {before}
- {DisableReason.UnderlinedAndClickableWord}
- {after}
- >
- );
- })()}
-
- )}
-
-
+