Skip to content
Open
Changes from 3 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
41 changes: 41 additions & 0 deletions client/src/components/ContentNavigator/ContentDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ class ContentDataProvider
public dropMimeTypes: string[];
public dragMimeTypes: string[];

private parentPathCache = new Map<string, string>();

get treeView(): TreeView<ContentItem> {
return this._treeView;
}
Expand Down Expand Up @@ -213,6 +215,20 @@ class ContentDataProvider
public async getTreeItem(item: ContentItem): Promise<TreeItem> {
const isContainer = getIsContainer(item);
const uri = await this.model.getUri(item, false);
let tooltip = item.name;

const canCopyPath = item.contextValue?.includes("copyPath");

if (canCopyPath) {
try {
const parentPath = await this.getCachedParentPath(item);
if (parentPath) {
tooltip = parentPath + "/" + item.name;
}
} catch {
// If getting parent path fails, tooltip will remain as item.name
}
}

return {
collapsibleState: isContainer
Expand All @@ -230,6 +246,7 @@ class ContentDataProvider
id: item.uid,
label: item.name,
resourceUri: uri,
tooltip: tooltip,
};
}

Expand Down Expand Up @@ -735,6 +752,30 @@ class ContentDataProvider
}
: undefined;
}

private async getCachedParentPath(item: ContentItem): Promise<string> {
const parentUri = item.parentFolderUri;
if (!parentUri) {
return "";
}

if (!this.parentPathCache.has(parentUri)) {
try {
const fullPath = await this.model.getPathOfItem(item);
if (fullPath) {
const parentPath =
fullPath.substring(0, fullPath.lastIndexOf("/")) || "/";
this.parentPathCache.set(parentUri, parentPath);
} else {
this.parentPathCache.set(parentUri, "");
}
} catch {
this.parentPathCache.set(parentUri, "");
}
}

return this.parentPathCache.get(parentUri) || "";
}
}

export default ContentDataProvider;
Expand Down
Loading