-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(309): Add codeblock to unknown node #644
Conversation
@tplevko looks good 👍 |
<> | ||
<Title headingLevel="h1">{componentName}</Title> | ||
<CodeBlock> | ||
<CodeBlockCode id="code-content">{stringify(model)}</CodeBlockCode> | ||
</CodeBlock> | ||
</> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💅 Maybe it would be nice to extract this into a dedicated component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could look like this
<UnknownComponent componentName={componentName} } code={stringify(model)} />
Alternatively, we could reorder a bit the component to avoid duplicating the <Title>
component:
const isUnknownComponent = useMemo(() => {
return schema?.schema === undefined || Object.keys(schema?.schema).length === 0;
}, [schema]);
return (
<ErrorBoundary key={props.selectedNode.id} fallback={<p>This node cannot be configured yet</p>}>
<Title headingLevel="h1">{componentName}</Title>
{isUnknownComponent ? (
<CodeBlock>
<CodeBlockCode>{stringify(props.selectedNode.data?.vizNode?.getComponentSchema())}</CodeBlockCode>
</CodeBlock>
) : (
<AutoField.componentDetectorContext.Provider value={CustomAutoFieldDetector}>
{isExpressionAwareStep && <StepExpressionEditor selectedNode={props.selectedNode} />}
{isDataFormatAwareStep && <DataFormatEditor selectedNode={props.selectedNode} />}
{isLoadBalanceAwareStep && <LoadBalancerEditor selectedNode={props.selectedNode} />}
<AutoForm ref={formRef} schema={schema} model={model} onChangeModel={handleOnChange} data-testid="autoform">
<AutoFields omitFields={omitFields} />
<ErrorsField />
</AutoForm>
</AutoField.componentDetectorContext.Provider>
)}
</ErrorBoundary>
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the hint Ricardo, I updated the PR to remove the duplicate <Title>
and also updated the failing tests.
8703aa3
to
b4156a5
Compare
@tplevko if I'm not mistaken, we shown the component's definition, but now we're showing an internal kaoto object, is this intended? |
fixes #309
@lordrip I tried both - the
<pre>
with<code>
and the PFCodeBlock
- I believe usingCodeBlock
the yaml code gets more highlighted, but I can change to the originally proposed solution.Also I wanted to ask, whether we should add some info, regarding the displayed block of code - I was thinking about, to be consistent - something like FieldLabelIcon qestionmark with popover, containing information, regarding the displayed yaml and some info, regarding the node itself - that the name is not correct and needs to be changed in source code, or replaced in the canvas.
Let me know, what do you think.