From dfe32456a6cf4bd957adf3129f12e0b79c140cea Mon Sep 17 00:00:00 2001 From: Luke De Feo Date: Mon, 5 Aug 2024 03:49:43 -0700 Subject: [PATCH] Add special case for null attributes Summary: before this was just an empty box and was a little unclear. With a new color, italic font and the word Null explictly called outit should be less ambigious Reviewed By: antonk52 Differential Revision: D60509577 fbshipit-source-id: d013550b7b71365144a07b3343daa7fc8f5acbe3 --- .../attributes/AttributesInspector.tsx | 27 +++++++++++++++++++ .../sidebarV2/attributes/TextInput.tsx | 4 ++- .../sidebarV2/attributes/shared.tsx | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/AttributesInspector.tsx b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/AttributesInspector.tsx index 1456e84c024..d74160652ce 100644 --- a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/AttributesInspector.tsx +++ b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/AttributesInspector.tsx @@ -46,6 +46,7 @@ import { import { boolColor, enumColor, + nullColor, numberColor, rowHeight, stringColor, @@ -374,6 +375,19 @@ function NamedAttribute({ ); } +function checkForNull(inspectable: Inspectable) { + if (inspectable.type === 'array') { + return inspectable.items == null; + } else if (inspectable.type === 'pluginDeeplink') { + return inspectable.pluginId == null; + } else if (inspectable.type === 'object') { + return inspectable.fields == null; + } else { + return inspectable.value == null; + } +} +const emptyfn = () => {}; + function AttributeValue({ metadataMap, name, @@ -396,6 +410,19 @@ function AttributeValue({ const numberGroupOnChange = (value: number, hint: CompoundTypeHint): void => { instance.uiActions.editClientAttribute(nodeId, value, metadataPath, hint); }; + + if (checkForNull(inspectable)) { + return ( + + ); + } + switch (inspectable.type) { case 'boolean': return ( diff --git a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/TextInput.tsx b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/TextInput.tsx index 83ece5af115..5141ba21ece 100644 --- a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/TextInput.tsx +++ b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/TextInput.tsx @@ -18,7 +18,9 @@ export function StyledTextArea({ color, mutable, onChange, + style, }: { + style?: React.CSSProperties; value: string; color: string; mutable: boolean; @@ -32,7 +34,7 @@ export function StyledTextArea({ autoSize className={cx(inputBase, !mutable && readOnlyInput)} bordered - style={{color, ...pendingStyle(optimisticValue)}} + style={{color, ...pendingStyle(optimisticValue), ...style}} readOnly={!mutable} value={optimisticValue.value} onChange={(event) => optimisticValue.onChange(event.target.value)} diff --git a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/shared.tsx b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/shared.tsx index 37c282d9ef7..0cb649033ba 100644 --- a/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/shared.tsx +++ b/desktop/plugins/public/ui-debugger/components/sidebarV2/attributes/shared.tsx @@ -39,6 +39,7 @@ export const readOnlyInput = css` export const boolColor = '#C41D7F'; export const stringColor = '#AF5800'; +export const nullColor = '#cb34cb'; export const enumColor = '#006D75'; export const numberColor = '#003EB3'; export const rowHeight = 26;