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

Fix: UI crash when the plugin doesn't build. #737

Merged
merged 2 commits into from
Mar 30, 2023

Conversation

barnettZQG
Copy link
Collaborator

@barnettZQG barnettZQG commented Mar 30, 2023

Description of your changes

  1. Show the crash message on the page.
  2. Don't load the invalid plugin.

I have:

  • Read and followed KubeVela's contribution process.
  • Related Docs updated properly. In a new feature or configuration option, an update to the documentation is necessary.
  • Run yarn lint to ensure the frontend changes are ready for review.
  • Run make reviewableto ensure the server changes are ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

Special notes for your reviewer

@codecov
Copy link

codecov bot commented Mar 30, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.21 ⚠️

Comparison is base (4ca9085) 60.52% compared to head (c7e899a) 60.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #737      +/-   ##
==========================================
- Coverage   60.52%   60.31%   -0.21%     
==========================================
  Files          99       99              
  Lines       18020    18019       -1     
==========================================
- Hits        10906    10868      -38     
- Misses       5773     5806      +33     
- Partials     1341     1345       +4     
Flag Coverage Δ
apiserver-unittests 32.08% <0.00%> (-0.06%) ⬇️
server-e2e-tests 49.73% <0.00%> (-0.20%) ⬇️

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

Impacted Files Coverage Δ
pkg/plugin/loader/loader.go 51.49% <0.00%> (-3.33%) ⬇️

... and 11 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
@@ -0,0 +1,2 @@
define(["@velaux/data","react","@velaux/ui"],((e,n,t)=>(()=>{"use strict";var r={112:n=>{n.exports=e},928:e=>{e.exports=t},650:e=>{e.exports=n}},o={};function a(e){var n=o[e];if(void 0!==n)return n.exports;var t=o[e]={exports:{}};return r[e](t,t.exports,a),t.exports}a.d=(e,n)=>{for(var t in n)a.o(n,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},a.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{a.r(l),a.d(l,{plugin:()=>d});var e=a(112),n=a(650);class t extends n.PureComponent{render(){return n.createElement("div",{className:"page-container"},"Hello KubeVela Plugin Words!")}}var r=a(928);function o(e,n,t,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){return void t(e)}i.done?n(u):Promise.resolve(u).then(r,o)}const i=(u=function*(e,n){try{window.location.reload()}catch(e){console.error("Error while updating the plugin",e)}},c=function(){var e=this,n=arguments;return new Promise((function(t,r){var a=u.apply(e,n);function l(e){o(a,t,r,l,i,"next",e)}function i(e){o(a,t,r,l,i,"throw",e)}l(void 0)}))},function(e,n){return c.apply(this,arguments)});var u,c;const d=(new e.AppPagePlugin).setRootPage(t).addConfigPage({title:"Configuration",icon:"cog",body:({plugin:e})=>{const{enabled:t,jsonData:o}=e.meta;return n.createElement("div",{className:"gf-form-group"},n.createElement("div",null,n.createElement("div",null,"Enable / Disable"),!t&&n.createElement(n.Fragment,null,n.createElement("div",null,"The plugin is currently not enabled."),n.createElement(r.Button,{type:"primary",onClick:()=>i(e.meta.id,{enabled:!0,jsonData:o})},"Enable plugin")),t&&n.createElement(n.Fragment,null,n.createElement("div",null,"The plugin is currently enabled."),n.createElement(r.Button,{type:"secondary",onClick:()=>i(e.meta.id,{enabled:!1,jsonData:o})},"Disable plugin"))))},id:"configuration"})})(),l})()));

Check warning

Code scanning / CodeQL

Variable not declared before use

Variable 'u' is used before its [declaration](1).
@@ -0,0 +1,2 @@
define(["@velaux/data","react","@velaux/ui"],((e,n,t)=>(()=>{"use strict";var r={112:n=>{n.exports=e},928:e=>{e.exports=t},650:e=>{e.exports=n}},o={};function a(e){var n=o[e];if(void 0!==n)return n.exports;var t=o[e]={exports:{}};return r[e](t,t.exports,a),t.exports}a.d=(e,n)=>{for(var t in n)a.o(n,t)&&!a.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},a.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),a.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var l={};return(()=>{a.r(l),a.d(l,{plugin:()=>d});var e=a(112),n=a(650);class t extends n.PureComponent{render(){return n.createElement("div",{className:"page-container"},"Hello KubeVela Plugin Words!")}}var r=a(928);function o(e,n,t,r,o,a,l){try{var i=e[a](l),u=i.value}catch(e){return void t(e)}i.done?n(u):Promise.resolve(u).then(r,o)}const i=(u=function*(e,n){try{window.location.reload()}catch(e){console.error("Error while updating the plugin",e)}},c=function(){var e=this,n=arguments;return new Promise((function(t,r){var a=u.apply(e,n);function l(e){o(a,t,r,l,i,"next",e)}function i(e){o(a,t,r,l,i,"throw",e)}l(void 0)}))},function(e,n){return c.apply(this,arguments)});var u,c;const d=(new e.AppPagePlugin).setRootPage(t).addConfigPage({title:"Configuration",icon:"cog",body:({plugin:e})=>{const{enabled:t,jsonData:o}=e.meta;return n.createElement("div",{className:"gf-form-group"},n.createElement("div",null,n.createElement("div",null,"Enable / Disable"),!t&&n.createElement(n.Fragment,null,n.createElement("div",null,"The plugin is currently not enabled."),n.createElement(r.Button,{type:"primary",onClick:()=>i(e.meta.id,{enabled:!0,jsonData:o})},"Enable plugin")),t&&n.createElement(n.Fragment,null,n.createElement("div",null,"The plugin is currently enabled."),n.createElement(r.Button,{type:"secondary",onClick:()=>i(e.meta.id,{enabled:!1,jsonData:o})},"Disable plugin"))))},id:"configuration"})})(),l})()));

Check warning

Code scanning / CodeQL

Variable not declared before use

Variable 'c' is used before its [declaration](1).
Signed-off-by: barnettZQG <barnett.zqg@gmail.com>
@barnettZQG barnettZQG merged commit 89581ba into kubevela:main Mar 30, 2023
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.

1 participant