feat(environment): add Environment menu with variable substitution and status indicators#73
feat(environment): add Environment menu with variable substitution and status indicators#73KhenCahyo13 wants to merge 24 commits intosunchayn:basefrom
Conversation
sunchayn
left a comment
There was a problem hiding this comment.
Thank you for your contribution 🙏
I left some questions and suggestions.
Some of the variabes like the base endpoint, make sense to be configurable instead, which will also make the collaboration more consistent. This can be combined with something I have in mind in the future to have configuration per environment (which some Nimbus features, being disabled like cookie decryption, can only work when the current and target environments are the same).
In the subject of collaboration, how will this work with shareable links? When the consumer doesn't have the same env variables configured in their localstorage?
resources/js/components/common/KeyValueParameters/KeyValueParameters.vue
Outdated
Show resolved
Hide resolved
resources/js/components/common/KeyValueParameters/KeyValueParameters.vue
Show resolved
Hide resolved
resources/js/components/common/KeyValueParameters/KeyValueParameters.vue
Outdated
Show resolved
Hide resolved
resources/js/components/domain/Environment/EnvironmentCollectionsManager.vue
Outdated
Show resolved
Hide resolved
resources/js/components/domain/Environment/EnvironmentCollectionsManager.vue
Outdated
Show resolved
Hide resolved
resources/js/components/domain/Environment/EnvironmentCollectionsManager.vue
Show resolved
Hide resolved
| export const fallbackExtensions = (readonly: boolean): Extension[] => | ||
| commonExtensions(readonly); | ||
|
|
||
| const placeholderPattern = /{{\s*([^{}]+?)\s*}}/g; |
There was a problem hiding this comment.
[this is is an overall question]
What if the user wants to actually use literal '{{ .. }}' but not necessarily substitute it with a variable?
[suggestion, perhaps future iteration]
The way I see it, a UX friendly way would be to show a dropdown when the user starts typing, they can either pick an option or continue typing. When they fully type a variable, there will be only one option in the dropdown. They will have to either click on it or type Enter to confirm; pressing space after the variable closing tag or clicking outside of the variable boundaries will hide the dropdown. Wdyt?
There was a problem hiding this comment.
Yes sir, your suggestion is right, when the user type an variable name, they will get some suggesstions from an dropdown (its like autocomplete). I thought about this feature also, but i'm still hold it, i will make this one if you agree with this feature 🙏🏼.
There was a problem hiding this comment.
Yes, an auto-complete dropdown will be a great UX here 🙏 But let's first stabilize the implementation before making UX improvements to make sure they are done on a final architecture.
|
For shareable environment, i have some suggestions sir:
Wdyt sir? For local storage we must keep this for persist environment per user. |
If we substitute the env variables directly and send them to the request store as plain texts, the shareable links will work fine because the request builder store will have plain values (instead of the variables). Meaning that, when it is shared, the other consumer will receive the "output" of the substitution across the board. But they will lose the source of the env variable, which is a fine compromise for now. Perhaps in the future we can make the environment variables shareable as well within the same link, but it needs dedicated thinking. The URL length is limited, so the less data we carry the better.
This is another day's problem. It will require a "server" in between to keep things in sync. It is too early to go in that direction. |
resources/js/components/common/KeyValueParameters/KeyValueParameters.vue
Outdated
Show resolved
Hide resolved
resources/js/components/common/KeyValueParameters/KeyValueParameters.vue
Outdated
Show resolved
Hide resolved
...rces/js/components/domain/Client/Request/RequestAuthorization/RequestAuthorizationBearer.vue
Outdated
Show resolved
Hide resolved
resources/js/components/domain/Client/Request/RequestBody/RequestBodyFormData.vue
Outdated
Show resolved
Hide resolved
| parameter.value, | ||
| activeVariables.value, | ||
| activeVariablesMap.value, | ||
| ); |
There was a problem hiding this comment.
[question]
The way this works is a bit hard to follow mentally. I don't fully follow how this will be mapped to the input. It is coming from the store, and I assume the getEnvironmentPlaceholderStatus is reactive. But it is reactive to what? All inputs on the page? What if there are many inputs on the page and they all have different statuses (theoretically), how will the status react independently for each input?
There was a problem hiding this comment.
In the context of getEnvironmentPlaceholderStatus, this is reactive, and this is reactive for indicator status for related variable. This work only on Authorization, Headers, Body (JSON, Form Data), and Parameters.
For the case many inputs it will reacted based on the variable key sir, if there is an value or not on the related variable key, so it will update the indicator status (in this case placeholder status) based on the value.
Co-authored-by: Mazen Touati <14861869+sunchayn@users.noreply.github.com>
…ahyo13/nimbus into feat/environment-variables
…olvedRequest Enhance the useResolvedRequest composable to expose individual resolved request components (endpoint, headers, body, queryParameters) as reactive computed properties. This enables more decoupled and maintainable component consumption, allowing consumers to use only the specific resolved values they need. The composable now provides: - resolvedEndpoint: reactive endpoint with substituted variables - resolvedHeaders: reactive headers with substituted variables - resolvedBody: reactive body with substituted variables - resolvedQueryParameters: reactive query parameters with substituted variables The original resolveRequest() method is retained for backward compatibility. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… access Add a 'variables' computed property to useEnvironmentVariablesStore that automatically resolves to the current environment's global variables. This simplifies the consumer API by eliminating the need to understand the 'collections' concept. Consumers now use store.variables instead of store.activeCollection?.variables, reducing cognitive load and providing better decoupling. The variables property automatically tracks the active collection selection. Update useResolvedRequest to use the new variables property for cleaner access to active environment variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…er status Add EnvironmentVariablePlaceholderIndicator component that wraps any input with a hover popover showing contextual info when a placeholder is Missing, Empty, or Resolved. Apply it across all indicator usages (KeyValueParameters, auth inputs, endpoint input). Refactor getValueInputStatus and reactive env variable helpers into utils/ui/environment-variable to eliminate duplication across components. Also fix broken getValueInputExtraClassUsing prop name that prevented indicator colors from working in KeyValueParameters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…dRequest - Accept optional reactive request ref to return truly granular ComputedRef<T> per field, instead of ComputedRef<(req) => T> which never re-evaluated on store changes - Fix lazy store access in environment-variable util to avoid calling useEnvironmentVariablesStore() at module level (broke component tests) - Add tests covering reactive property defaults, placeholder resolution, reactivity to variable/request changes, and imperative resolveRequest use Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description
This PR introduces a new Environment menu to manage environment variable collections and use them in request building/execution (The concept is actually the same as Postman and similar tools).
It also adds placeholder status indicators in request inputs:
Motivation
Users need a way to define reusable variables (e.g. tokens, host parts, query values) and inject them into requests using
{{variable}}syntax.This improves request reuse and reduces manual editing across endpoints, headers, auth fields, and body payloads.
Changes
Environmentpage and sidebar navigation entry.useEnvironmentVariablesStorewith persisted collections.missing | empty | resolved).Important Note / Current Limitation
Environment collections are currently persisted in browser local storage (Pinia persisted state), so they are:
If this feature is approved, we may consider a future enhancement for server-backed/shared environment storage.
How to Test
token,host,userId), and ensure it is active (Used)./api/{{host}}/users{{token}}{ "id": "{{userId}}" }Screenshots
Environment Page
Variables Indicator
Related
N/A