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

feat: add app params for image builders #3511

Draft
wants to merge 2 commits into
base: leafty/session-env-builders-2
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ echo " HOMEPAGE=${HOMEPAGE}"
echo " CORE_API_VERSION_CONFIG=${CORE_API_VERSION_CONFIG}"
echo " USER_PREFERENCES_MAX_PINNED_PROJECTS=${USER_PREFERENCES_MAX_PINNED_PROJECTS}"
echo " SESSION_CLASS_EMAIL_US=${SESSION_CLASS_EMAIL_US}"
echo " IMAGE_BUILDERS_ENABLED=${IMAGE_BUILDERS_ENABLED}"
echo "==================================================="

echo "Privacy file contains the following markdown (first 5 lines):"
Expand Down Expand Up @@ -82,7 +83,8 @@ tee > "${NGINX_PATH}/config.json" << EOF
"HOMEPAGE": ${HOMEPAGE},
"CORE_API_VERSION_CONFIG": ${CORE_API_VERSION_CONFIG},
"USER_PREFERENCES_MAX_PINNED_PROJECTS": ${USER_PREFERENCES_MAX_PINNED_PROJECTS},
"SESSION_CLASS_EMAIL_US": ${SESSION_CLASS_EMAIL_US}
"SESSION_CLASS_EMAIL_US": ${SESSION_CLASS_EMAIL_US},
"IMAGE_BUILDERS_ENABLED": "${IMAGE_BUILDERS_ENABLED}"
}
EOF
echo "config.json created in ${NGINX_PATH}"
Expand Down
3 changes: 2 additions & 1 deletion client/run-telepresence.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ tee > ./public/config.json << EOF
"datasetSlug": "${HOMEPAGE_DATASET_SLUG}"
},
"USER_PREFERENCES_MAX_PINNED_PROJECTS": ${USER_PREFERENCES_MAX_PINNED_PROJECTS:-5},
"SESSION_CLASS_EMAIL_US": { "enabled": false }
"SESSION_CLASS_EMAIL_US": { "enabled": false },
"IMAGE_BUILDERS_ENABLED": "true"
}
EOF

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ import cx from "classnames";
import { Control, Controller } from "react-hook-form";
import { ButtonGroup } from "reactstrap";
import { SessionLauncherForm } from "../../sessionsV2.types";
import { useContext } from "react";
import AppContext from "../../../../utils/context/appContext";
import { DEFAULT_APP_PARAMS } from "../../../../utils/context/appParams.constants";

interface EnvironmentKindField {
control: Control<SessionLauncherForm>;
}
export default function EnvironmentKindField({
control,
}: EnvironmentKindField) {
const { params } = useContext(AppContext);
const imageBuildersEnabled =
params?.IMAGE_BUILDERS_ENABLED ?? DEFAULT_APP_PARAMS.IMAGE_BUILDERS_ENABLED;

return (
<Controller
control={control}
Expand Down Expand Up @@ -67,22 +74,26 @@ export default function EnvironmentKindField({
Custom Environment
</label>

<input
type="radio"
className="btn-check"
name={field.name}
autoComplete="off"
checked={field.value === "BUILDER"}
id="environment-kind-builder-radio"
onChange={() => field.onChange("BUILDER")}
onBlur={field.onBlur}
/>
<label
className={cx("btn", "btn-outline-primary")}
htmlFor="environment-kind-builder-radio"
>
Create from a repository
</label>
{imageBuildersEnabled && (
<>
<input
type="radio"
className="btn-check"
name={field.name}
autoComplete="off"
checked={field.value === "BUILDER"}
id="environment-kind-builder-radio"
onChange={() => field.onChange("BUILDER")}
onBlur={field.onBlur}
/>
<label
className={cx("btn", "btn-outline-primary")}
htmlFor="environment-kind-builder-radio"
>
Create from a repository
</label>
</>
)}
</ButtonGroup>
</div>
)}
Expand Down
2 changes: 2 additions & 0 deletions client/src/utils/context/appParams.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ export const DEFAULT_APP_PARAMS: AppParams = {
UPLOAD_THRESHOLD: DEFAULT_UPLOAD_THRESHOLD,
USER_PREFERENCES_MAX_PINNED_PROJECTS:
DEFAULT_USER_PREFERENCES_MAX_PINNED_PROJECTS,
// new
IMAGE_BUILDERS_ENABLED: false,
};
3 changes: 3 additions & 0 deletions client/src/utils/context/appParams.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface AppParams {
UI_VERSION: string;
UPLOAD_THRESHOLD: UploadThresholdParams;
USER_PREFERENCES_MAX_PINNED_PROJECTS: number;

// new
IMAGE_BUILDERS_ENABLED: boolean;
}

export type AppParamsStrings = {
Expand Down
6 changes: 6 additions & 0 deletions client/src/utils/context/appParams.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ export function validatedAppParams(params: unknown): AppParams {
"PRIVACY_BANNER_ENABLED"
);
const TERMS_PAGES_ENABLED = validateBoolean(params_, "TERMS_PAGES_ENABLED");
const IMAGE_BUILDERS_ENABLED = validateBoolean(
params_,
"IMAGE_BUILDERS_ENABLED"
);

// Integer params
const USER_PREFERENCES_MAX_PINNED_PROJECTS = validateInteger(
Expand Down Expand Up @@ -108,6 +112,8 @@ export function validatedAppParams(params: unknown): AppParams {
UI_VERSION,
UPLOAD_THRESHOLD,
USER_PREFERENCES_MAX_PINNED_PROJECTS,
// new
IMAGE_BUILDERS_ENABLED,
};
}

Expand Down
Loading