-
-
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 to compose env variables in HTTP request #2616
Comments
One solution could be to allow users to bind parameters, not only to UI state, but also to environment variables. That way we could have the best of both worlds:
|
So I guess that we could allow the user to bind to an expression in these cases, and in these cases that expression would have access to the values of the environment variables. We could try something like that? |
Just to be sure I expressed myself clearly. What I meant was to enable binding to an environment variable in the parameter bindings: So that in the query bindings one could use it like It's just a proposal, maybe it's still too convoluted. What I like about it:
What I don't like
@JerryWu1234 You can find it when opening the binding editor for a header: We're still trying to figure out how to generalize this pattern. I've also had questions about binding to cookies in this dialog as well. If you have any suggestions on how we could improve discoverability of this feature, or improvements to the documentation around this, I'd gladly hear it or take PRs. |
Got it, this makes sense! |
@apedroferreira |
I might work on it soon or maybe someone else can, but the team is also still going to discuss this to try to define a solution better. |
will write a ideas that the latest solutions if you discuss over? |
Ok, will do that and then you can take a look at this issue if we decide that it makes sense! :) |
Hello, I would like this feature. Any update on it? |
For this time being, I am using this bash script: #!/usr/bin/env bash
if [ -z "$BASE_URL" ]; then
echo '$BASE_URL is not set'
exit 1
fi
find toolpad/pages -name page.yml -exec sed -i "s|http://localhost:8000|$BASE_URL|g" {} \;
yarn toolpad build
rm -rf dist
cd ..
mkdir dist
cp -r ./admin/. ../yarn.lock ./dist/
mv ./dist ./admin/
cd admin
git checkout -- toolpad/pages |
as well as you to wait for the final solution. |
@IgnisDa Would the solution described in #2616 (comment) be sufficient to implement your use-case without extra scripts? |
@Janpot Yeah looks like it should be. |
Hi @JerryWu1234 , feel free to take this issue and follow the solution proposed in #2616 (comment). The team has agreed that it's a good solution to start with! So let's show the "environment variables" tab when setting bindings on query parameters. --- a/packages/toolpad-app/src/toolpadDataSources/rest/client.tsx
+++ b/packages/toolpad-app/src/toolpadDataSources/rest/client.tsx
@@ -531,6 +531,7 @@ function QueryEditor({
globalScopeMeta={globalScopeMeta}
liveValue={paramsEditorLiveValue}
jsRuntime={jsBrowserRuntime}
+ envVarNames={envVarNames}
/>
</Box>
</Panel> The main issue that you will notice is that there will be an error when trying to bind a parameter to an environment variable: It would be great if we could cover these changes in a test too. Also additionally, we could allow for doing this in Let me know if you have any questions and I'll always try to assist and offer feedback. |
Now there are three pr that it's going on. |
@apedroferreira |
Got it! If you ever feel like you have too much going on or if you don't want to take this issue just let me know, I just tagged you because you seemed interested :)
The environment variables that show as options for bindings are read from the |
yes I'm interested I just tell you my plan, and I will take it |
Recently I celebrated a national holiday, But I already began to address this problem. However. Can I pass the environment variables to the front-end as a property within such as define: {
'process.env.TOOLPAD: JSON.stringify(env),
}, Otherwise, I will pursue an alternative approach to improve |
I did two ways for this PR. because now all of the variables are handled in the backend, it will be hard for fixing #2686 if there is any variable in |
Summary 💡
I would like to use my process.env.GITHUB_TOKEN token, so I wired the value:
However, I need to have this logic:
for the token to be correctly recognized. I would rather not add
Bearer
toGITHUB_TOKEN
because I'm also using https://octokit.github.io/rest.js/v20#authentication.Motivation
Without tokens, GitHub API is rate-limited at 10 requests per minute. With the token, the limit is x83 higher.
https://docs.github.com/en/rest/overview/resources-in-the-rest-api?apiVersion=2022-11-28#rate-limits-for-requests-from-personal-accounts
Versions
v0.1.26
The text was updated successfully, but these errors were encountered: