-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: ensure botTemplate saved for workflow-template bot creation (#1021) #1035
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,20 @@ const MakeCreateModal: React.FC<MakeCreateModalProps> = ({ | |
| if (flag) { | ||
| req['maasId'] = item.maasId; | ||
| req['name'] = item.title + Date.now(); | ||
| const coreScenarios = item?.coreScenarios as any; | ||
| const botTemplateFromTemplate = | ||
| coreScenarios?.botTemplate ?? | ||
| coreScenarios?.bot_template ?? | ||
| coreScenarios?.inputTemplate ?? | ||
| coreScenarios?.input_template ?? | ||
| coreScenarios?.description; | ||
|
Comment on lines
+55
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This logic for finding a bot template from a set of possible keys ( |
||
|
|
||
| if ( | ||
| typeof botTemplateFromTemplate === 'string' && | ||
| botTemplateFromTemplate.trim() | ||
| ) { | ||
| req['botTemplate'] = botTemplateFromTemplate; | ||
| } | ||
| await createFromTemplate(req) | ||
| .then((res: any) => { | ||
| navigate(`/work_flow/${res.flowId}/arrange`); | ||
|
|
||
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.
Using
as anybypasses TypeScript's type checking, which can lead to runtime errors and makes the code harder to maintain. It's better to provide a specific type forcoreScenarios. A more comprehensive fix would be to type the entireitemobject, which seems to correspond to theMaasTemplateentity from the backend, and update thegetStarTemplateservice to return a typed response instead ofany.