Skip to content
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

MS2: Blockly Editor for Script Tasks #445

Merged
merged 9 commits into from
Jan 22, 2025
Merged

MS2: Blockly Editor for Script Tasks #445

merged 9 commits into from
Jan 22, 2025

Conversation

LucasMGo
Copy link
Contributor

Summary

Added the visual editor blockly for creating script tasks.

Details

  • added blockly editor to script tasks
  • store blockly script as xml
  • convertion of blockly to regular js script

This comment has been minimized.

@FelipeTrost FelipeTrost self-requested a review January 20, 2025 10:21
Copy link
Contributor

@FelipeTrost FelipeTrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor things, but it looks good

Maybe you could also add a loading animation to the script editor, because it initially opens the menu to select between js and blockly and then it jumps to the correct editor.

) {
const blocklyEditorRef = useRef<Blockly.WorkspaceSvg | null>(null);

const validateBlockScript = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to check if a block has an empty field, for example if the setVariable block isn't given a value it produces invalid code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now changed the js-transformation of the setVariable block so that the default value for setting a variable is null.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That solves that particular instance of the problem, but I still think we should check for empty fields, I'm going to merge this PR, but I think that we should check them in future

Copy link
Contributor

@FelipeTrost FelipeTrost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if the variableValue is false or undefined and write null instead

This comment has been minimized.

@LucasMGo
Copy link
Contributor Author

LucasMGo commented Jan 22, 2025

This will fail if the variableValue is false or undefined and write null instead

When accessing the value attribute in blockly, the value is always returned as a string by the javascriptGenerator of blockly.
So, when using true (or undefined) as a value in your block, the javascriptGenerator will return a string 'true' (or 'undefined'). Using a word, e.g. "test", in your block, this would result in the string ' "test" '. So if I check for empty values and it is used true or undefined, the check (variableValue || null) would return the variableValue, which is 'true' or 'undefined', because these are just strings and not falsy values. On the other hand, if the block has an empty value, the javascriptGenerator would return the empty string '' which is a falsy value and therefore null is inserted.

Copy link

CLOUDRUN ACTIONS

✅ Successfully created Preview Deployment.

https://pr-445---ms-server-staging-c4f6qdpj7q-ew.a.run.app

@FelipeTrost FelipeTrost merged commit 2c9e882 into main Jan 22, 2025
15 checks passed
@FelipeTrost FelipeTrost deleted the blockly-editor branch January 22, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants