1- import { useContext , useMemo } from "react" ;
2- import { ExperimentsContext } from "../contexts/ExperimentsContext" ;
3- import { ParameterDisplayGroupsContext } from "../contexts/ParameterDisplayGroupsContext" ;
1+ import { useMemo } from "react" ;
42import { ButtonComponent } from "./parameterComponents/Button" ;
3+ import { Output } from "./parameterComponents/Output" ;
54import { ParameterNumberComponent } from "./parameterComponents/ParameterNumberComponent" ;
65import { Combobox } from "./parameterComponents/Combobox" ;
76import { useScanContext } from "../hooks/useScanContext" ;
87import { getScanIndex } from "../utils/getScanIndex" ;
98import { useResponsiveGridColumns } from "../hooks/useResponsiveGridColumns" ;
9+ import { ParameterMetadata } from "../types/ExperimentMetadata" ;
10+ import { ParameterValue } from "../types/ExperimentData" ;
1011
1112interface ParameterGroupDisplayProps {
13+ parameters : Record < string , ParameterMetadata > ;
14+ values ?: Record < string , ParameterValue > ;
1215 experimentKey ?: string ;
1316 experimentGroup ?: string ;
1417 namespace ?: string ;
1518 displayGroup ?: string ;
19+ readOnly ?: boolean ;
1620}
1721
1822const extractNamespaceFromParamId = ( parameterId : string ) : string | null => {
@@ -25,33 +29,13 @@ export const ParameterGroupDisplay = ({
2529 experimentGroup,
2630 namespace,
2731 displayGroup,
32+ parameters,
33+ values,
34+ readOnly = false ,
2835} : ParameterGroupDisplayProps ) => {
2936 const { scannedParamKeys, handleRightClick } = useScanContext ( ) ;
3037 const gridTemplateColumns = useResponsiveGridColumns ( ) ;
3138
32- const experiments = useContext ( ExperimentsContext ) ;
33- const { parameterDisplayGroups } = useContext ( ParameterDisplayGroupsContext ) ;
34-
35- // Determine parameters based on props
36- const parameters = useMemo ( ( ) => {
37- if ( experimentKey && experimentGroup ) {
38- // Fetch parameters from ExperimentsContext
39- return experiments [ experimentKey ] ?. parameters ?. [ experimentGroup ] || { } ;
40- }
41- if ( namespace && displayGroup ) {
42- // Fetch parameters from ParameterDisplayGroupsContext
43- return parameterDisplayGroups [ `${ namespace } (${ displayGroup } )` ] || { } ;
44- }
45- return { } ;
46- } , [
47- experimentKey ,
48- experimentGroup ,
49- namespace ,
50- displayGroup ,
51- experiments ,
52- parameterDisplayGroups ,
53- ] ) ;
54-
5539 // Memoize sorting
5640 const sortedParameters = useMemo ( ( ) => {
5741 return Object . entries ( parameters ) . sort ( ( a , b ) =>
@@ -69,6 +53,20 @@ export const ParameterGroupDisplay = ({
6953 >
7054 { sortedParameters . map ( ( [ paramId , paramMetadata ] ) => {
7155 const scanIndex = getScanIndex ( paramId , scannedParamKeys ) ;
56+ const value = values ?. [ paramId ] ?. value ;
57+
58+ if ( readOnly ) {
59+ return (
60+ < Output
61+ id = { paramId }
62+ label = { paramMetadata . display_name }
63+ value = { value }
64+ defaultValue = { paramMetadata . default_value }
65+ scanIndex = { scanIndex }
66+ description = { paramId }
67+ />
68+ ) ;
69+ }
7270
7371 if ( paramId . includes ( "param_type='ParameterTypes.BOOLEAN'" ) ) {
7472 return (
@@ -79,6 +77,7 @@ export const ParameterGroupDisplay = ({
7977 id = { paramId }
8078 displayName = { paramMetadata . display_name }
8179 defaultValue = { Boolean ( paramMetadata . default_value ) }
80+ value = { value != null ? Boolean ( value ) : undefined }
8281 namespace = {
8382 namespace === undefined
8483 ? experimentKey === undefined
@@ -101,6 +100,7 @@ export const ParameterGroupDisplay = ({
101100 key = { paramId }
102101 id = { paramId }
103102 defaultValue = { String ( paramMetadata . default_value ) }
103+ value = { value ?. toString ( ) }
104104 displayName = { paramMetadata . display_name }
105105 allowedValues = { paramMetadata . allowed_values ! }
106106 />
@@ -117,6 +117,7 @@ export const ParameterGroupDisplay = ({
117117 min = { paramMetadata ?. min_value }
118118 max = { paramMetadata ?. max_value }
119119 unit = { paramMetadata ?. unit }
120+ value = { value ?. toString ( ) }
120121 namespace = {
121122 namespace === undefined
122123 ? experimentKey === undefined
0 commit comments