From a1da5ba8bc34a2fd35ad4930da19fbfd213ffe75 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Tue, 30 May 2023 15:28:29 +0200 Subject: [PATCH] show added/removed status in sessions list --- src/lib/components/Stats.svelte | 23 ++++++++++ src/lib/components/index.ts | 1 + .../[projectId]/QuickCommitModal.svelte | 23 ++-------- .../[projectId]/player/[date]/+layout.svelte | 5 +++ .../player/[date]/SessionCard.svelte | 43 ++++++++++++++++++- .../player/[date]/SessionsList.svelte | 16 ++++++- 6 files changed, 88 insertions(+), 23 deletions(-) create mode 100644 src/lib/components/Stats.svelte diff --git a/src/lib/components/Stats.svelte b/src/lib/components/Stats.svelte new file mode 100644 index 000000000..f1937fc0d --- /dev/null +++ b/src/lib/components/Stats.svelte @@ -0,0 +1,23 @@ + + +
+
+ +{added} + -{removed} +
+
+ {#each { length: diffStatAdded } as _} +
+ {/each} + {#each { length: diffStatRemoved } as _} +
+ {/each} +
+
diff --git a/src/lib/components/index.ts b/src/lib/components/index.ts index c4648f983..bbb697024 100644 --- a/src/lib/components/index.ts +++ b/src/lib/components/index.ts @@ -11,3 +11,4 @@ export { default as Differ } from './Differ'; export { default as DeltasViewer } from './DeltasViewer.svelte'; export { default as DiffContext } from './DiffContext.svelte'; export { default as Checkbox } from './Checkbox'; +export { default as Stats } from './Stats.svelte'; diff --git a/src/routes/projects/[projectId]/QuickCommitModal.svelte b/src/routes/projects/[projectId]/QuickCommitModal.svelte index 40eddc076..b4ae3b680 100644 --- a/src/routes/projects/[projectId]/QuickCommitModal.svelte +++ b/src/routes/projects/[projectId]/QuickCommitModal.svelte @@ -3,6 +3,7 @@ import { Status, type Project, git, type CloudApi, type User } from '$lib/api'; import { Button, Overlay, Link } from '$lib/components'; import { IconGitBranch, IconSparkle } from '$lib/icons'; + import { Stats } from '$lib/components'; export const show = () => modal.show(); @@ -29,7 +30,7 @@ }); }; - let [linesAdded, linesRemoved] = Object.values(diffs) + $: [linesAdded, linesRemoved] = Object.values(diffs) .map((diff) => { let added = 0; let removed = 0; @@ -50,10 +51,6 @@ }) .reduce((a, b) => [a[0] + b[0], a[1] + b[1]], [0, 0]); - let diffStatRatio = linesAdded / (linesAdded + linesRemoved); - let diffStatAdded = Math.floor(4 * diffStatRatio); - let diffStatRemoved = 4 - diffStatAdded; - const reset = () => { summary = ''; description = ''; @@ -180,22 +177,8 @@ href="/projects/{project.id}/commit/" > {Object.keys(statuses).length} files changed + - -
-
- +{linesAdded} - -{linesRemoved} -
-
- {#each { length: diffStatAdded } as _} -
- {/each} - {#each { length: diffStatRemoved } as _} -
- {/each} -
-
diff --git a/src/routes/projects/[projectId]/player/[date]/+layout.svelte b/src/routes/projects/[projectId]/player/[date]/+layout.svelte index faa6d1507..4aca5549e 100644 --- a/src/routes/projects/[projectId]/player/[date]/+layout.svelte +++ b/src/routes/projects/[projectId]/player/[date]/+layout.svelte @@ -31,6 +31,11 @@ Object.fromEntries( Object.entries(deltas).filter(([path]) => (filter ? path === filter : true)) ) + ), + files: derived(stores.files({ projectId, sessionId: session.id }), (files) => + Object.fromEntries( + Object.entries(files).filter(([path]) => (filter ? path === filter : true)) + ) ) })) ); diff --git a/src/routes/projects/[projectId]/player/[date]/SessionCard.svelte b/src/routes/projects/[projectId]/player/[date]/SessionCard.svelte index c933f6367..d6797a73a 100644 --- a/src/routes/projects/[projectId]/player/[date]/SessionCard.svelte +++ b/src/routes/projects/[projectId]/player/[date]/SessionCard.svelte @@ -1,16 +1,55 @@