Skip to content

Commit edeca49

Browse files
rd merge
1 parent faec643 commit edeca49

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

editor-packages/editor-dashboard/scaffold/editor-dashboard-hierarchy.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function DashboardHierarchy() {
1717
const renderItem = useCallback(
1818
(item: DashboardItem, i: number) => {
1919
const selected = selection.includes(item.id);
20-
const depth = item.path.split("/").length - 1;
20+
const depth = getHierarchyDepth(item.path);
2121

2222
return (
2323
<HierarchyRow
@@ -77,3 +77,16 @@ function pushhash(router: NextRouter, hash: string) {
7777
}
7878
});
7979
}
80+
81+
/**
82+
* get the depth via the path (ignore the first slash)
83+
* @param path
84+
* @returns
85+
*/
86+
function getHierarchyDepth(path: string): number {
87+
const splits = path.split("/");
88+
if (splits[0] === "") {
89+
return splits.length - 2;
90+
}
91+
return splits.length - 1;
92+
}

editor-packages/editor-dashboard/scaffold/editor-dashboard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function RootDirectory({
172172
}) {
173173
return (
174174
<div style={{ marginBottom: 32 }}>
175-
<RootDirectoryContextMenuProvider cwd={path}>
175+
<RootDirectoryContextMenuProvider cwd={path} disabled>
176176
<Collapsible.Root open={expanded} onOpenChange={onExpandChange}>
177177
<SectionHeader
178178
id={path}
@@ -212,9 +212,11 @@ function Providers({ children }: React.PropsWithChildren<{}>) {
212212

213213
function RootDirectoryContextMenuProvider({
214214
children,
215+
disabled,
215216
cwd,
216217
}: React.PropsWithChildren<{
217218
cwd: string;
219+
disabled?: boolean;
218220
}>) {
219221
const { mkdir } = useDashboard();
220222
const items: MenuItem<string>[] = [
@@ -239,6 +241,10 @@ function RootDirectoryContextMenuProvider({
239241
[mkdir]
240242
);
241243

244+
if (disabled) {
245+
return <>{children}</>;
246+
}
247+
242248
return (
243249
<ContextMenu items={items} onSelect={onselect}>
244250
{children}

0 commit comments

Comments
 (0)