diff --git a/web/src/core/usecases/launcher/selectors.ts b/web/src/core/usecases/launcher/selectors.ts index 60d1609ee..692d88c90 100644 --- a/web/src/core/usecases/launcher/selectors.ts +++ b/web/src/core/usecases/launcher/selectors.ts @@ -119,13 +119,14 @@ const chartVersion = createSelector(readyState, state => { const s3ConfigSelect = createSelector( s3ConfigManagement.selectors.s3Configs, isReady, + projectManagement.selectors.canInjectPersonalInfos, createSelector(readyState, state => { if (state === null) { return null; } return state.s3Config; }), - (s3Configs, isReady, s3Config) => { + (s3Configs, isReady, canInjectPersonalInfos, s3Config) => { if (!isReady) { return null; } @@ -137,13 +138,17 @@ const s3ConfigSelect = createSelector( return undefined; } + const availableConfigs = s3Configs.filter( + config => canInjectPersonalInfos || config.origin !== "deploymentRegion" + ); + // We don't display the s3 config selector if there is no config or only one if (s3Configs.length <= 1) { return undefined; } return { - options: s3Configs.map(s3Config => ({ + options: availableConfigs.map(s3Config => ({ optionValue: s3Config.id, label: { dataSource: s3Config.dataSource, diff --git a/web/src/core/usecases/launcher/thunks.ts b/web/src/core/usecases/launcher/thunks.ts index 1c1714536..b2c62d225 100644 --- a/web/src/core/usecases/launcher/thunks.ts +++ b/web/src/core/usecases/launcher/thunks.ts @@ -153,17 +153,8 @@ export const thunks = { return; } - const { doInjectPersonalInfos } = (() => { - const project = - projectManagement.protectedSelectors.currentProject(getState()); - - const doInjectPersonalInfos = - project.group === undefined || - !rootContext.paramsOfBootstrapCore - .disablePersonalInfosInjectionInGroup; - - return { doInjectPersonalInfos }; - })(); + const doInjectPersonalInfos = + projectManagement.selectors.canInjectPersonalInfos(getState()); const { s3ConfigId, s3ConfigId_default } = (() => { const s3Configs = s3ConfigManagement.selectors diff --git a/web/src/core/usecases/projectManagement/selectors.ts b/web/src/core/usecases/projectManagement/selectors.ts index ffa13f0cb..76e191622 100644 --- a/web/src/core/usecases/projectManagement/selectors.ts +++ b/web/src/core/usecases/projectManagement/selectors.ts @@ -1,5 +1,4 @@ import type { State as RootState } from "core/bootstrap"; -import type { Project } from "core/ports/OnyxiaApi"; import { name } from "./state"; import { createSelector } from "clean-architecture"; import { assert } from "tsafe/assert"; @@ -9,7 +8,7 @@ const state = (rootState: RootState) => rootState[name]; const projectConfig = createSelector(state, state => state.currentProjectConfigs); export const protectedSelectors = { - currentProject: createSelector(state, (state): Project => { + currentProject: createSelector(state, state => { const { projects, selectedProjectId } = state; const project = projects.find(({ id }) => id === selectedProjectId); @@ -46,5 +45,11 @@ export const selectors = { doesUserBelongToSomeGroupProject: createSelector( state, state => state.projects.length !== 1 + ), + canInjectPersonalInfos: createSelector( + protectedSelectors.currentProject, + currentProject => { + return currentProject.doInjectPersonalInfos; + } ) }; diff --git a/web/src/core/usecases/projectManagement/state.ts b/web/src/core/usecases/projectManagement/state.ts index a06cf3723..403a6262b 100644 --- a/web/src/core/usecases/projectManagement/state.ts +++ b/web/src/core/usecases/projectManagement/state.ts @@ -6,7 +6,7 @@ import { import type { ProjectConfigs } from "./decoupledLogic/ProjectConfigs"; type State = { - projects: Project[]; + projects: (Project & { doInjectPersonalInfos: boolean })[]; selectedProjectId: string; currentProjectConfigs: ProjectConfigs; }; diff --git a/web/src/core/usecases/projectManagement/thunks.ts b/web/src/core/usecases/projectManagement/thunks.ts index a03c0f65f..a33a50df5 100644 --- a/web/src/core/usecases/projectManagement/thunks.ts +++ b/web/src/core/usecases/projectManagement/thunks.ts @@ -22,7 +22,11 @@ export const thunks = { changeProject: (params: { projectId: string }) => async (...args) => { - const [dispatch, getState, { onyxiaApi, secretsManager }] = args; + const [ + dispatch, + getState, + { onyxiaApi, secretsManager, paramsOfBootstrapCore } + ] = args; const { projectId } = params; @@ -167,9 +171,16 @@ export const thunks = { } } + const projectWithInjectedPersonalInfos = projects.map(project => ({ + ...project, + doInjectPersonalInfos: + project.group === undefined || + !paramsOfBootstrapCore.disablePersonalInfosInjectionInGroup + })); + dispatch( actions.projectChanged({ - projects, + projects: projectWithInjectedPersonalInfos, selectedProjectId: projectId, currentProjectConfigs: projectConfigs }) diff --git a/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/ProjectSettingsS3ConfigTab.tsx b/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/ProjectSettingsS3ConfigTab.tsx index 839d07bf5..25c216258 100644 --- a/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/ProjectSettingsS3ConfigTab.tsx +++ b/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/ProjectSettingsS3ConfigTab.tsx @@ -41,7 +41,10 @@ export const ProjectSettingsS3ConfigTab = memo((props: Props) => { })); const s3Configs = useCoreState("s3ConfigManagement", "s3Configs"); - + const canInjectPersonalInfos = useCoreState( + "projectManagement", + "canInjectPersonalInfos" + ); const { s3ConfigManagement } = useCore().functions; const { classes, css, theme } = useStyles(); @@ -101,6 +104,7 @@ export const ProjectSettingsS3ConfigTab = memo((props: Props) => { projectS3ConfigId: s3Config.id }); })()} + canInjectPersonalInfos={canInjectPersonalInfos} /> ))} diff --git a/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/S3ConfigCard.tsx b/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/S3ConfigCard.tsx index 8060b198a..9be7d30b2 100644 --- a/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/S3ConfigCard.tsx +++ b/web/src/ui/pages/projectSettings/ProjectSettingsS3ConfigTab/S3ConfigCard.tsx @@ -18,6 +18,7 @@ type Props = { onIsOnyxiaDefaultChange: (value: boolean) => void; onEdit: (() => void) | undefined; onTestConnection: (() => void) | undefined; + canInjectPersonalInfos: boolean; }; export function S3ConfigCard(props: Props) { @@ -28,7 +29,8 @@ export function S3ConfigCard(props: Props) { onIsExplorerConfigChange, onIsOnyxiaDefaultChange, onEdit, - onTestConnection + onTestConnection, + canInjectPersonalInfos } = props; const { classes, cx, css, theme } = useStyles(); @@ -80,7 +82,16 @@ export function S3ConfigCard(props: Props) {   onIsOnyxiaDefaultChange(event.target.checked)} inputProps={{ "aria-label": "controlled" }} />