Skip to content

Commit

Permalink
Rename variables
Browse files Browse the repository at this point in the history
  • Loading branch information
blazejkustra committed Aug 13, 2024
1 parent 69ab537 commit 5f3f64f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/components/FormHelpMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ type FormHelpMessageProps = {
shouldShowRedDotIndicator?: boolean;

/** Whether should render error text as HTML or as Text */
shouldParseMessage?: boolean;
shouldRenderMessageAsHTML?: boolean;
};

function FormHelpMessage({message = '', children, isError = true, style, shouldShowRedDotIndicator = true, shouldParseMessage = false}: FormHelpMessageProps) {
function FormHelpMessage({message = '', children, isError = true, style, shouldShowRedDotIndicator = true, shouldRenderMessageAsHTML = false}: FormHelpMessageProps) {
const theme = useTheme();
const styles = useThemeStyles();

const processedText = useMemo(() => {
if (typeof message !== 'string' || !shouldParseMessage) {
const HTMLMessage = useMemo(() => {
if (typeof message !== 'string' || !shouldRenderMessageAsHTML) {
return '';
}

Expand All @@ -46,7 +46,7 @@ function FormHelpMessage({message = '', children, isError = true, style, shouldS
}

return `<muted-text-label>${replacedText}</muted-text-label>`;
}, [isError, message, shouldParseMessage]);
}, [isError, message, shouldRenderMessageAsHTML]);

if (isEmpty(message) && isEmpty(children)) {
return null;
Expand All @@ -61,7 +61,7 @@ function FormHelpMessage({message = '', children, isError = true, style, shouldS
/>
)}
<View style={[styles.flex1, isError && shouldShowRedDotIndicator ? styles.ml2 : {}]}>
{children ?? (shouldParseMessage ? <RenderHTML html={processedText} /> : <Text style={[isError ? styles.formError : styles.formHelp, styles.mb0]}>{message}</Text>)}
{children ?? (shouldRenderMessageAsHTML ? <RenderHTML html={HTMLMessage} /> : <Text style={[isError ? styles.formError : styles.formHelp, styles.mb0]}>{message}</Text>)}
</View>
</View>
);
Expand Down
12 changes: 6 additions & 6 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,10 @@ type MenuItemBaseProps = {
shouldParseHelperText?: boolean;

/** Whether should render hint text as HTML or as Text */
shouldParseHintText?: boolean;
shouldRenderHintAsHTML?: boolean;

/** Whether should render error text as HTML or as Text */
shouldParseErrorText?: boolean;
shouldRenderErrorAsHTML?: boolean;

/** Should check anonymous user in onPress function */
shouldCheckActionAllowedOnPress?: boolean;
Expand Down Expand Up @@ -400,8 +400,8 @@ function MenuItem(
shouldBlockSelection = false,
shouldParseTitle = false,
shouldParseHelperText = false,
shouldParseHintText = false,
shouldParseErrorText = false,
shouldRenderHintAsHTML = false,
shouldRenderErrorAsHTML = false,
shouldCheckActionAllowedOnPress = true,
onSecondaryInteraction,
titleWithTooltips,
Expand Down Expand Up @@ -810,7 +810,7 @@ function MenuItem(
shouldShowRedDotIndicator={!!shouldShowRedDotIndicator}
message={errorText}
style={[styles.menuItemError, errorTextStyle]}
shouldParseMessage={shouldParseErrorText}
shouldRenderMessageAsHTML={shouldRenderErrorAsHTML}
/>
)}
{!!hintText && (
Expand All @@ -819,7 +819,7 @@ function MenuItem(
shouldShowRedDotIndicator={false}
message={hintText}
style={styles.menuItemError}
shouldParseMessage={shouldParseHintText}
shouldRenderMessageAsHTML={shouldRenderHintAsHTML}
/>
)}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ function ApprovalWorkflowEditor({approvalWorkflow, policyID}: ApprovalWorkflowEd
}
shouldShowRightIcon
hintText={hintText}
shouldParseHintText
shouldRenderHintAsHTML
brickRoadIndicator={errorText ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined}
errorText={errorText}
shouldParseErrorText
shouldRenderErrorAsHTML
/>
);
})}
Expand Down

0 comments on commit 5f3f64f

Please sign in to comment.