From a844e3a50be209e020b431ebb0b9a20fb36ed612 Mon Sep 17 00:00:00 2001 From: Ian Donahue Date: Sun, 12 Mar 2023 15:48:44 +0100 Subject: [PATCH 1/3] --- src/routes/+page.svelte | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 4db6cd777..d59285c81 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -185,17 +185,16 @@
+ class="flex-grow-0 rounded-b-lg border-t border-zinc-600 bg-zinc-600 px-3 py-1 text-sm font-mono text-zinc-300"> {#if project.api}
-
syncing
+
Backed-up
{:else}
-
offline
+
Offline
{/if}
From 3cc3fda37a9db10ab4ba5186ec84cef4b23e2424 Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Mon, 13 Mar 2023 09:19:47 +0100 Subject: [PATCH 2/3] format --- src/lib/components/CommandPalette.svelte | 18 +++++++-------- src/lib/components/icons/ContactIcon.svelte | 2 +- src/lib/components/icons/ProjectIcon.svelte | 2 +- .../search/RenderedSearchResult.svelte | 2 +- src/lib/current_project.ts | 2 +- src/lib/paths.ts | 22 +++++++++---------- src/routes/+page.svelte | 3 ++- .../projects/[projectId]/+layout.svelte | 2 +- src/routes/projects/[projectId]/+page.svelte | 14 ++++++------ .../[projectId]/timeline/+page.svelte | 2 +- 10 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/lib/components/CommandPalette.svelte b/src/lib/components/CommandPalette.svelte index 7aa28b739..63e00f834 100644 --- a/src/lib/components/CommandPalette.svelte +++ b/src/lib/components/CommandPalette.svelte @@ -326,7 +326,7 @@ bind:this={palette} in:fade={{ duration: 100 }} out:fade={{ duration: 100 }} - class="mx-auto max-w-2xl transform divide-y divide-zinc-500 divide-opacity-20 overflow-hidden rounded-xl bg-zinc-900 shadow-2xl transition-all border border-zinc-700" + class="mx-auto max-w-2xl transform divide-y divide-zinc-500 divide-opacity-20 overflow-hidden rounded-xl border border-zinc-700 bg-zinc-900 shadow-2xl transition-all" style=" border-width: 0.5px; -webkit-backdrop-filter: blur(20px) saturate(190%) contrast(70%) brightness(80%); @@ -366,7 +366,7 @@
    {#each menuItems as item} {#if item.type == 'divider'} -
  • +
  • {:else}
  • {item.text} {#if item.key} {item.key} @@ -403,16 +403,16 @@ in:fade={{ duration: 100 }} out:fade={{ duration: 100 }} bind:this={commitPalette} - class="mx-auto max-w-2xl transform overflow-hidden rounded-xl bg-zinc-900 shadow-2xl transition-all border border-zinc-700" + class="mx-auto max-w-2xl transform overflow-hidden rounded-xl border border-zinc-700 bg-zinc-900 shadow-2xl transition-all" style=" border-width: 0.5px; border: 0.5px solid rgba(63, 63, 70, 0.50);" > -
    +
    Commit Your Changes
    {#if Object.entries(changedFiles).length > 0}
    @@ -428,7 +428,7 @@ id="commit-message" bind:this={commitMessageInput} bind:value={commitMessage} - class="block w-full rounded-md p-4 border-0 text-zinc-200 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:py-1.5 sm:text-sm sm:leading-6" + class="block w-full rounded-md border-0 p-4 text-zinc-200 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-blue-600 sm:py-1.5 sm:text-sm sm:leading-6" />
    @@ -442,7 +442,7 @@ >Commit Your Changes
    -
    +
    @@ -461,7 +461,7 @@ {/each}
    {:else} -
    No changes to commit
    +
    No changes to commit
    {/if}
diff --git a/src/lib/components/icons/ContactIcon.svelte b/src/lib/components/icons/ContactIcon.svelte index bdba7d036..0853b5519 100644 --- a/src/lib/components/icons/ContactIcon.svelte +++ b/src/lib/components/icons/ContactIcon.svelte @@ -4,7 +4,7 @@ viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" - class="w-6 h-6" + class="h-6 w-6" > {formatDistanceToNow(processedResult.timestamp)} ago

-
+
{#each processedResult.hunks as hunk, i} {#if i > 0}
diff --git a/src/lib/current_project.ts b/src/lib/current_project.ts index 10024dc0e..e415f67b6 100644 --- a/src/lib/current_project.ts +++ b/src/lib/current_project.ts @@ -1,4 +1,4 @@ import { writable } from 'svelte/store'; import type { Project } from '$lib/projects'; -export const currentProject = writable(undefined); \ No newline at end of file +export const currentProject = writable(undefined); diff --git a/src/lib/paths.ts b/src/lib/paths.ts index 217ebbbf9..a12f33869 100644 --- a/src/lib/paths.ts +++ b/src/lib/paths.ts @@ -1,12 +1,12 @@ export function shortPath(path: string, max = 3) { - if (path.length < 30) { - return path; - } - const pathParts = path.split('/'); - const file = pathParts.pop(); - if (pathParts.length > 0) { - const pp = pathParts.map((p) => p.slice(0, max)).join('/'); - return `${pp}/${file}`; - } - return file; -} \ No newline at end of file + if (path.length < 30) { + return path; + } + const pathParts = path.split('/'); + const file = pathParts.pop(); + if (pathParts.length > 0) { + const pp = pathParts.map((p) => p.slice(0, max)).join('/'); + return `${pp}/${file}`; + } + return file; +} diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 348b8de5d..a1c44f872 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -188,7 +188,8 @@
+ class="flex-grow-0 rounded-b-lg border-t border-zinc-600 bg-zinc-600 px-3 py-1 font-mono text-sm text-zinc-300" + > {#if project.api}
diff --git a/src/routes/projects/[projectId]/+layout.svelte b/src/routes/projects/[projectId]/+layout.svelte index 84a46cc8e..5609a9194 100644 --- a/src/routes/projects/[projectId]/+layout.svelte +++ b/src/routes/projects/[projectId]/+layout.svelte @@ -126,7 +126,7 @@
Open in GitButler Cloud
-
+
Project
-
+

Recent File Changes

{#if $dateSessions === undefined} -
Loading...
+
Loading...
{:else}
{#each Object.entries(fileSessions) as filetime}
@@ -162,9 +162,9 @@

Work in Progress

{#if $filesStatus.length == 0}
-
+
-
-
+
+
{new Date(activity.timestampMs).toLocaleDateString('en-us', { weekday: 'short', diff --git a/src/routes/projects/[projectId]/timeline/+page.svelte b/src/routes/projects/[projectId]/timeline/+page.svelte index a148392e7..310ff913a 100644 --- a/src/routes/projects/[projectId]/timeline/+page.svelte +++ b/src/routes/projects/[projectId]/timeline/+page.svelte @@ -154,7 +154,7 @@
Date: Mon, 13 Mar 2023 10:37:14 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=94=A8=20Refactor:=20Recent=20Activit?= =?UTF-8?q?y=20&=20Files=20Status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add recent activity to the project page - Sort recent activity by timestamp - Limit recent activity to 20 elements [src/routes/projects/[projectId]/+page.svelte] - Add a `recentActivity` variable to store the recent activity - Convert a list of timestamps to a sparkline - Limit the number of sparkline elements to 3 - Iterate over the `dateSessions` to get the recent activity - Sort the recent activity by timestamp - Limit the recent activity to 20 elements - Update the template to use the `recentActivity` variable [src/routes/projects/[projectId]/+layout.ts] - Add `Activity` type from `$lib/sessions` - Add `recentActivity` derived from `sessions` - Sort `sessions` by `startTimestampMs` - Sort `recentActivity` by `timestampMs` - Limit `recentActivity` to the first `20` items - Add `filesStatus` to the return object --- src/routes/projects/[projectId]/+layout.ts | 16 +++++++++++++- src/routes/projects/[projectId]/+page.svelte | 22 ++------------------ 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/routes/projects/[projectId]/+layout.ts b/src/routes/projects/[projectId]/+layout.ts index 257a7440d..7b06cbeea 100644 --- a/src/routes/projects/[projectId]/+layout.ts +++ b/src/routes/projects/[projectId]/+layout.ts @@ -7,6 +7,7 @@ import type { Status } from '$lib/statuses'; import { asyncDerived } from '@square/svelte-store'; import type { Delta } from '$lib/deltas'; import { startOfDay } from 'date-fns'; +import type { Activity } from '$lib/sessions'; export const prerender = false; export const load: LayoutLoad = async ({ parent, params }) => { @@ -22,6 +23,18 @@ export const load: LayoutLoad = async ({ parent, params }) => { const orderedSessions = derived(sessions, (sessions) => { return sessions.slice().sort((a, b) => a.meta.startTimestampMs - b.meta.startTimestampMs); }); + const recentActivity = derived(sessions, (sessions) => { + const recentActivity: Activity[] = []; + sessions.forEach((session) => { + session.activity.forEach((activity) => { + recentActivity.push(activity); + }); + }); + const activitySorted = recentActivity.sort((a, b) => { + return b.timestampMs - a.timestampMs; + }); + return activitySorted.slice(0, 20); + }); let dateSessions = readable>({}); if (!building) { @@ -80,6 +93,7 @@ export const load: LayoutLoad = async ({ parent, params }) => { projectId: params.projectId, sessions: orderedSessions, dateSessions: dateSessions, - filesStatus: filesStatus + filesStatus: filesStatus, + recentActivity: recentActivity }; }; diff --git a/src/routes/projects/[projectId]/+page.svelte b/src/routes/projects/[projectId]/+page.svelte index aa935b47c..32df854bc 100644 --- a/src/routes/projects/[projectId]/+page.svelte +++ b/src/routes/projects/[projectId]/+page.svelte @@ -10,6 +10,7 @@ $: project = data.project; $: dateSessions = data.dateSessions as Readable>; $: filesStatus = data.filesStatus; + $: recentActivity = data.recentActivity as Readable; // convert a list of timestamps to a sparkline function timestampsToSpark(tsArray: number[]) { @@ -85,25 +86,6 @@ }) .slice(0, 3); } - - function recentActivity(dateSessions: Record) { - let recentActivity: Activity[] = []; - if (dateSessions) { - Object.entries(dateSessions).forEach(([date, sessions]) => { - sessions.forEach((session: UISession) => { - if (session.session) { - session.session.activity.forEach((activity) => { - recentActivity.push(activity); - }); - } - }); - }); - } - let activitySorted = recentActivity.sort((a, b) => { - return b.timestampMs - a.timestampMs; - }); - return activitySorted.slice(0, 20); - }
@@ -193,7 +175,7 @@ style="height: calc(100vh - 110px); overflow-y: auto;" >

Recent Activity

- {#each recentActivity($dateSessions) as activity} + {#each $recentActivity as activity}