| 127 | } |
| 128 | |
| 129 | func (d *Dive) loadFileExplorerData(nodeKey string) { |
| 130 | // Configure tree |
| 131 | root := tview.NewTreeNode("[::b]Filetree[::-]") |
| 132 | for _, child := range d.buildpacksTreeMap[nodeKey].GetChildren() { |
| 133 | root.AddChild(child) |
| 134 | } |
| 135 | |
| 136 | d.fileExplorerTable.Clear() |
| 137 | |
| 138 | // Configure Table |
| 139 | d.fileExplorerTable.SetCell(0, 0, tview.NewTableCell("[::b]Permission[::-]").SetSelectable(false)) |
| 140 | d.fileExplorerTable.SetCell(0, 1, tview.NewTableCell("[::b]UID:GID[::-]").SetSelectable(false). |
| 141 | SetAlign(tview.AlignRight)) |
| 142 | d.fileExplorerTable.SetCell(0, 2, tview.NewTableCell("[::b]Size[::-] ").SetSelectable(false). |
| 143 | SetAlign(tview.AlignRight)) |
| 144 | d.fileExplorerTable.SetCell(0, 3, tview.NewTableCell("[::b]Filetree[::-]").SetSelectable(false)) |
| 145 | |
| 146 | branchesMapping := map[*tview.TreeNode]Branches{ |
| 147 | root: {}, |
| 148 | } |
| 149 | |
| 150 | root.Walk(func(node, parent *tview.TreeNode) bool { |
| 151 | if node == root { |
| 152 | return true |
| 153 | } |
| 154 | |
| 155 | childCount := len(parent.GetChildren()) |
| 156 | isLast := parent.GetChildren()[childCount-1] == node |
| 157 | |
| 158 | if isLast { |
| 159 | branchesMapping[node] = branchesMapping[parent].Add(NoBranchSymbol) |
| 160 | } else { |
| 161 | branchesMapping[node] = branchesMapping[parent].Add(BranchSymbol) |
| 162 | } |
| 163 | |
| 164 | return true |
| 165 | }) |
| 166 | |
| 167 | var tableRow = 0 |
| 168 | root.Walk(func(node, parent *tview.TreeNode) bool { |
| 169 | if node == root { |
| 170 | tableRow++ |
| 171 | return true |
| 172 | } |
| 173 | |
| 174 | ref := node.GetReference().(*tar.Header) |
| 175 | |
| 176 | collapseIcon := "" |
| 177 | if !node.IsExpanded() { |
| 178 | collapseIcon = " ⬥ " |
| 179 | } |
| 180 | |
| 181 | size := "-" |
| 182 | if ref.Typeflag != tar.TypeDir { |
| 183 | size = humanize.Bytes(uint64(ref.Size)) |
| 184 | } |
| 185 | |
| 186 | color := "" |