-
Notifications
You must be signed in to change notification settings - Fork 6
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: add env variables in start session form #2066
Conversation
You can access the deployment of this PR at https://renku-ci-ui-2066.dev.renku.ch |
dc32fca
to
88db8e8
Compare
88db8e8
to
d98c125
Compare
d98c125
to
bee2968
Compare
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.
Nice addition! It works well, but I feel the logic for storing the environment variables in the presentation component is redundant since you already store them in the redux store.
I would remove const [environmentVariables, setEnvironmentVariables] = useState(
and use the variables coming from the redux model direcly.
client/src/model/RenkuModels.js
Outdated
@@ -391,6 +391,7 @@ const notebooksSchema = new Schema({ | |||
commit: { initial: {} }, | |||
discard: { initial: false }, | |||
options: { initial: {} }, | |||
environment_variables: { initial: [{ key: "", value: "" }] }, |
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.
environment_variables: { initial: [{ key: "", value: "" }] }, | |
environment_variables: { initial: {} }, |
If I interpret the code correctly, this format [{ key: "", value: "" }]
is overwritten by { <key>: <value> }
immediately.
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.
P.S: after finishing the review, I now understand this better.
I feel going for [{ key: "", value: "" }]
is the best alternative since it's easier to add empty fields.
const [environmentVariables, setEnvironmentVariables] = useState([ { key: "", value: "" }]); | ||
|
||
const setNotebookEnvVariables = (variables) => { | ||
props.handlers.setNotebookEnvVariables(variables); | ||
setEnvironmentVariables(variables); | ||
}; | ||
|
||
useEffect(() => { | ||
if (props.envVariablesQueryParams) | ||
setEnvironmentVariables(props.envVariablesQueryParams); | ||
}, []); // eslint-disable-line | ||
|
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.
This logic seems redundant to me.
If you are already save the status in the redux store, you can get it from props.filters.environment_variables
.
Why saving it locally with a different format? Wouldn't it be easier to use only the redux store?
I feel the easiest thing would be adopting the pattern [ { key: "", value: "" }]
also for the redux store, although that requires a few extra changes.
d4d6375
to
217f096
Compare
Thanks @lorenzo-cavazzi for your review. |
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.
This looks great! A tiny detail before merging.
I personally think we can start with an empty array for the variables and let the user click on "Add Variable" instead of showing an empty one since it's optional and probably only very few people will use them. The initial state would be as in the following screenshot.
If you agree, I think I added all the necessary changes as suggestions. If you prefer to keep an initial empty entry, I would then move const DEFAULT_ENV_VARIABLES
away from the RenkuModel file to a "NotebooksSomething" file since it looks like a session-related constant.
client/src/model/RenkuModels.js
Outdated
const DEFAULT_ENV_VARIABLES = [{ key: "", value: "" }]; | ||
|
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.
const DEFAULT_ENV_VARIABLES = [{ key: "", value: "" }]; |
client/src/model/RenkuModels.js
Outdated
@@ -391,6 +393,7 @@ const notebooksSchema = new Schema({ | |||
commit: { initial: {} }, | |||
discard: { initial: false }, | |||
options: { initial: {} }, | |||
environment_variables: { initial: DEFAULT_ENV_VARIABLES }, |
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.
environment_variables: { initial: DEFAULT_ENV_VARIABLES }, | |
environment_variables: { initial: [] }, |
client/src/model/RenkuModels.js
Outdated
@@ -722,5 +725,5 @@ const formGeneratorSchema = new Schema({ | |||
export { | |||
datasetFormSchema, datasetSchema, datasetImportFormSchema, environmentSchema, | |||
formGeneratorSchema, issueFormSchema, newProjectSchema, notebooksSchema, notificationsSchema, | |||
projectSchema, projectsSchema, statuspageSchema, userSchema, webSocketSchema | |||
projectSchema, projectsSchema, statuspageSchema, userSchema, webSocketSchema, DEFAULT_ENV_VARIABLES |
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.
projectSchema, projectsSchema, statuspageSchema, userSchema, webSocketSchema, DEFAULT_ENV_VARIABLES | |
projectSchema, projectsSchema, statuspageSchema, userSchema, webSocketSchema |
@@ -30,6 +30,7 @@ import { StatusHelper } from "../model/Model"; | |||
import { Url } from "../utils/helpers/url"; | |||
import { sleep } from "../utils/helpers/HelperFunctions"; | |||
import ShowSessionFullscreen from "./components/SessionFullScreen"; | |||
import { DEFAULT_ENV_VARIABLES } from "../model/RenkuModels"; |
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.
import { DEFAULT_ENV_VARIABLES } from "../model/RenkuModels"; |
|
||
const environmentVariables = this.getEnvironmentVariablesFromSearch(currentSearch); | ||
this.customEnvVariables = currentSearch && this.autostart && environmentVariables.length ? | ||
environmentVariables : DEFAULT_ENV_VARIABLES; |
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.
environmentVariables : DEFAULT_ENV_VARIABLES; | |
environmentVariables : []; |
3469fb1
to
dfb4105
Compare
df56e0d
to
f08b01c
Compare
f08b01c
to
5470841
Compare
5470841
to
9e232af
Compare
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.
Lgtm! 🚀
baf48aa
to
414e2d6
Compare
Tearing down the temporary RenkuLab deplyoment for this PR. |
This PR add the env variables fields in start session form.
Testing
User should be able to start a session with environment variables

Verify environment variable is available

Create a session link to share with environment variables

Closes #2058
*Note: Added renku-notebooks dependency just to make available other functionalities merged before in master
/deploy #persist renku-notebooks=master extra-values=notebooks.amalthea.image.repository=registry.dev.renku.ch/tasko.olevski/renku-images/amalthea,notebooks.amalthea.image.tag=0.5.2-n014.h50ddcaa