Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show folder icon for empty folders #102

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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