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

feat: refactor Plugin Orchestration #1813

Merged
merged 36 commits into from
May 11, 2021
Merged

Conversation

juzhiyuan
Copy link
Member

@juzhiyuan juzhiyuan commented Apr 21, 2021

Please answer these questions before submitting a pull request, or your PR will get closed.

Why submit this pull request?

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What changes will this PR take into?

Hi, this PR aims to refactor then improve the Plugin Orchestration feature :)

  • use X6 to replace the core of FlowChart;
  • support Plugin Card (Category);
  • support Start & End & Condition card;
  • support card limitation: Start card with bottom Connection Port; End card with top Connection Port;
  • support Plugin Editor (In Progress)
  • Data transformer;
  • i18n of course;

Thanks to https://github.com/antvis/x6 .

Related issues

resolve #1247

Project

Checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@netlify
Copy link

netlify bot commented Apr 21, 2021

Deploy preview for apisix-dashboard ready!

Built with commit 5d6f3f7

https://deploy-preview-1813--apisix-dashboard.netlify.app

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2021

Codecov Report

Merging #1813 (e27bcd6) into master (1770596) will decrease coverage by 18.80%.
The diff coverage is n/a.

❗ Current head e27bcd6 differs from pull request most recent head 5d6f3f7. Consider uploading reports for the commit 5d6f3f7 to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@
##           master    #1813       +/-   ##
===========================================
- Coverage   71.22%   52.42%   -18.81%     
===========================================
  Files         173       39      -134     
  Lines        6221     2745     -3476     
  Branches      712        0      -712     
===========================================
- Hits         4431     1439     -2992     
+ Misses       1534     1112      -422     
+ Partials      256      194       -62     
Flag Coverage Δ
backend-e2e-test ?
backend-e2e-test-ginkgo ?
backend-unit-test 52.42% <ø> (-0.04%) ⬇️
frontend-e2e-test ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
api/internal/utils/version.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/filter/request_id.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/entity/entity.go 0.00% <0.00%> (-100.00%) ⬇️
api/internal/core/store/storehub.go 0.00% <0.00%> (-71.03%) ⬇️
api/internal/filter/cors.go 0.00% <0.00%> (-66.67%) ⬇️
api/internal/filter/schema.go 0.00% <0.00%> (-55.47%) ⬇️
api/internal/utils/consts/api_error.go 0.00% <0.00%> (-50.00%) ⬇️
api/internal/handler/data_loader/route_import.go 27.41% <0.00%> (-37.50%) ⬇️
api/internal/handler/handler.go 42.59% <0.00%> (-35.19%) ⬇️
api/internal/handler/schema/schema.go 66.66% <0.00%> (-33.34%) ⬇️
... and 143 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1770596...5d6f3f7. Read the comment docs.

@juzhiyuan juzhiyuan force-pushed the feat-plugin-flow branch 2 times, most recently from 549b064 to dcebacd Compare April 23, 2021 11:39
@juzhiyuan juzhiyuan marked this pull request as ready for review April 24, 2021 05:32
@juzhiyuan juzhiyuan requested review from LiteSun and liuxiran and removed request for LiteSun April 24, 2021 08:51
@juzhiyuan juzhiyuan requested a review from LiteSun April 24, 2021 12:45
@juzhiyuan
Copy link
Member Author

fixing CI

@juzhiyuan
Copy link
Member Author

juzhiyuan commented Apr 24, 2021

Test building failed due to ESLint error, it doesn't affect the Netlify Preview. I will continue fixing them.

@LiteSun
Copy link
Member

LiteSun commented Apr 26, 2021

I pulled the code into a local run and tried it out, and the new plugin orchestration works great.
But I found two small problems:

  1. how do I know which one is the true exit and which one is the false exit for each conditional link?
    image

  2. the problem of automatic resize, see the video below for details
    https://user-images.githubusercontent.com/31329157/116041986-7aca7980-a6a0-11eb-9ed5-e31e8f89395a.mov

  3. how to enable the plug-in for users in orchestration mode? Drag the plug-in to the drawing board and still need enable to enable the plug-in?
    image

@juzhiyuan juzhiyuan requested review from liuxiran and LiteSun May 5, 2021 13:32
@juzhiyuan
Copy link
Member Author

I will add E2E test cases for this PR

@nic-chen
Copy link
Member

nic-chen commented May 6, 2021

As for key is required issue, @nic-chen please take a look.

curl 'http://localhost:8000/apisix/admin/routes' \
  -H 'Connection: keep-alive' \
  -H 'sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="90", "Google Chrome";v="90"' \
  -H 'Accept: application/json' \
  -H 'Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MjAyMjIzNzgsImlhdCI6MTYyMDIxODc3OCwic3ViIjoiYWRtaW4ifQ.n-kqe-O125cu1p0T01FhMKFRyg6MsRE2sqpTmMeEQO8' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H 'Origin: http://localhost:8000' \
  -H 'Sec-Fetch-Site: same-origin' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Referer: http://localhost:8000/routes/create' \
  -H 'Accept-Language: en,zh-CN;q=0.9,zh;q=0.8' \
  -H 'Cookie: _ga=GA1.1.1414702999.1618817327; _ga_WQLBQL6GY3=GS1.1.1618817327.1.1.1618817540.0; next-i18next=en-US; _gid=GA1.1.619947394.1620143250' \
  --data-raw '{"uris":["/*"],"methods":["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS","CONNECT","TRACE"],"priority":0,"name":"test222","desc":"","status":1,"labels":{},"script":{"chart":{"cells":[{"shape":"edge","attrs":{"line":{"stroke":"#5F95FF","strokeWidth":1,"targetMarker":{"name":"classic","size":8}}},"id":"25e20dd5-ca57-4b60-ba05-405b0a078ac0","router":{"name":"manhattan"},"zIndex":0,"source":{"cell":"69ca1277-fd6c-4486-b7df-4de4547f30d9","port":"fa3f2c5b-8fd5-482b-8544-4148d0f0bb00"},"target":{"cell":"be7c5c72-00be-4678-92c1-cda07ecfe735","port":"b5ddd0eb-4ecb-462b-9723-019087933544"}},{"position":{"x":160,"y":90},"size":{"width":80,"height":42},"attrs":{"text":{"textWrap":{"text":"开始"}},"body":{"rx":24,"ry":24}},"shape":"flow-chart-start-rect","ports":{"groups":{"top":{"position":"top","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}},"right":{"position":"right","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}},"bottom":{"position":"bottom","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}},"left":{"position":"left","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}}},"items":[{"group":"bottom","id":"fa3f2c5b-8fd5-482b-8544-4148d0f0bb00"}]},"id":"69ca1277-fd6c-4486-b7df-4de4547f30d9","zIndex":1},{"position":{"x":100,"y":187},"size":{"width":200,"height":60},"attrs":{"text":{"text":"key-auth"},"title":{"text":"key-auth"}},"shape":"flow-chart-plugin-rect","ports":{"groups":{"top":{"position":"top","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}},"bottom":{"position":"bottom","attrs":{"circle":{"r":3,"magnet":true,"stroke":"#5F95FF","strokeWidth":1,"fill":"#fff","style":{"visibility":"hidden"}}}}},"items":[{"group":"top","id":"b5ddd0eb-4ecb-462b-9723-019087933544"},{"group":"bottom","id":"de0bae68-787d-4977-b75b-b8f030d0636e"}]},"id":"be7c5c72-00be-4678-92c1-cda07ecfe735","zIndex":2,"data":{"disable":false}}]},"conf":{"be7c5c72-00be-4678-92c1-cda07ecfe735":{"disable":false}},"rule":{"root":"be7c5c72-00be-4678-92c1-cda07ecfe735"}},"vars":[],"upstream_id":"352139465977758504"}' \
  --compressed

ok

@juzhiyuan
Copy link
Member Author

https://github.com/apache/apisix-dashboard/pull/1813/checks?check_run_id=2514882778

@nic-chen @starsz Please check this CI

groupButton: '.ant-radio-group',
canvas: '.x6-graph-svg',
startNode:
'#stencil > div > div.x6-widget-stencil-content > div:nth-child(1) > div > div > svg > g > g.x6-graph-svg-stage > g:nth-child(1) > g > circle',
Copy link
Member

Choose a reason for hiding this comment

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

it would be better to use data-* (https://docs.cypress.io/guides/references/best-practices#Selecting-Elements) to reduce selector length.

web/package.json Outdated Show resolved Hide resolved
@starsz
Copy link
Contributor

starsz commented May 10, 2021

@juzhiyuan
Copy link
Member Author

Hi, I just fixed the dag-to-lua issue in CI, and retriggered the Test to make sure it's stable as expected.

@juzhiyuan
Copy link
Member Author

CI passes twice, cc @liuxiran @imjoey @LiteSun @bzp2010 to review, thanks!

@juzhiyuan juzhiyuan merged commit 423c9e8 into apache:master May 11, 2021
@juzhiyuan juzhiyuan deleted the feat-plugin-flow branch May 11, 2021 06:36
Copy link
Member

@imjoey imjoey left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks.

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.

[Proposal]: Enhance plugin orchestration
8 participants