From 08a3f24903ebcfd5711e9b10a4997dbd23ce4921 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 21 Nov 2024 14:08:42 -0800 Subject: [PATCH 01/19] Create start of flat file map --- .../webviews/homeView/src/stores/home.ts | 5 +++- .../webviews/homeView/src/utils/files.ts | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/webviews/homeView/src/stores/home.ts b/extensions/vscode/webviews/homeView/src/stores/home.ts index 2763ee03c..6719ec6a1 100644 --- a/extensions/vscode/webviews/homeView/src/stores/home.ts +++ b/extensions/vscode/webviews/homeView/src/stores/home.ts @@ -15,7 +15,7 @@ import { isConfigurationError } from "../../../../src/api/types/configurations"; import { WebviewToHostMessageType } from "../../../../src/types/messages/webviewToHostMessages"; import { RPackage } from "../../../../src/api/types/packages"; import { DeploymentSelector } from "../../../../src/types/shared"; -import { splitFilesOnInclusion } from "src/utils/files"; +import { flattenFiles, splitFilesOnInclusion } from "src/utils/files"; import { isAgentErrorInvalidTOML, isAgentErrorTypeUnknown, @@ -138,6 +138,8 @@ export const useHomeStore = defineStore("home", () => { const files = ref(); + const ultraFlatFiles = computed(() => flattenFiles(files.value?.files || [])); + const flatFiles = computed(() => { const response: { includedFiles: ContentRecordFile[]; @@ -424,6 +426,7 @@ export const useHomeStore = defineStore("home", () => { selectedConfiguration, serverCredential, files, + ultraFlatFiles, flatFiles, initializingRequestComplete, lastContentRecordResult, diff --git a/extensions/vscode/webviews/homeView/src/utils/files.ts b/extensions/vscode/webviews/homeView/src/utils/files.ts index 6e215bc04..2a9d0163e 100644 --- a/extensions/vscode/webviews/homeView/src/utils/files.ts +++ b/extensions/vscode/webviews/homeView/src/utils/files.ts @@ -35,3 +35,28 @@ export function canFileBeIncluded(file: ContentRecordFile): boolean { export function canFileBeExcluded(file: ContentRecordFile): boolean { return Boolean(!file.reason?.exclude); } + +export type FlatFile = Omit & { + indent: number; + parent?: string; +}; + +export function flattenFiles( + files: ContentRecordFile[], + map = new Map(), + indent = 0, + parentFile?: string, +): Map { + files.forEach((file) => { + const { files, ...rest } = file; + const flatFile = { + ...rest, + indent: indent, + parent: parentFile, + }; + map.set(file.id, flatFile); + flattenFiles(file.files, map, indent + 1, file.id); + }); + + return map; +} From 5d2e0bb8380d9c756101ac1f669af3a5b7fb3a89 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 21 Nov 2024 14:08:59 -0800 Subject: [PATCH 02/19] Update tooltip functions to use minimal types --- .../src/components/views/projectFiles/tooltips.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts index 1b63c7c88..5f11d8050 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts @@ -1,6 +1,8 @@ import { ContentRecordFile, FileMatchSource } from "../../../../../../src/api"; -export function includedFileTooltip(file: ContentRecordFile) { +export function includedFileTooltip( + file: Pick, +) { let tooltip = `${file.rel} will be included in the next deployment.`; if (file.reason) { tooltip += `\nThe configuration file ${file.reason?.fileName} is including it with the pattern '${file.reason?.pattern}'`; @@ -8,7 +10,9 @@ export function includedFileTooltip(file: ContentRecordFile) { return tooltip; } -export function excludedFileTooltip(file: ContentRecordFile) { +export function excludedFileTooltip( + file: Pick, +) { let tooltip = `${file.rel} will be excluded in the next deployment.`; if (file.reason) { if (file.reason.source === FileMatchSource.BUILT_IN) { From 183fa6ef988b6ec7a64a9ee3d9b015804792d2b4 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 21 Nov 2024 14:09:15 -0800 Subject: [PATCH 03/19] Make TreeProjectFiles take flat file map --- .../views/projectFiles/TreeProjectFiles.vue | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/TreeProjectFiles.vue b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/TreeProjectFiles.vue index ba58a6230..06fe01849 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/TreeProjectFiles.vue +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/TreeProjectFiles.vue @@ -1,7 +1,7 @@