From 698d871711899fc58c48c1a6af12c405f79caca8 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 3 Oct 2024 11:04:32 +0200 Subject: [PATCH 1/9] simplify dumb styles, exercise new apis style changes --- apps/web/src/lib/components/Navigation.svelte | 13 +- apps/web/src/lib/styles/global.css | 7 - apps/web/src/routes/+layout.svelte | 18 -- .../routes/projects/[projectId]/+page.svelte | 2 +- .../branches/[branchId]/stack/+page.svelte | 8 +- .../[branchId]/stack/[changeId]/+page.svelte | 283 +++++++++++++++--- 6 files changed, 251 insertions(+), 80 deletions(-) diff --git a/apps/web/src/lib/components/Navigation.svelte b/apps/web/src/lib/components/Navigation.svelte index 9e5757e14e..1110628825 100644 --- a/apps/web/src/lib/components/Navigation.svelte +++ b/apps/web/src/lib/components/Navigation.svelte @@ -19,8 +19,8 @@
- github -

GitButler

+ gitbutler +
GitButler
Downloads @@ -45,13 +45,18 @@ diff --git a/apps/web/src/routes/projects/[projectId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/+page.svelte index 9ff60573ea..670e7e3666 100644 --- a/apps/web/src/routes/projects/[projectId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/+page.svelte @@ -94,7 +94,7 @@
{project.name}
-

Patch Stacks

+

Patch Stacks

{#each patchStacks as stack}
{stack.title}
diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte index 58a7585f0e..2a070cfb8b 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte @@ -48,7 +48,7 @@ {:else} -

Patch Stack

+

Patch Stack

Title: {stackData.title}
@@ -91,6 +91,10 @@ Additions: {patch.statistics.lines - patch.statistics.deletions}, Deletions: {patch .statistics.deletions}, Files: {patch.statistics.file_count}
+
+
Viewed: {patch.review.viewed}
+
Signed Off:{patch.review.signed_off}
+
Rejected: {patch.review.rejected}
{/each} @@ -113,7 +117,7 @@ margin: 4px 0; } .patch { - background-color: #fff; + background-color: var(--clr-bg-1-muted); border: 1px solid #ccc; padding: 15px 20px; margin: 10px 0; diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte index a8f0359f64..babca9ba1a 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte @@ -7,6 +7,8 @@ let state = 'loading'; let patch: any = {}; let stack: any = {}; + let status: any = {}; + let chats: any = []; let key: any = ''; let uuid: any = ''; @@ -18,6 +20,8 @@ let branchId = data.branchId; let changeId = data.changeId; + // scroll chatWindow to bottom + if (key) { fetch(env.PUBLIC_APP_HOST + 'api/patch_stack/' + projectId + '/' + branchId, { method: 'GET', @@ -31,12 +35,21 @@ stack = data; uuid = data.uuid; fetchPatch(data.uuid, changeId, key); + getPatchStatus(); + fetchAndUpdateChat(); }); } else { state = 'unauthorized'; } }); + function scrollToBottom() { + let chatWindow = document.querySelector('.chatWindow'); + if (chatWindow) { + chatWindow.scrollTop = chatWindow.scrollHeight; + } + } + function fetchPatch(uuid: string, changeId: string, key: string) { fetch(env.PUBLIC_APP_HOST + 'api/patch_stack/' + uuid + '/patch/' + changeId, { method: 'GET', @@ -144,6 +157,7 @@ }); } } + function moveSection(position: number, change: number) { console.log('Moving section at position', position, 'by', change); let ids = patch.sections.map((section: any) => section.identifier); @@ -209,11 +223,106 @@ } } } + function updatePatch() { setTimeout(() => { fetchPatch(uuid, data.changeId, key); }, 500); } + + function getPatchStatus() { + //GET /api/patch_stack/:project_id/:branch_id/patch_status + fetch( + env.PUBLIC_APP_HOST + + 'api/patch_stack/' + + data.projectId + + '/' + + data.branchId + + '/patch_status', + { + method: 'GET', + headers: { + 'X-AUTH-TOKEN': key || '' + } + } + ) + .then(async (response) => await response.json()) + .then((data) => { + status = data; + console.log('patch status'); + console.log(data); + }); + } + + function fetchAndUpdateChat() { + fetch(env.PUBLIC_APP_HOST + 'api/chat_messages/' + data.projectId + '/chats/' + data.changeId, { + method: 'GET', + headers: { + 'X-AUTH-TOKEN': key || '' + } + }) + .then(async (response) => await response.json()) + .then((data) => { + console.log(data); + setTimeout(() => { + chats = data; + setTimeout(() => { + scrollToBottom(); + }, 150); // I don't know how to DOM in Svelte, but it takes a second + }, 50); // I don't know how to DOM in Svelte, but it takes a second + }); + } + + function createChatMessage() { + let chatBox = document.querySelector('.chatBox'); + if (chatBox) { + let text = chatBox.querySelector('textarea')!.value; + let opts = { + method: 'POST', + headers: { + 'X-AUTH-TOKEN': key || '', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + chat: text, + change_id: data.changeId + }) + }; + if (key) { + fetch( + env.PUBLIC_APP_HOST + 'api/chat_messages/' + data.projectId + '/branch/' + data.branchId, + opts + ) + .then(async (response) => await response.json()) + .then((data) => { + chatBox.querySelector('textarea')!.value = ''; + fetchAndUpdateChat(); + console.log(data); + }); + } + } + } + + function signOff(signoff: boolean) { + let opts = { + method: 'PATCH', + headers: { + 'X-AUTH-TOKEN': key || '', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + sign_off: signoff + }) + }; + if (key) { + fetch(env.PUBLIC_APP_HOST + 'api/patch_stack/' + uuid + '/patch/' + data.changeId, opts) + .then(async (response) => await response.json()) + .then((data) => { + console.log('sign off', data); + getPatchStatus(); + }); + } + } {#if state === 'loading'} @@ -221,58 +330,63 @@ {:else if state === 'unauthorized'}

Unauthorized

{:else} -

Patch Stack: {stack.title}

- {#each stack.patches as stackPatch} -
- {stackPatch.change_id.substr(0, 8)}: - {#if patch.change_id === stackPatch.change_id} - {stackPatch.title} - {:else} - {stackPatch.title} - {/if} -
- {/each} -
- -

Patch

-
Title: {patch.title}
- {#if patch.description} -
Desc: {patch.description}
- {/if} -
Change Id: {patch.change_id}
-
Commit: {patch.commit_sha}
-
-
-
Patch Version: {patch.version}
-
Stack Position: {patch.position + 1}/{stack.stack_size}
-
Contributors: {patch.contributors}
-
- Additions: {patch.statistics.lines - patch.statistics.deletions}, Deletions: {patch - .statistics.deletions}, Files: {patch.statistics.file_count} -
-
-
- -
-
-

Outline

-
- {#each patch.sections as section} - {#if section.section_type === 'diff'} - +

Patch Series: {stack.title}

+ {#each stack.patches as stackPatch} +
+ {stackPatch.change_id.substr(0, 8)}: + {#if patch.change_id === stackPatch.change_id} + {stackPatch.title} {:else} - + {stackPatch.title} {/if} - {/each} +
+ {/each} +
+ +

Patch

+
+
+
Title: {patch.title}
+ {#if patch.description} +
Desc: {patch.description}
+ {/if} +
Change Id: {patch.change_id.substr(0, 13)}
+
Commit SHA: {patch.commit_sha.substr(0, 10)}
+
Patch Version: {patch.version}
+
Series Position: {patch.position + 1}/{stack.stack_size}
+
Contributors: {patch.contributors}
+
Review:
+
Viewed: {patch.review.viewed}
+
Signed Off: {patch.review.signed_off}
+
Rejected: {patch.review.rejected}
+
+ Additions: {patch.statistics.lines - patch.statistics.deletions}, Deletions: {patch + .statistics.deletions}, Files: {patch.statistics.file_count} +
+
+
+

Sign off

+ {#if status[data.changeId]} +
Last View: {status[data.changeId].last_viewed}
+
Last Review: {status[data.changeId].last_reviewed}
+
Last Signoff: {status[data.changeId].last_signoff}
+ {/if} +
+ + +
+
-
-
+ +
+
{#each patch.sections as section}
@@ -289,7 +403,7 @@
{section.new_path}
-
{section.diff_patch}
+
{section.diff_patch}
{:else}
@@ -316,6 +430,26 @@
+
+

Chat

+
+ {#each chats as chat} +
+
+
{chat.user.email}
+
{chat.created_at}
+
+
{chat.comment}
+
+ {/each} +
+
+
+ + +
+
+
{/if} From 7c86840e61800643e2f5afa555616c6a2d31ed60 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 3 Oct 2024 11:18:43 +0200 Subject: [PATCH 2/9] patch clicks reload the page --- .../branches/[branchId]/stack/[changeId]/+page.svelte | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte index babca9ba1a..9969491f33 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte @@ -337,6 +337,7 @@
{stackPatch.change_id.substr(0, 8)} Date: Thu, 3 Oct 2024 11:43:51 +0200 Subject: [PATCH 3/9] also set localstorage for now not sure how to get the other thing to work --- apps/web/src/routes/+layout.svelte | 1 + .../branches/[branchId]/stack/[changeId]/+page.svelte | 2 ++ 2 files changed, 3 insertions(+) diff --git a/apps/web/src/routes/+layout.svelte b/apps/web/src/routes/+layout.svelte index 9b33536e51..be50284023 100644 --- a/apps/web/src/routes/+layout.svelte +++ b/apps/web/src/routes/+layout.svelte @@ -21,6 +21,7 @@ const token = $page.url.searchParams.get('gb_access_token'); if (token && token.length > 0) { $page.data.authService.setToken(token); + localStorage.setItem('gb_access_token', token); $page.url.searchParams.delete('gb_access_token'); goto(`?${$page.url.searchParams.toString()}`); diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte index 9969491f33..710bdb54d1 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte @@ -16,6 +16,8 @@ onMount(() => { key = localStorage.getItem('gb_access_token'); + console.log(key); + let projectId = data.projectId; let branchId = data.branchId; let changeId = data.changeId; From 200cfba9de50652c221346d5e993ef6c42424e3a Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Thu, 3 Oct 2024 17:50:28 +0200 Subject: [PATCH 4/9] can comment on diff ranges --- apps/web/package.json | 3 +- apps/web/src/lib/components/DiffPatch.svelte | 304 ++++++++++++++++++ .../src/lib/components/DiffPatchArray.svelte | 46 +++ .../branches/[branchId]/stack/+page.svelte | 49 ++- .../[branchId]/stack/[changeId]/+page.svelte | 171 ++++++++-- pnpm-lock.yaml | 87 +++-- 6 files changed, 605 insertions(+), 55 deletions(-) create mode 100644 apps/web/src/lib/components/DiffPatch.svelte create mode 100644 apps/web/src/lib/components/DiffPatchArray.svelte diff --git a/apps/web/package.json b/apps/web/package.json index 958f0d540d..350483e427 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -26,6 +26,7 @@ "@sentry/sveltekit": "^8.9.2", "highlight.js": "^11.10.0", "marked": "^10.0.0", - "moment": "^2.30.1" + "moment": "^2.30.1", + "svelte-gravatar": "^1.0.3" } } diff --git a/apps/web/src/lib/components/DiffPatch.svelte b/apps/web/src/lib/components/DiffPatch.svelte new file mode 100644 index 0000000000..11f08a29b6 --- /dev/null +++ b/apps/web/src/lib/components/DiffPatch.svelte @@ -0,0 +1,304 @@ + + +
+ +
+ {#each parsedLines as line} + {#if line.type !== 'header'} + + +
handleLineNumberClick(line, event)} + > + {line.leftLineNumber !== null ? line.leftLineNumber : ' '} +
+ {/if} + {/each} +
+ +
+ {#each parsedLines as line} + {#if line.type !== 'header'} + + +
handleLineNumberClick(line, event)} + > + {line.rightLineNumber !== null ? line.rightLineNumber : ' '} +
+ {/if} + {/each} +
+ + +
+ {#each parsedLines as line} + {#if line.type !== 'header'} +
+ ͏{line.content} +
+ {/if} + {/each} +
+
+ + diff --git a/apps/web/src/lib/components/DiffPatchArray.svelte b/apps/web/src/lib/components/DiffPatchArray.svelte new file mode 100644 index 0000000000..94b1f6d291 --- /dev/null +++ b/apps/web/src/lib/components/DiffPatchArray.svelte @@ -0,0 +1,46 @@ + + +
+
+ {#each diffArray as line} +
{line.right}
+ {/each} +
+
+ {#each diffArray as line} +
{line.line}
+ {/each} +
+
+ + diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte index 2a070cfb8b..ed4a536730 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte @@ -1,7 +1,9 @@ {#if state === 'loading'} @@ -333,7 +355,7 @@

Unauthorized

{:else}
-
+

Patch Series: {stack.title}

{#each stack.patches as stackPatch}
@@ -364,26 +386,63 @@
Commit SHA: {patch.commit_sha.substr(0, 10)}
Patch Version: {patch.version}
Series Position: {patch.position + 1}/{stack.stack_size}
-
Contributors: {patch.contributors}
-
Review:
-
Viewed: {patch.review.viewed}
-
Signed Off: {patch.review.signed_off}
-
Rejected: {patch.review.rejected}
+
+ Contributors: + {#each patch.contributors as email} + + {/each} +
Additions: {patch.statistics.lines - patch.statistics.deletions}, Deletions: {patch .statistics.deletions}, Files: {patch.statistics.file_count}
-

Sign off

+ {#if patch.review.viewed.length > 0} +
+
Viewed:
+ {#each patch.review.viewed as email} + + {/each} +
+ {/if} + + {#if patch.review.signed_off.length > 0} +
+
Signed Off:
+ {#each patch.review.signed_off as email} + + {/each} +
+ {/if} + + {#if patch.review.length > 0} +
+
Rejected:
+ {#each patch.review.rejected as email} + + {/each} +
+ {/if} + +

Your sign off status

{#if status[data.changeId]} -
Last View: {status[data.changeId].last_viewed}
-
Last Review: {status[data.changeId].last_reviewed}
-
Last Signoff: {status[data.changeId].last_signoff}
+ {#if status[data.changeId].last_signoff} +
You signed off on this patch
+ {/if} + {#if !status[data.changeId].last_reviewed} +
You have not reviewed this patch
+ {:else if !status[data.changeId].last_signoff} +
You have rejected this patch
+ {/if} {/if}
- - + {#if !status[data.changeId].last_signoff} + + {/if} + {#if status[data.changeId].last_signoff || !status[data.changeId].last_reviewed} + + {/if}
@@ -403,10 +462,18 @@ >down]
+
+ {section.new_path} +
- {section.new_path} + + rangeSelect(range, diff_path, diff_sha)} + diffPath={section.new_path} + diffSha={section.diff_sha} + diff={section.diff_patch} + />
-
{section.diff_patch}
{:else}
@@ -439,9 +506,18 @@ {#each chats as chat}
-
{chat.user.email}
+
+ +
{chat.created_at}
+ {#if chat.diff_patch_array} +
+
{chat.diff_path}
+ + +
+ {/if}
{chat.comment}
{/each} @@ -455,12 +531,12 @@
{/if} - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1ed1846ac..eb7641bcd3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,28 +4,6 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -catalogs: - default: - vite: - specifier: 5.2.13 - version: 5.2.13 - svelte: - '@sveltejs/adapter-static': - specifier: 3.0.4 - version: 3.0.4 - '@sveltejs/kit': - specifier: 2.5.25 - version: 2.5.25 - '@sveltejs/vite-plugin-svelte': - specifier: 4.0.0-next.6 - version: 4.0.0-next.6 - svelte: - specifier: 5.0.0-next.243 - version: 5.0.0-next.243 - svelte-check: - specifier: 4.0.1 - version: 4.0.1 - importers: .: @@ -307,6 +285,9 @@ importers: moment: specifier: ^2.30.1 version: 2.30.1 + svelte-gravatar: + specifier: ^1.0.3 + version: 1.0.3(svelte@5.0.0-next.243) devDependencies: '@fontsource/fira-mono': specifier: ^4.5.10 @@ -2525,6 +2506,9 @@ packages: chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + charenc@0.0.2: + resolution: {integrity: sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==} + check-error@2.1.1: resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} engines: {node: '>= 16'} @@ -2666,6 +2650,9 @@ packages: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} + crypt@0.0.2: + resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==} + css-shorthand-properties@1.1.1: resolution: {integrity: sha512-Md+Juc7M3uOdbAFwOYlTrccIZ7oCFuzrhKYQjdeUEW/sE1hv17Jp/Bws+ReOPpGVBTYCBoYo+G17V5Qo8QQ75A==} @@ -3752,6 +3739,9 @@ packages: resolution: {integrity: sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==} engines: {node: '>= 0.4'} + is-buffer@1.1.6: + resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} + is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} @@ -4164,6 +4154,9 @@ packages: engines: {node: '>= 18'} hasBin: true + md5@2.3.0: + resolution: {integrity: sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==} + media-typer@0.3.0: resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} engines: {node: '>= 0.6'} @@ -5312,6 +5305,11 @@ packages: peerDependencies: svelte: ^3.57.0 || ^4.0.0 + svelte-gravatar@1.0.3: + resolution: {integrity: sha512-CNxIV2lAuiqwdaPrGAM/BFj5U1dNNQXzeyh+HVi/48BODFXoDy0L1CMqYyvM+aKiF4ideZUBwT0S9/C1BeL5oA==} + peerDependencies: + svelte: '*' + svelte-preprocess@5.1.3: resolution: {integrity: sha512-xxAkmxGHT+J/GourS5mVJeOXZzne1FR5ljeOUAMXUkfEhkLEllRreXpbl3dIYJlcJRfL1LO1uIAPpBpBfiqGPw==} engines: {node: '>= 16.0.0', pnpm: ^8.0.0} @@ -5349,6 +5347,9 @@ packages: typescript: optional: true + svelte-waypoint@0.1.4: + resolution: {integrity: sha512-UEqoXZjJeKj2sWlAIsBOFjxjMn+KP8aFCc/zjdmZi1cCOE59z6T2C+I6ZaAf8EmNQqNzfZVB/Lci4Ci9spzXAw==} + svelte-writable-derived@3.1.0: resolution: {integrity: sha512-cTvaVFNIJ036vSDIyPxJYivKC7ZLtcFOPm1Iq6qWBDo1fOHzfk6ZSbwaKrxhjgy52Rbl5IHzRcWgos6Zqn9/rg==} peerDependencies: @@ -5975,6 +5976,28 @@ packages: resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==} engines: {node: '>= 14'} +catalogs: + default: + vite: + specifier: 5.2.13 + version: 5.2.13 + svelte: + '@sveltejs/adapter-static': + specifier: 3.0.4 + version: 3.0.4 + '@sveltejs/kit': + specifier: 2.5.25 + version: 2.5.25 + '@sveltejs/vite-plugin-svelte': + specifier: 4.0.0-next.6 + version: 4.0.0-next.6 + svelte: + specifier: 5.0.0-next.243 + version: 5.0.0-next.243 + svelte-check: + specifier: 4.0.1 + version: 4.0.1 + snapshots: '@aashutoshrathi/word-wrap@1.2.6': {} @@ -8639,6 +8662,8 @@ snapshots: chardet@0.7.0: {} + charenc@0.0.2: {} + check-error@2.1.1: {} chokidar@3.6.0: @@ -8782,6 +8807,8 @@ snapshots: shebang-command: 2.0.0 which: 2.0.2 + crypt@0.0.2: {} + css-shorthand-properties@1.1.1: {} css-value@0.0.1: {} @@ -10152,6 +10179,8 @@ snapshots: call-bind: 1.0.7 has-tostringtag: 1.0.2 + is-buffer@1.1.6: {} + is-callable@1.2.7: {} is-core-module@2.13.1: @@ -10531,6 +10560,12 @@ snapshots: marked@10.0.0: {} + md5@2.3.0: + dependencies: + charenc: 0.0.2 + crypt: 0.0.2 + is-buffer: 1.1.6 + media-typer@0.3.0: {} memoizerific@1.11.3: @@ -11738,6 +11773,12 @@ snapshots: svelte: 5.0.0-next.243 svelte-writable-derived: 3.1.0(svelte@5.0.0-next.243) + svelte-gravatar@1.0.3(svelte@5.0.0-next.243): + dependencies: + md5: 2.3.0 + svelte: 5.0.0-next.243 + svelte-waypoint: 0.1.4 + svelte-preprocess@5.1.3(@babel/core@7.24.7)(postcss-load-config@5.1.0(postcss@8.4.39))(postcss@8.4.39)(svelte@5.0.0-next.243)(typescript@5.4.5): dependencies: '@types/pug': 2.0.6 @@ -11752,6 +11793,8 @@ snapshots: postcss-load-config: 5.1.0(postcss@8.4.39) typescript: 5.4.5 + svelte-waypoint@0.1.4: {} + svelte-writable-derived@3.1.0(svelte@5.0.0-next.243): dependencies: svelte: 5.0.0-next.243 From bdcdf028a009febf1873f0003ed49de406496d65 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Fri, 4 Oct 2024 10:03:20 +0200 Subject: [PATCH 5/9] add ability to create issue comments and resovle --- .../[branchId]/stack/[changeId]/+page.svelte | 88 +++++++++++++++++-- 1 file changed, 82 insertions(+), 6 deletions(-) diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte index 1d1928c5cf..3049692ce9 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte @@ -277,6 +277,13 @@ function createChatMessage() { let chatBox = document.querySelector('.chatBox'); if (chatBox) { + // check if this is an issue + var checkbox = document.getElementById('issue'); + let is_issue = false; + if ((checkbox as HTMLInputElement).checked) { + is_issue = true; + } + let text = chatBox.querySelector('textarea')!.value; let params: { chat: string; @@ -284,16 +291,17 @@ range?: string; diff_path?: string; diff_sha?: string; + issue?: boolean; } = { chat: text, - change_id: data.changeId + change_id: data.changeId, + issue: is_issue }; if (commentRange.length > 0) { params.range = commentRange; params.diff_path = diffPath; params.diff_sha = diffSha; } - console.log('FUCKING POST', params); let opts = { method: 'POST', headers: { @@ -338,11 +346,35 @@ } } + function resolveIssue(uuid: string) { + //:project_id/chat/:chat_uuid + console.log('Resolving issue', uuid); + let opts = { + method: 'PATCH', + headers: { + 'X-AUTH-TOKEN': key || '', + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + resolved: true + }) + }; + if (key) { + fetch(env.PUBLIC_APP_HOST + 'api/chat_messages/' + data.projectId + '/chat/' + uuid, opts) + .then(async (response) => await response.json()) + .then((data) => { + console.log('resolved', data); + fetchAndUpdateChat(); + }); + } + } + let commentRange: string = ''; let diffPath: string = ''; let diffSha: string = ''; function rangeSelect(range: string, diff_path: string, diff_sha: string) { + console.log('range selected', range, diff_path, diff_sha); commentRange = range; diffPath = diff_path; diffSha = diff_sha; @@ -504,7 +536,7 @@

Chat

{#each chats as chat} -
+
@@ -519,13 +551,28 @@
{/if}
{chat.comment}
+ {#if chat.issue} + {#if chat.resolved} +
resolved
+ {:else} + + {/if} + {/if}
{/each}
- - +
+ +
+
+
+ +
issue
+
+ +
@@ -533,6 +580,27 @@ {/if} From 1aaf2029659170fb2538a393813a81de6abd9746 Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Fri, 4 Oct 2024 10:49:06 +0200 Subject: [PATCH 7/9] new review_all data --- .../branches/[branchId]/stack/+page.svelte | 73 ++++++++++++++----- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte index 54fe740cd7..d3fae94529 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/+page.svelte @@ -76,9 +76,9 @@

Patches

{#each stackData.patches as patch}
- {#if patch.review.rejected.length > 0} + {#if patch.review_all.rejected.length > 0}
X
- {:else if patch.review.signed_off.length > 0} + {:else if patch.review_all.signed_off.length > 0}
{:else}
?
@@ -104,23 +104,49 @@ .statistics.deletions}, Files: {patch.statistics.file_count}

-
- Viewed: - {#each patch.review.viewed as email} - - {/each} -
-
- Signed Off: - {#each patch.review.signed_off as email} - - {/each} -
-
- Rejected: - {#each patch.review.rejected as email} - - {/each} +
+
+

This Version

+
+
Viewed:
+ {#each patch.review.viewed as email} + + {/each} +
+
+
Signed Off:
+ {#each patch.review.signed_off as email} + + {/each} +
+
+
Rejected:
+ {#each patch.review.rejected as email} + + {/each} +
+
+
+

All Versions

+
+
Viewed:
+ {#each patch.review_all.viewed as email} + + {/each} +
+
+
Signed Off:
+ {#each patch.review_all.signed_off as email} + + {/each} +
+
+
Rejected:
+ {#each patch.review_all.rejected as email} + + {/each} +
+
@@ -135,6 +161,10 @@ h2 { font-size: 1.5rem; } + h3 { + font-size: 1.1rem; + font-weight: bold; + } .columns { display: flex; } @@ -169,4 +199,9 @@ background-color: rgb(215, 215, 144); color: black; } + .title { + min-width: 100px; + display: inline-block; + border-right: 1px solid #eee; + } From be491c6cb9e8c3f2963c4d8ab851286a11eccfca Mon Sep 17 00:00:00 2001 From: Scott Chacon Date: Fri, 4 Oct 2024 14:02:09 +0200 Subject: [PATCH 8/9] move chat rendering to patch_events --- .../[branchId]/stack/[changeId]/+page.svelte | 146 ++++++++++++++---- 1 file changed, 119 insertions(+), 27 deletions(-) diff --git a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte index 3049692ce9..8a7d2b3f78 100644 --- a/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte +++ b/apps/web/src/routes/projects/[projectId]/branches/[branchId]/stack/[changeId]/+page.svelte @@ -10,7 +10,7 @@ let patch: any = {}; let stack: any = {}; let status: any = {}; - let chats: any = []; + let events: any = []; let key: any = ''; let uuid: any = ''; @@ -256,7 +256,7 @@ } function fetchAndUpdateChat() { - fetch(env.PUBLIC_APP_HOST + 'api/chat_messages/' + data.projectId + '/chats/' + data.changeId, { + fetch(env.PUBLIC_APP_HOST + 'api/patch_events/' + data.projectId + '/patch/' + data.changeId, { method: 'GET', headers: { 'X-AUTH-TOKEN': key || '' @@ -266,7 +266,7 @@ .then((data) => { console.log(data); setTimeout(() => { - chats = data; + events = data; setTimeout(() => { scrollToBottom(); }, 150); // I don't know how to DOM in Svelte, but it takes a second @@ -342,6 +342,7 @@ .then((data) => { console.log('sign off', data); getPatchStatus(); + fetchAndUpdateChat(); }); } } @@ -469,11 +470,13 @@ {/if} {/if}
- {#if !status[data.changeId].last_signoff} - - {/if} - {#if status[data.changeId].last_signoff || !status[data.changeId].last_reviewed} - + {#if status[data.changeId]} + {#if !status[data.changeId].last_signoff} + + {/if} + {#if status[data.changeId].last_signoff || !status[data.changeId].last_reviewed} + + {/if} {/if}
@@ -535,30 +538,85 @@

Chat

- {#each chats as chat} -
-
-
- + {#each events as event} + {#if event.event_type === 'chat'} +
+
+
+ +
+
{event.object.created_at}
-
{chat.created_at}
+ {#if event.object.diff_patch_array} +
+
{event.object.diff_path}
+ + +
+ {/if} +
{event.object.comment}
+ {#if event.object.issue} + {#if event.object.resolved} +
resolved
+ {:else} + + {/if} + {/if}
- {#if chat.diff_patch_array} -
-
{chat.diff_path}
- - + {/if} + {#if event.event_type === 'issue_status'} + {#if event.data.resolution} +
+
+ {event.user.email} resolved issue {event.object.uuid.substr(0, 8)} +
+
+ {event.created_at} +
{/if} -
{chat.comment}
- {#if chat.issue} - {#if chat.resolved} -
resolved
- {:else} - - {/if} + {/if} + + {#if event.event_type === 'patch_status'} + {#if event.data.status} +
+
+ {event.user.email} + signed off +
+
+ {event.created_at} +
+
+ {:else} +
+
+ {event.user.email} + requested changes +
+
+ {event.created_at} +
+
{/if} -
+ {/if} + + {#if event.event_type === 'patch_version'} +
+
+ new patch version: v{event.object.version} +
+
+ {event.created_at} +
+
+ {/if} {/each}
@@ -580,6 +638,40 @@ {/if}