-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f478cc9
commit e6dad79
Showing
3 changed files
with
108 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
...er/components/configuration/components/standard_config_section/StandardConfigViewGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, { useContext } from "react"; | ||
|
||
import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from "@elastic/eui"; | ||
import { TreatmentMappingConfigSection } from "./TreatmentMappingConfigSection"; | ||
import { FallbackRouteConfigSection } from "./FallbackRouteConfigSection"; | ||
import ExperimentEngineContext from "../../../../../providers/experiments/context"; | ||
import { Panel} from "../../../form/components/Panel"; | ||
import StandardEnsemblerLoaderComponent from "../../../../../components/ensembler/StandardEnsemblerLoaderComponent"; | ||
import { RemoteComponent } from "../../../../../components/remote_component/RemoteComponent"; | ||
|
||
const FallbackView = ({ text }) => ( | ||
<EuiFlexItem grow={true}> | ||
<Panel title="Route Selection"> | ||
<EuiSpacer size="m" /> | ||
{text} | ||
</Panel> | ||
</EuiFlexItem> | ||
); | ||
|
||
const StandardEnsemblerWithCustomExperimentEngineConfigView = ({ | ||
remoteUi, | ||
projectId, | ||
routes, | ||
routeNamePath | ||
}) => { | ||
// Load component from remote host | ||
return ( | ||
<React.Suspense | ||
fallback={<FallbackView text="Loading Standard Ensembler config for the selected Custom Experiment Engine" />}> | ||
<StandardEnsemblerLoaderComponent | ||
FallbackView={FallbackView} | ||
experimentEngine={remoteUi}> | ||
<RemoteComponent | ||
scope={remoteUi.name} | ||
name="./StandardEnsemblerConfigDetails" | ||
fallback={<FallbackView text="Loading Standard Ensembler config for the selected Custom Experiment Engine" />} | ||
projectId={projectId} | ||
routes={routes} | ||
routeNamePath={routeNamePath} | ||
/> | ||
</StandardEnsemblerLoaderComponent> | ||
</React.Suspense> | ||
); | ||
}; | ||
|
||
|
||
export const StandardConfigViewGroup = ({ | ||
projectId, | ||
routes, | ||
standardConfig, | ||
experimentConfig, | ||
type | ||
}) => { | ||
const { getEngineProperties, isLoaded } = useContext(ExperimentEngineContext); | ||
|
||
const engineProps = getEngineProperties(type); | ||
|
||
return ( | ||
!!standardConfig && ( | ||
<EuiFlexGroup direction="column"> | ||
<> | ||
{engineProps?.type === "standard" ? ( | ||
<EuiFlexItem> | ||
<TreatmentMappingConfigSection | ||
engine={type} | ||
experiments={experimentConfig} | ||
mappings={standardConfig.experiment_mappings} | ||
/> | ||
</EuiFlexItem> | ||
) : isLoaded ? ( | ||
<EuiFlexItem> | ||
<StandardEnsemblerWithCustomExperimentEngineConfigView | ||
remoteUi={engineProps.custom_experiment_manager_config.remote_ui} | ||
projectId={projectId} | ||
routes={routes} | ||
routeNamePath={standardConfig.route_name_path} | ||
/> | ||
</EuiFlexItem> | ||
) : ( | ||
<EuiFlexItem> | ||
<FallbackView text={"Loading ..."} /> | ||
</EuiFlexItem> | ||
)} | ||
|
||
<EuiFlexItem> | ||
<FallbackRouteConfigSection | ||
fallbackResponseRouteId={ | ||
standardConfig.fallback_response_route_id | ||
} | ||
/> | ||
</EuiFlexItem> | ||
</> | ||
</EuiFlexGroup> | ||
) | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters