-
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
feat: Support configuring expression in Canvas form #272
Conversation
Implementation is done including dialect parsing. I'll add tests and then should be ready to go. 2023-11-08.16-01-18.mp4 |
One known bug: the language Issue: #311 |
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.
This is great @igarashitm, a huge step forward 💪 🙌
return schema?.schema === undefined ? null : ( | ||
<ErrorBoundary fallback={<p>This node cannot be configured yet</p>}> | ||
<Title headingLevel="h1">{componentName}</Title> | ||
|
||
{isExpressionAwareStep && <ExpressionEditor selectedNode={props.selectedNode} />} |
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.
[curious-question]
- Couldn't this be added in the
CustomAutoField
component instead? - Could be possible for this
expression
property to collide with another one from another resource? - If the latter is true, would be beneficial to have the
isExpressionAwareStep
logic inside of thecamel-route-visual-entity
?
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.
- Since this is done outside of the uniforms,
CustomAutoField
doesn't participate - Can you ellaborate?
- I'd like to wait a bit to see how
Integration
andKamelet
kind is implemented, as this logic will be used for those as well
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.
- Could it be incorporated into the
CustomAutoField
workflow? This is not a blocking issue in any case - I meant what would happen if a
Pipe
for instance has anexpression
property? I guess we're gonna see the expression field anyway. - That sounds fair 👍
@@ -1,7 +1,7 @@ | |||
import { PipeErrorHandlerEditor } from './PipeErrorHandlerEditor'; | |||
import { within } from '@testing-library/dom'; | |||
import { fireEvent, render, screen } from '@testing-library/react'; | |||
import { pipeErrorHandlerJson } from '../../stubs/PipeErrorHandler'; | |||
import * as pipeErrorHandlerSchema from '@kaoto-next/camel-catalog/PipeErrorHandler.json'; |
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.
Great this is finally working 🎉
useSchemasStore.setState({ | ||
schemas: { | ||
camelYamlDsl: { | ||
name: 'camelYamlDsl', | ||
tags: ['camel'], | ||
version: '1.0.0', | ||
uri: '', | ||
schema: yamlDslSchema as unknown as Record<string, unknown>, | ||
}, | ||
}, | ||
}); |
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.
[heads-up]: It's possible that in a future iteration, the useSchemasStore will be removed in favor of a react provider, to handle schemas easier in consumers, like the VSCode extension.
/** | ||
* Get the language catalog map from the Camel catalog. Since "language" language is not in the languages Camel | ||
* catalog, it is extracted from the YAML DSL schema. | ||
* @param yamlDslSchema | ||
*/ | ||
static getLanguageMap(yamlDslSchema: Record<string, unknown>): Record<string, ICamelLanguageDefinition> { | ||
const catalog = { ...CamelCatalogService.getLanguageMap() }; | ||
|
||
// "language" for custom language is not in the Camel catalog. Create from YAML DSL schema and Add here. | ||
const customDefinition = ExpressionService.createCustomLanguageDefinition(yamlDslSchema); | ||
if (customDefinition) { | ||
catalog['language'] = customDefinition; | ||
} | ||
|
||
// "file" language is merged with "simple" language and it doesn't exist in YAML DSL schema. Remove it here. | ||
delete catalog['file']; | ||
|
||
return catalog; | ||
} | ||
|
||
private static createCustomLanguageDefinition(yamlDslSchema: Record<string, unknown>) { | ||
const definitions = (yamlDslSchema.items as Record<string, unknown>)?.definitions as Record<string, unknown>; | ||
const customLanguageSchema = | ||
definitions && (definitions['org.apache.camel.model.language.LanguageExpression'] as Record<string, unknown>); | ||
if (!customLanguageSchema) return; | ||
|
||
const properties = Object.entries(customLanguageSchema.properties as Record<string, unknown>).reduce( | ||
(acc, [key, value]) => { | ||
acc[key] = { | ||
index: Object.keys(acc).length, | ||
required: (customLanguageSchema.required as string[]).includes(key), | ||
...(value as Record<string, unknown>), | ||
} as ICamelLanguageProperty; | ||
return acc; | ||
}, | ||
{} as Record<string, ICamelLanguageProperty>, | ||
); | ||
return { | ||
language: { | ||
kind: CatalogKind.Language, | ||
name: 'language', | ||
title: customLanguageSchema.title, | ||
description: customLanguageSchema.description, | ||
deprecated: false, | ||
modelName: 'language', | ||
} as ICamelLanguageModel, | ||
properties: properties, | ||
} as ICamelLanguageDefinition; | ||
} | ||
|
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.
[curious-question]: Does this process mutate over time? If not, wouldn't be preferable to run it just once at boot time instead? Perhaps around when we build the catalogs.
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.
Sounds like a plan, filed an issue - #316
/** | ||
* Set the expression model to the parent step model object. This method uses the most verbose dialect, i.e. | ||
* ```yaml | ||
* - setBody: | ||
* expression: | ||
* simple: | ||
* expression: ${body} | ||
* trim: true | ||
* ``` |
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.
This is great, thanks for providing the example
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.
mmm, could be possible to point also in the example, what the params represent based on the YAML example?
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.
Do you mean we want an explanation for e.g. trim
parameter in this comment?
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.
Ah, no, I meant the function parameters.
@param parentModel
@param languageModelName
@param newExpressionModel
For instance, are those parameters related to the YAML example? do they correspond to a particular field? if that's the case, can we point out which ones?
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.
ahh OK, that makes sense, I'll follow up
I would think so, since some of the language have many parameters and push step parameters out of the screen.
Filed an issue - #317 |
I filed an issue for the |
Considering that we have all the feedback in dedicated issues, I'm gonna merge this PR 🎉 , thanks once again Tomo |
Fixes: #270
Just a mockup for now, plumbing TBD
2023-11-01.20-51-47.mp4