refactor: extract filetree preflight helpers
This commit is contained in:
@@ -2966,6 +2966,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
});
|
||||
|
||||
function fileTreeRowsForUploadPreflight() {
|
||||
var runtimeFn = fileTreeRuntimeFunction('fileTreeRowsForUploadPreflight');
|
||||
if (runtimeFn) return runtimeFn(fileTreeRuntimeDeps());
|
||||
return Array.from(document.querySelectorAll('.tree-row[data-shell-mode="filetree"]')).map(function(row) {
|
||||
return {
|
||||
rowId: row.getAttribute('data-row-id') || '',
|
||||
@@ -3031,6 +3033,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function fileTreeDocumentParentsForPreflight() {
|
||||
var runtimeFn = fileTreeRuntimeFunction('fileTreeDocumentParentsForPreflight');
|
||||
if (runtimeFn) return runtimeFn(fileTreeRuntimeDeps());
|
||||
return Array.from(document.querySelectorAll('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"]')).map(function(row) {
|
||||
var documentId = row.getAttribute('data-document-id') || row.getAttribute('data-doc-id') || '';
|
||||
if (!documentId) return null;
|
||||
@@ -3041,6 +3045,8 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function fileTreeTargetChildrenForPreflight(targetRow) {
|
||||
var runtimeFn = fileTreeRuntimeFunction('fileTreeTargetChildrenForPreflight');
|
||||
if (runtimeFn) return runtimeFn(targetRow, fileTreeRuntimeDeps());
|
||||
var node = targetRow instanceof HTMLElement ? targetRow.closest('.tree-node') : null;
|
||||
if (!node) return [];
|
||||
return Array.from(node.querySelectorAll(':scope > .tree-children > .tree-node > .tree-row[data-shell-mode="filetree"]')).map(function(row) {
|
||||
@@ -3054,6 +3060,10 @@ const SIDEBAR_TREE_JS: &str = r##"
|
||||
}
|
||||
|
||||
function fileTreeDropPreflightRows() {
|
||||
var runtimeFn = fileTreeRuntimeFunction('fileTreeDropPreflightRows');
|
||||
if (runtimeFn) return runtimeFn(Object.assign({}, fileTreeRuntimeDeps(), {
|
||||
fileTreeRowsForUploadPreflight: fileTreeRowsForUploadPreflight
|
||||
}));
|
||||
return fileTreeRowsForUploadPreflight().map(function(row) {
|
||||
var domRow = document.querySelector('#sidebar-file-tree-root .tree-row[data-shell-mode="filetree"][data-row-id="' + cssEscape(row.rowId) + '"]');
|
||||
row.title = rowTitle(domRow);
|
||||
@@ -11099,6 +11109,14 @@ mod tests {
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('revealFileTreeAssetRow')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('appendUploadedAssetRow')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeUploadTargetFallback')"));
|
||||
assert!(
|
||||
SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeRowsForUploadPreflight')")
|
||||
);
|
||||
assert!(SIDEBAR_TREE_JS
|
||||
.contains("fileTreeRuntimeFunction('fileTreeDocumentParentsForPreflight')"));
|
||||
assert!(SIDEBAR_TREE_JS
|
||||
.contains("fileTreeRuntimeFunction('fileTreeTargetChildrenForPreflight')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('fileTreeDropPreflightRows')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('readProjection')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('readSidebarDataset')"));
|
||||
assert!(SIDEBAR_TREE_JS.contains("fileTreeRuntimeFunction('readDatasetProjection')"));
|
||||
@@ -11160,6 +11178,10 @@ mod tests {
|
||||
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("function fileTreeRowsForUploadPreflight"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeDocumentParentsForPreflight"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeTargetChildrenForPreflight"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function fileTreeDropPreflightRows"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function readProjection"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function readSidebarDataset"));
|
||||
assert!(FILETREE_RUNTIME_JS.contains("function readDatasetProjection"));
|
||||
@@ -11182,6 +11204,15 @@ mod tests {
|
||||
.contains("applyLocalFolderSidebarSnapshot: applyLocalFolderSidebarSnapshot"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("markLocalFolderWatchApplied: markLocalFolderWatchApplied"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("fileTreeRowsForUploadPreflight: fileTreeRowsForUploadPreflight"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("fileTreeDocumentParentsForPreflight: fileTreeDocumentParentsForPreflight"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("fileTreeTargetChildrenForPreflight: fileTreeTargetChildrenForPreflight"));
|
||||
assert!(
|
||||
FILETREE_RUNTIME_JS.contains("fileTreeDropPreflightRows: fileTreeDropPreflightRows")
|
||||
);
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
.contains("uploadIntent: String(detail.uploadIntent || 'filetree.folder.drop')"));
|
||||
assert!(FILETREE_RUNTIME_JS
|
||||
|
||||
Reference in New Issue
Block a user