From a6b243e59a6c142d664f7c6e65182dbc9ccf46c6 Mon Sep 17 00:00:00 2001 From: John Kasper Svergja Date: Wed, 16 Aug 2023 14:51:25 +0200 Subject: [PATCH] Add env variable which controls if auto launch is enabled or not Keep old behaviour of allowing auto launch by default. --- .env | 4 +++- src/ui/env.ts | 15 +++++++++++++++ .../catalog/CatalogLauncher/CatalogLauncher.tsx | 4 +++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.env b/.env index a8e633719..2b175df6c 100644 --- a/.env +++ b/.env @@ -118,4 +118,6 @@ REACT_APP_EXTRA_LEFTBAR_ITEMS= REACT_APP_HEADER_LINKS= # Description used in the preview card for social media: https://user-images.githubusercontent.com/6702424/152668805-d1e055e0-2d9d-4b6c-9bc7-fba0093855aa.png -REACT_APP_DESCRIPTION=Data science oriented container launcher +REACT_APP_DESCRIPTION=Data science oriented container launcher + +REACT_APP_DISABLE_AUTO_LAUNCH=false diff --git a/src/ui/env.ts b/src/ui/env.ts index adeee4d38..4262375d4 100644 --- a/src/ui/env.ts +++ b/src/ui/env.ts @@ -69,6 +69,21 @@ export const getIsHomePageDisabled = memoize((): boolean => { return DISABLE_HOME_PAGE === "true"; }); +export const getIsAutoLaunchDisabled = memoize((): boolean => { + const { DISABLE_AUTO_LAUNCH } = getEnv(); + + const possibleValues = ["true", "false"]; + + assert( + possibleValues.indexOf(DISABLE_AUTO_LAUNCH) >= 0, + `${symToStr({ DISABLE_AUTO_LAUNCH })} should either be ${possibleValues.join( + " or " + )}` + ); + + return DISABLE_AUTO_LAUNCH === "true"; +}); + export const getDoHideOnyxia = memoize((): boolean => { const { HEADER_HIDE_ONYXIA } = getEnv(); diff --git a/src/ui/pages/catalog/CatalogLauncher/CatalogLauncher.tsx b/src/ui/pages/catalog/CatalogLauncher/CatalogLauncher.tsx index bd45c70e2..9d2a5e1d0 100644 --- a/src/ui/pages/catalog/CatalogLauncher/CatalogLauncher.tsx +++ b/src/ui/pages/catalog/CatalogLauncher/CatalogLauncher.tsx @@ -23,6 +23,7 @@ import type { UnpackEvt } from "evt"; import { Markdown } from "onyxia-ui/Markdown"; import { declareComponentKeys } from "i18nifty"; import { symToStr } from "tsafe/symToStr"; +import { getIsAutoLaunchDisabled } from "../../../env"; export type Props = { className?: string; @@ -178,7 +179,8 @@ export const CatalogLauncher = memo((props: Props) => { case "ready": switch (state.launchState) { case "not launching": - if (route.params.autoLaunch) { + const autoLaunchEnabled = !getIsAutoLaunchDisabled(); + if (autoLaunchEnabled && route.params.autoLaunch) { const { sensitiveConfigurations } = state; if (sensitiveConfigurations.length !== 0) {