-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Allow binding query parameters to environment variables #2777
Allow binding query parameters to environment variables #2777
Conversation
Ok, I think we can bring env var values to the editor frontend. |
Agree, it should be fine to show the |
part of query |
I have a suggestion. |
We want to be able to assign and use environment variables as OR (different idea) we can try making a new |
I got it , and now it's going on.
there i'm not totally understand. such as we have a environment variable SECRET_BAR="Some bar secret" I create {
"name": "dataSourceFetchPrivate",
"params": [
"rest",
null,
{
"kind": "debugExec",
"query": {
"method": "GET",
"headers": [
[
"var",
{
"$$env": "SECRET_BAR"
}
]
],
"browser": false,
"searchParams": [
[
"aa",
{
"$$jsExpression": "`?code=${parameters.sd}`\n"
}
]
]
},
"params": {
"sd": "Some bar secret"
}
}
]
} because we already have all of the environment variable. "headers": [
[
"var",
{
"$$env": "SECRET_BAR"
}
]
to
"headers":{
"var": "Some bar secret"
}
and
"searchParams": [
[
"aa",
{
"$$jsExpression": "`?code=${parameters.sd}`\n"
}
]
]
to
"searchParams": {
"aa": "?code=`Some bar secret"
} final version {
"name": "dataSourceFetchPrivate",
"params": [
"rest",
null,
{
"kind": "debugExec",
"query": {
"method": "GET",
"headers": {
"var": "Some bar secret"
},
"browser": false,
"searchParams": {
"aa": "?code=Some bar secre"
}
},
"params": {
"sd": "Some bar secret"
}
}
]
} is there any problem in this way? |
We have to make a distinction between the Toolpad editor and the Toolpad application. The latter is what gets served when running Within the "private query" we can add a method to retrieve the environment variables of the process and variable names that exist in .env file. Those can be different. The former is used to resolve |
@apedroferreira I done |
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.
The latest changes are great, thank you!
We just still need to use the environment variables names in packages/toolpad-app/src/toolpad/AppEditor/BindingEditor.tsx
, instead of the values.
We still also need to solve the main remaining problem: all these changes work for the "Preview" mode in the editor, but if you try it, you will see that they do not work in a live application. It only works when you click the "Preview" button. In all other cases you will see that the values are still undefined
.
So we also need a way for the running application to be able to read and resolve environment bindings from the parameters - and we can't pass the env
values there directly like we do in preview, because they can include secrets. We can only pass the bindings (of type [string, BindableAttrValue<string>][]
), which then need to be resolved securely in the back-end.
I have already written some suggestions to try to solve this part of the problem before, in previous comments. But if you feel like that part is too much I can try to add a solution on top of your PR!
I think definitely we weren't on the same page about if I were right, you would want to say this preview |
i will do it |
Signed-off-by: Jerry_wu <409187100@qq.com>
I will add some tests if review is done |
Signed-off-by: Jerry_wu <409187100@qq.com>
@apedroferreira I done |
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.
Thank you! Some more comments:
packages/toolpad-app/src/toolpad/AppEditor/GlobalScopeExplorer.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Jerry_wu <409187100@qq.com>
…ryWu1234/mui-toolpad into 2616_add_node_env_second_way
@apedroferreira please help check |
Hi @JerryWu1234 , it's almost there but we still need to solve these cases, after that we can probably merge:
Screen.Recording.2023-11-02.at.14.16.53.mov
Screen.Recording.2023-11-02.at.14.17.17.mov |
|
…ryWu1234/mui-toolpad into 2616_add_node_env_second_way
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.
Thanks a lot for your work so far @JerryWu1234 , I know it has been a long process. :)
You can just add this suggested change and then if there's nothing else you would like to add I think we should be good!
packages/toolpad-app/src/toolpad/AppEditor/GlobalScopeExplorer.tsx
Outdated
Show resolved
Hide resolved
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.
Thank you @JerryWu1234 , this was a really important feature!
We might add some refinements later but this solution will work great for now!
#2616