@@ -5,7 +5,15 @@ import { LitElement, html, nothing } from "lit";
55import { currentLang } from "../../../common/utils.js" ;
66import { EVENTS } from "../../../core/events.js" ;
77import { treeStyles } from "./tree-styles.js" ;
8- import { CARD_WIDTH , CONNECTOR_GAP , GAP_ROW_HEIGHT , computeDepthGroups , computeTreeLayout } from "./tree-layout.js" ;
8+ import {
9+ CARD_WIDTH ,
10+ CONNECTOR_GAP ,
11+ GAP_ROW_HEIGHT ,
12+ ACTIVITY_GROUPS ,
13+ computeDepthGroups ,
14+ computeTreeLayout ,
15+ computeActivityGroups
16+ } from "./tree-layout.js" ;
917import { renderCardContent } from "./tree-card.js" ;
1018import { drawConnectors } from "./tree-connectors.js" ;
1119import "../../../components/root-selector/root-selector.js" ;
@@ -138,6 +146,41 @@ class TreeView extends LitElement {
138146 ` ;
139147 }
140148
149+ #renderActivityColumn( bucket , nodeIds ) {
150+ const i18n = window . i18n [ currentLang ( ) ] ;
151+ const labelKey = `activity${ bucket . key . charAt ( 0 ) . toUpperCase ( ) } ${ bucket . key . slice ( 1 ) } ` ;
152+
153+ return html `
154+ < div class ="depth-column ">
155+ < div class ="depth-column--header " style ="border-bottom-color: ${ bucket . color } ">
156+ < span class ="depth-column--label " style ="color: ${ bucket . color } "> ${ i18n . tree [ labelKey ] } </ span >
157+ < span class ="depth-column--count " style ="background: ${ bucket . color } "> ${ nodeIds . length } </ span >
158+ </ div >
159+ < div class ="depth-column--cards ">
160+ ${ nodeIds . map ( ( nodeId ) => {
161+ const entry = this . secureDataSet . linker . get ( nodeId ) ;
162+ const publishedAt = this . secureDataSet . data . dependencies [ entry . name ] ?. metadata ?. lastUpdateAt ?? null ;
163+
164+ return renderCardContent ( this . secureDataSet , { nodeId, publishedAt, publishedColor : bucket . color } ) ;
165+ } ) }
166+ </ div >
167+ </ div >
168+ ` ;
169+ }
170+
171+ #renderActivityMode( ) {
172+ const activityGroups = computeActivityGroups (
173+ this . secureDataSet . linker ,
174+ this . secureDataSet . data . dependencies
175+ ) ;
176+
177+ return html `
178+ < div class ="depth-container ">
179+ ${ ACTIVITY_GROUPS . map ( ( bucket ) => this . #renderActivityColumn( bucket , activityGroups . get ( bucket . key ) ) ) }
180+ </ div >
181+ ` ;
182+ }
183+
141184 #renderHeader( depthGroups ) {
142185 const totalDeps = Object . keys ( this . secureDataSet . data . dependencies ) . length ;
143186 const directDeps = ( depthGroups . get ( 1 ) ?? [ ] ) . length ;
@@ -165,11 +208,28 @@ class TreeView extends LitElement {
165208 this . _mode = "tree" ;
166209 } }
167210 > ${ i18n . tree . modeTree } </ button >
211+ < button
212+ class ="mode-btn ${ this . _mode === "activity" ? "active" : "" } "
213+ @click =${ ( ) => {
214+ this . _mode = "activity" ;
215+ } }
216+ > ${ i18n . tree . modeActivity } </ button >
168217 </ div >
169218 </ div >
170219 ` ;
171220 }
172221
222+ #renderBody( depthGroups , maxDepth ) {
223+ if ( this . _mode === "tree" ) {
224+ return this . #renderTreeMode( maxDepth ) ;
225+ }
226+ else if ( this . _mode === "activity" ) {
227+ return this . #renderActivityMode( ) ;
228+ }
229+
230+ return this . #renderDepthMode( depthGroups ) ;
231+ }
232+
173233 render ( ) {
174234 if ( ! this . secureDataSet ?. data ) {
175235 return nothing ;
@@ -183,10 +243,7 @@ class TreeView extends LitElement {
183243
184244 return html `
185245 ${ this . #renderHeader( depthGroups ) }
186- ${ this . _mode === "tree"
187- ? this . #renderTreeMode( maxDepth )
188- : this . #renderDepthMode( depthGroups )
189- }
246+ ${ this . #renderBody( depthGroups , maxDepth ) }
190247 ` ;
191248 }
192249}
0 commit comments