refactor: delegate filetree asset append
This commit is contained in:
@@ -3162,10 +3162,16 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
function fileTreeRuntimeDeps() {
|
||||
return {
|
||||
currentSourceKind: currentSourceKind,
|
||||
currentDocumentId: currentDocumentId,
|
||||
localFilePathFromAssetId: localFilePathFromAssetId,
|
||||
rowTitle: rowTitle,
|
||||
resolveWorkspaceId: resolveWorkspaceId,
|
||||
cssEscape: cssEscape
|
||||
cssEscape: cssEscape,
|
||||
escapeHtml: escapeHtml,
|
||||
objectIdentityAttr: objectIdentityAttr,
|
||||
uploadedAssetTitle: uploadedAssetTitle,
|
||||
uploadedAssetType: uploadedAssetType,
|
||||
fileTreeIconKindForFileName: fileTreeIconKindForFileName
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3529,6 +3535,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function revealFileTreeRow(row) {
|
||||
var runtimeFn = fileTreeRuntimeFunction('revealFileTreeRow');
|
||||
if (runtimeFn) return runtimeFn(row, fileTreeRuntimeDeps());
|
||||
if (!(row instanceof HTMLElement)) return;
|
||||
var node = row.closest('.tree-node');
|
||||
while (node && node.parentElement) {
|
||||
@@ -3548,6 +3556,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function revealFileTreeAssetRow(assetId) {
|
||||
var runtimeFn = fileTreeRuntimeFunction('revealFileTreeAssetRow');
|
||||
if (runtimeFn) return runtimeFn(assetId, fileTreeRuntimeDeps());
|
||||
if (!assetId) return false;
|
||||
var row = document.querySelector('.tree-row[data-shell-mode="filetree"][data-asset-id="' + cssEscape(assetId) + '"]');
|
||||
if (!(row instanceof HTMLElement)) return false;
|
||||
@@ -3556,6 +3566,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function appendUploadedAssetRow(asset, documentId) {
|
||||
var runtimeFn = fileTreeRuntimeFunction('appendUploadedAssetRow');
|
||||
if (runtimeFn) return runtimeFn(asset, documentId, fileTreeRuntimeDeps());
|
||||
var assetId = String(asset && asset.id || '').trim();
|
||||
if (!assetId) return false;
|
||||
if (revealFileTreeAssetRow(assetId)) return true;
|
||||
@@ -11038,6 +11050,9 @@ mod tests {
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeAssetDownloadDetail')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeRowsByRowIds')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeChildCount')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('revealFileTreeRow')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('revealFileTreeAssetRow')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('appendUploadedAssetRow')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeUploadTargetFallback')"));
|
||||
let document_id_body = js_function_body(SIDEBAR_TREE_JS, "fileTreeRowDocumentId");
|
||||
assert!(
|
||||
@@ -11058,7 +11073,11 @@ mod tests {
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeAssetDownloadDetail"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeRowsByRowIds"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeChildCount"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function revealFileTreeRow"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function revealFileTreeAssetRow"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function appendUploadedAssetRow"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeUploadTargetFallback"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("appendUploadedAssetRow: appendUploadedAssetRow"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
|
||||
Reference in New Issue
Block a user