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

Create Pipeline Rules syntax highlighting mode for Ace #5957

Merged
merged 20 commits into from Jun 21, 2019

Conversation

@kyleknighted
Copy link
Contributor

commented May 21, 2019

Description

Created custom Mode for Ace Editor to introduce syntax highlighting for Pipeline Rules

Motivation and Context

  • User request
  • Improve code readability

How Has This Been Tested?

Screenshots (if appropriate):

Before:
image

After:
image

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
@kyleknighted

This comment has been minimized.

Copy link
Contributor Author

commented May 21, 2019

Errors currently in master

client.js:772 POST http://localhost:9000/api/system/pipelines/rule/parse 400 (Bad Request)

FetchProvider.js:19 There was an error fetching a resource: cannot POST http://localhost:9000/api/system/pipelines/rule/parse (400). Additional information: Not available

After adding in the syntax highlighting, an additional error is added to the mix, even though the mode actually loads fine and renders appropriately

index.js:3802 GET http://127.0.0.1:8080/system/pipelines/rules/mode-pipeline.js net::ERR_ABORTED 404 (Not Found)

I could use an additional set of eyes to help me figure out what's causing this 404 even though it actually works.

@kyleknighted kyleknighted force-pushed the ace_editor_pipeline_rules_mode branch 2 times, most recently from a83c08f to fd4ead0 Jun 11, 2019

@dennisoelkers
Copy link
Member

left a comment

I have played with the PR today and it is a good improvement!

Some suggestions:

  • The mode should be named pipeline/pipeline_rule, not graylog to make it more specific.

  • The mode file can be reduced in size dramatically. While playing with it, I removed the JavaScript mode and let the graylog mode inherit from TextMode. Also, the folding is not required.

  • The mode contains a number of keywords (match|pipeline|all|either) which are not used in the rule language. I think you got them from the internal representation of pipelines, which is different from pipeline rules. While we might support editing them at some point, it would be a different mode than the pipeline rules.

  • rule|when|then|end should be keywords, not constants. This way the highlighting lets you differentiate visually between the outer framing of the rule and the used functions:
    Screen Shot 2019-06-19 at 14 02 53

  • Instead of maintaining a huge list of functions, we should try to fetch them again from the backend. (Maybe by using an instance of the mode again, which is passed to react-ace, so it is not evaluated in its scope, but ours)

  • If that is not possible, we should replace the static list with a regex. IMO it is confusing if a function that is in the list has a different color than a function that is supplied by a plugin (but is still correct). Validating that a function is defined is done by the editor anyway.

@kyleknighted kyleknighted force-pushed the ace_editor_pipeline_rules_mode branch 2 times, most recently from babb9b8 to 5e9b8f8 Jun 19, 2019

@kyleknighted kyleknighted force-pushed the ace_editor_pipeline_rules_mode branch from 5e9b8f8 to 4f67b2c Jun 20, 2019

@edmundoa edmundoa merged commit d5539f5 into master Jun 21, 2019

4 checks passed

ci-web-linter Jenkins build graylog-pr-linter-check 3742 has succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
graylog-project/pr Jenkins build graylog-project-pr-snapshot 4308 has succeeded
Details
license/cla Contributor License Agreement is signed.
Details

@edmundoa edmundoa deleted the ace_editor_pipeline_rules_mode branch Jun 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.