@@ -81,6 +81,10 @@ type IssueFlagTableProps = {
8181 canEdit : boolean ;
8282} ;
8383
84+ type FeatureState = FlagModel & {
85+ [ key : string ] : string | number | EnvironmentFeatureState [ ] ;
86+ } ;
87+
8488const IssueFlagTable = ( {
8589 projectUrl,
8690 apiKey,
@@ -90,7 +94,7 @@ const IssueFlagTable = ({
9094 onRemove,
9195 canEdit,
9296} : IssueFlagTableProps ) => {
93- const [ environmentFlags , setEnvironmentFlags ] = useState < any > ( [ ] ) ;
97+ const [ environmentFlags , setEnvironmentFlags ] = useState < FeatureState [ ] > ( [ ] ) ;
9498
9599 useEffect ( async ( ) => {
96100 // Filtered features by comparing their IDs with the feature IDs stored in Jira.
@@ -99,7 +103,7 @@ const IssueFlagTable = ({
99103 ) ;
100104 try {
101105 if ( environments . length > 0 && flagsmithfeaturesFiltered . length > 0 ) {
102- const featureState : any = { } ;
106+ const featureState : { [ key : string ] : FeatureState } = { } ;
103107 // Iterate over each filtered feature.
104108 for ( const feature of flagsmithfeaturesFiltered ) {
105109 // Initialize an object to store the state of the feature.
@@ -119,11 +123,13 @@ const IssueFlagTable = ({
119123 ffData . name = environment . name ;
120124 ffData . api_key = String ( environment . api_key ) ;
121125 // Add the feature state data to the feature state object.
122- featureState [ String ( feature . name ) ] . environments . push ( ffData ) ;
126+ featureState [ String ( feature . name ) ] ? .environments . push ( ffData ) ;
123127 }
124128 }
125- const ffArray = Object . keys ( featureState ) . map ( ( featureName ) => featureState [ featureName ] ) ;
126- setEnvironmentFlags ( ffArray ) ;
129+ const ffArray = Object . keys ( featureState ) . map (
130+ ( featureName ) => featureState [ featureName ] ,
131+ ) as FeatureState [ ] ;
132+ setEnvironmentFlags ( ffArray as FeatureState [ ] ) ;
127133 } else {
128134 setEnvironmentFlags ( [ ] ) ;
129135 }
@@ -139,7 +145,7 @@ const IssueFlagTable = ({
139145 let first = true ;
140146 return (
141147 < Fragment >
142- { environmentFlags . map ( ( environmentFlag : FlagModel ) => {
148+ { environmentFlags . map ( ( environmentFlag : FeatureState ) => {
143149 // add vertical space to separate the previous feature's Remove button from this feature
144150 const spacer = first ? null : < Text > </ Text > ;
145151 first = false ;
@@ -173,12 +179,12 @@ const IssueFlagTable = ({
173179 if ( ! flag ) return null ;
174180 // count variations/overrides
175181 const variations = flag . multivariate_feature_state_values . length ;
176- const segments = environmentFlags . filter (
182+ const segments = environmentFlag . environments . filter (
177183 ( each : EnvironmentFeatureState ) =>
178184 String ( each . feature ) === String ( environmentFlag . feature_id ) &&
179185 each . feature_segment !== null ,
180186 ) . length ;
181- const identities = environmentFlags . filter (
187+ const identities = environmentFlag . environments . filter (
182188 ( each : EnvironmentFeatureState ) =>
183189 String ( each . feature ) === String ( environmentFlag . feature_id ) &&
184190 each . identity !== null ,
0 commit comments