@@ -3,28 +3,16 @@ import type { ComponentProps } from 'react';
33import { useEffect } from 'react' ;
44import SplitterLayout from 'react-splitter-layout' ;
55import styled from 'styled-components' ;
6+ import type { ScanningItem } from 'backend/handler/SourceHandler.types' ;
7+ import type { WidgetData } from 'app/utils/StageAPI' ;
68import Actions from './actions' ;
9+ import type { BlueprintSourcesData } from './widget' ;
710
811const { CancelButton, NodesTree, Message, Label, Modal, HighlightText, ErrorMessage, Icon } = Stage . Basic ;
912const { useResettableState, useBoolean } = Stage . Hooks ;
1013
1114type FileType = ComponentProps < typeof HighlightText > [ 'language' ] ;
1215
13- interface NodeTreeItem {
14- children ?: NodeTreeItem [ ] ;
15- key : string ;
16- title : string ;
17- isDir : boolean ;
18- }
19-
20- interface BlueprintTree {
21- children : NodeTreeItem [ ] ;
22- key : string ;
23- title : string ;
24- isDir : boolean ;
25- timestamp : number ;
26- }
27-
2816const StyledHighlightText = styled ( HighlightText ) `
2917 margin-top: 2rem;
3018 margin-bottom: 0rem;
@@ -107,13 +95,7 @@ const RightPane = ({
10795} ;
10896
10997interface BlueprintSourcesProps {
110- data : {
111- blueprintId : string ;
112- blueprintTree : BlueprintTree ;
113- importedBlueprintIds : string [ ] ;
114- importedBlueprintTrees : BlueprintTree [ ] ;
115- yamlFileName : string ;
116- } ;
98+ data : NonNullable < WidgetData < BlueprintSourcesData > > ;
11799 toolbox : Stage . Types . Toolbox ;
118100 widget : Stage . Types . Widget ;
119101}
@@ -186,10 +168,10 @@ export default function BlueprintSources({ data, toolbox, widget }: BlueprintSou
186168 . finally ( ( ) => toolbox . loading ( false ) ) ;
187169 } ;
188170
189- const loop = ( blueprintId : string , timestamp : number , items : NodeTreeItem [ ] ) => {
171+ const loop = ( blueprintId : string , timestamp : string , items : ScanningItem [ ] ) => {
190172 return items . map ( item => {
191173 const key = `${ blueprintId } /file/${ timestamp } /${ item . key } ` ;
192- if ( item . children ) {
174+ if ( item . isDir ) {
193175 return (
194176 < NodesTree . Node
195177 key = { key }
@@ -204,7 +186,7 @@ export default function BlueprintSources({ data, toolbox, widget }: BlueprintSou
204186 </ NodesTree . Node >
205187 ) ;
206188 }
207- const blueprintRootDirectory = data . blueprintTree . children [ 0 ] . key ;
189+ const blueprintRootDirectory = data . blueprintTree ! . children [ 0 ] . key ;
208190 const mainYamlFilePath = `${ blueprintRootDirectory } /${ data . yamlFileName } ` ;
209191 const label =
210192 mainYamlFilePath === item . key ? (
@@ -250,7 +232,7 @@ export default function BlueprintSources({ data, toolbox, widget }: BlueprintSou
250232 </ Label >
251233 }
252234 >
253- { loop ( data . blueprintId , data . blueprintTree . timestamp , data . blueprintTree . children ) }
235+ { loop ( data . blueprintId , data . blueprintTree ! . timestamp , data . blueprintTree ! . children ) }
254236 </ NodesTree . Node >
255237 { _ . size ( data . importedBlueprintIds ) > 0 && (
256238 < NodesTree . Node
@@ -275,7 +257,7 @@ export default function BlueprintSources({ data, toolbox, widget }: BlueprintSou
275257 </ Label >
276258 }
277259 >
278- { loop ( data . importedBlueprintIds [ index ] , tree . timestamp , tree . children ) }
260+ { loop ( data . importedBlueprintIds [ index ] , tree ! . timestamp , tree ! . children ) }
279261 </ NodesTree . Node >
280262 ) ) }
281263 </ NodesTree . Node >
0 commit comments