From fd50eebbb73c321bfae5127aa1b7cbdd0fb0b520 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Thu, 12 Dec 2024 15:42:54 -0800 Subject: [PATCH 1/3] Disable entrypoint checkbox in Project Files view --- .../homeView/src/components/tree/TreeItemCheckbox.vue | 3 +++ .../src/components/views/projectFiles/ProjectFile.vue | 7 ++++++- extensions/vscode/webviews/homeView/src/style.css | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/webviews/homeView/src/components/tree/TreeItemCheckbox.vue b/extensions/vscode/webviews/homeView/src/components/tree/TreeItemCheckbox.vue index f402662c4..27ab07eb0 100644 --- a/extensions/vscode/webviews/homeView/src/components/tree/TreeItemCheckbox.vue +++ b/extensions/vscode/webviews/homeView/src/components/tree/TreeItemCheckbox.vue @@ -35,6 +35,7 @@ :checked="checked" :disabled="disabled" class="tree-item-checkbox" + :class="{ 'opacity-100': disableOpacity }" @click="checked ? $emit('uncheck') : $emit('check')" > {{ title }} @@ -77,6 +78,7 @@ interface Props { indentLevel?: number; expandable?: boolean; virtualized?: boolean; + disableOpacity?: boolean; } const props = withDefaults(defineProps(), { @@ -84,6 +86,7 @@ const props = withDefaults(defineProps(), { indentLevel: 1, expandable: false, virtualized: false, + disableOpacity: false, }); const slots = defineSlots<{ diff --git a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue index 9fe33a31c..035780899 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue @@ -4,6 +4,7 @@ :checked="isIncluded" :disabled="isDisabled" :list-style="listStyle" + :disable-opacity="isEntrypoint" :indent-level="file.indent + 1" :expandable="file.isDir" :tooltip="tooltip" @@ -57,7 +58,11 @@ const fileStore = useFileStore(); const isDisabled = computed((): boolean => { const source = props.file.reason?.source; - return source === "built-in" || source === "permissions"; + return ( + (isEntrypoint.value && isIncluded.value) || + source === "built-in" || + source === "permissions" + ); }); const isIncluded = computed((): boolean => { diff --git a/extensions/vscode/webviews/homeView/src/style.css b/extensions/vscode/webviews/homeView/src/style.css index 263b7798a..41c09be43 100644 --- a/extensions/vscode/webviews/homeView/src/style.css +++ b/extensions/vscode/webviews/homeView/src/style.css @@ -85,3 +85,7 @@ body { .text-git-conflicting { color: var(--vscode-gitDecoration-conflictingResourceForeground); } + +.opacity-100 { + opacity: 1; +} From 23230eb492406ac8ee4b188553c79f4d241dbf13 Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Fri, 20 Dec 2024 16:00:11 -0800 Subject: [PATCH 2/3] Add tooltip explaining entrypoint disable state --- .../src/components/views/projectFiles/ProjectFile.vue | 2 +- .../homeView/src/components/views/projectFiles/tooltips.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue index 035780899..b88cff7bc 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/ProjectFile.vue @@ -99,7 +99,7 @@ const listStyle = computed((): "emphasized" | "default" | "deemphasized" => { const tooltip = computed((): string => { return isIncluded.value - ? includedFileTooltip(props.file) + ? includedFileTooltip(props.file, isEntrypoint.value) : excludedFileTooltip(props.file); }); 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 5f11d8050..db757bec8 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts @@ -2,11 +2,15 @@ import { ContentRecordFile, FileMatchSource } from "../../../../../../src/api"; export function includedFileTooltip( file: Pick, + isEntrypoint: boolean = false, ) { 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}'`; } + if (isEntrypoint) { + tooltip += `\n${file.rel} is the entrypoint. Entrypoints must be included in the configuration 'files' list.`; + } return tooltip; } From 976e62b0f3d3890069b32b6ec0521b9735b1dfee Mon Sep 17 00:00:00 2001 From: Jordan Jensen Date: Fri, 20 Dec 2024 16:15:43 -0800 Subject: [PATCH 3/3] Add unit tests for file tooltips --- .../views/projectFiles/tooltips.test.ts | 99 +++++++++++++++++++ .../components/views/projectFiles/tooltips.ts | 5 +- .../vscode/webviews/homeView/vite.config.ts | 8 +- 3 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.test.ts diff --git a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.test.ts b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.test.ts new file mode 100644 index 000000000..aacc95ad9 --- /dev/null +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.test.ts @@ -0,0 +1,99 @@ +import { describe, it, expect } from "vitest"; +import { includedFileTooltip, excludedFileTooltip } from "./tooltips"; +import { FileMatchSource } from "../../../../../../src/api/types/files"; + +describe("includedFileTooltip", () => { + it("should return correct tooltip for included file without reason", () => { + const file = { rel: "src/index.ts", reason: null }; + const tooltip = includedFileTooltip(file); + expect(tooltip).toBe( + "src/index.ts will be included in the next deployment.", + ); + }); + + it("should return correct tooltip for included file with reason", () => { + const file = { + rel: "src/config.json", + reason: { + fileName: "config.json", + pattern: "*.json", + source: FileMatchSource.FILE, + filePath: "src/config.json", + exclude: false, + }, + }; + const tooltip = includedFileTooltip(file); + expect(tooltip).toBe( + `src/config.json will be included in the next deployment.\nThe configuration file config.json is including it with the pattern '*.json'`, + ); + }); + + it("should return correct tooltip for entrypoint file", () => { + const file = { rel: "src/index.ts", reason: null }; + const tooltip = includedFileTooltip(file, true); + expect(tooltip).toBe( + `src/index.ts will be included in the next deployment.\nsrc/index.ts is the entrypoint. Entrypoints must be included in the configuration 'files' list.`, + ); + }); +}); + +describe("excludedFileTooltip", () => { + it("should return correct tooltip for excluded file without reason", () => { + const file = { rel: "src/index.ts", reason: null }; + const tooltip = excludedFileTooltip(file); + expect(tooltip).toBe( + `src/index.ts will be excluded in the next deployment.\nIt did not match any pattern in the configuration 'files' list.`, + ); + }); + + it("should return correct tooltip for excluded file with built-in reason", () => { + const file = { + rel: "src/index.ts", + reason: { + source: FileMatchSource.BUILT_IN, + pattern: "*.ts", + fileName: "config.json", + filePath: "src/index.ts", + exclude: true, + }, + }; + const tooltip = excludedFileTooltip(file); + expect(tooltip).toBe( + `src/index.ts will be excluded in the next deployment.\nThis is a built-in exclusion for the pattern: '*.ts' and cannot be overridden.`, + ); + }); + + it("should return correct tooltip for excluded file with permissions error", () => { + const file = { + rel: "src/index.ts", + reason: { + source: FileMatchSource.PERMISSIONS_ERROR, + pattern: "", + fileName: "", + filePath: "", + exclude: true, + }, + }; + const tooltip = excludedFileTooltip(file); + expect(tooltip).toBe( + `src/index.ts will be excluded in the next deployment.\nYou don't have permission to access this directory.`, + ); + }); + + it("should return correct tooltip for excluded file with custom reason", () => { + const file = { + rel: "src/index.ts", + reason: { + fileName: "config.json", + pattern: "*.ts", + source: FileMatchSource.FILE, + filePath: "src/index.ts", + exclude: true, + }, + }; + const tooltip = excludedFileTooltip(file); + expect(tooltip).toBe( + `src/index.ts will be excluded in the next deployment.\nThe configuration file config.json is excluding it with the pattern '*.ts'`, + ); + }); +}); 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 db757bec8..2475eea78 100644 --- a/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts +++ b/extensions/vscode/webviews/homeView/src/components/views/projectFiles/tooltips.ts @@ -1,4 +1,7 @@ -import { ContentRecordFile, FileMatchSource } from "../../../../../../src/api"; +import { + ContentRecordFile, + FileMatchSource, +} from "../../../../../../src/api/types/files"; export function includedFileTooltip( file: Pick, diff --git a/extensions/vscode/webviews/homeView/vite.config.ts b/extensions/vscode/webviews/homeView/vite.config.ts index 6b98ad033..54c4dceb3 100644 --- a/extensions/vscode/webviews/homeView/vite.config.ts +++ b/extensions/vscode/webviews/homeView/vite.config.ts @@ -40,10 +40,10 @@ export default defineConfig({ coverage: { enabled: true, thresholds: { - functions: 27.77, - lines: 16.06, - branches: 37.97, - statements: 16.06, + functions: 30.13, + lines: 17.48, + branches: 44.82, + statements: 17.48, autoUpdate: true, }, },