Skip to content

Commit

Permalink
fix: show folder icon for empty folders (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrodriguez authored Aug 14, 2024
1 parent ecb6826 commit f993bd4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion daemon/domain/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package domain
type Node struct {
ID string `json:"id"`
Label string `json:"label"`
Leaf bool `json:"leaf"`
Parent string `json:"parent"`
Leaf bool `json:"leaf"`
Dir bool `json:"dir"`
}
7 changes: 2 additions & 5 deletions daemon/services/core/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ func (c *Core) GetTree(path, id string) domain.Branch {
node.Label = element.Name()

if element.IsDir() {
node.Dir = true
// let's check if the folder is empty
// we can still get an i/o error, if that's the case
// we assume the folder's empty
Expand All @@ -252,11 +253,7 @@ func (c *Core) GetTree(path, id string) domain.Branch {
// mlog.Warning("GetTree - Unable to determine if folder is empty: %s", folder)
node.Leaf = true
} else {
if empty {
node.Leaf = true
} else {
node.Leaf = false
}
node.Leaf = empty
}
} else {
node.Leaf = true
Expand Down
6 changes: 5 additions & 1 deletion ui/src/shared/tree/node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ export const TreeNode: React.FunctionComponent<TreeNodeProps> = ({
</span>

<span className="ml-1">
{node.leaf ? icons.leafIcon : icons.parentIcon}
{node.leaf
? node.dir
? icons.parentIcon
: icons.leafIcon
: icons.parentIcon}
</span>

<span className="ml-1">{node.label}</span>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/state/gather.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const rootNode = {
id: 'root',
label: '/',
leaf: false,
dir: false,
parent: '',
};

Expand Down Expand Up @@ -70,6 +71,7 @@ export const useGatherStore = create<GatherStore>()(
id: 'loader',
label: 'loading ...',
leaf: false,
dir: false,
parent: node.id,
children: [],
checked: false,
Expand Down
3 changes: 3 additions & 0 deletions ui/src/state/scatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ const rootNode = {
id: 'root',
label: '/',
leaf: false,
dir: false,
parent: '',
};

const loaderNode = {
id: 'loader',
label: 'loading ...',
leaf: false,
dir: false,
parent: 'root',
};

Expand Down Expand Up @@ -90,6 +92,7 @@ export const useScatterStore = create<ScatterStore>()(
id: 'loader',
label: 'loading ...',
leaf: false,
dir: false,
parent: node.id,
children: [],
checked: false,
Expand Down
1 change: 1 addition & 0 deletions ui/src/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export interface Node {
id: string;
label: string;
leaf: boolean;
dir: boolean;
parent: string;
checked?: boolean;
expanded?: boolean;
Expand Down

0 comments on commit f993bd4

Please sign in to comment.