mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-24 05:29:51 +03:00
add file filter back
This commit is contained in:
parent
b19e1ebb76
commit
b9363aed1f
@ -7,7 +7,6 @@
|
|||||||
import { invoke } from '@tauri-apps/api';
|
import { invoke } from '@tauri-apps/api';
|
||||||
import { toHumanBranchName } from '$lib/branch';
|
import { toHumanBranchName } from '$lib/branch';
|
||||||
import { list as listDeltas } from '$lib/deltas';
|
import { list as listDeltas } from '$lib/deltas';
|
||||||
import { goto } from '$app/navigation';
|
|
||||||
const getBranch = (params: { projectId: string }) => invoke<string>('git_branch', params);
|
const getBranch = (params: { projectId: string }) => invoke<string>('git_branch', params);
|
||||||
|
|
||||||
export let data: LayoutData;
|
export let data: LayoutData;
|
||||||
@ -18,17 +17,14 @@
|
|||||||
|
|
||||||
let latestDeltasByDateByFile: Record<number, Record<string, Delta[][]>[]> = {};
|
let latestDeltasByDateByFile: Record<number, Record<string, Delta[][]>[]> = {};
|
||||||
|
|
||||||
function gotoPlayer(filename: string) {
|
function playerURL(ms: string, file?: string) {
|
||||||
if ($project) {
|
|
||||||
goto(`/projects/${$project.id}/player?file=${encodeURIComponent(filename)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function datePlayerURL(ms: string) {
|
|
||||||
let date = new Date(parseInt(ms));
|
let date = new Date(parseInt(ms));
|
||||||
let datePass = format(date, 'yyyy-MM-dd');
|
let datePass = format(date, 'yyyy-MM-dd');
|
||||||
|
|
||||||
if ($project) {
|
if ($project) {
|
||||||
|
if (file) {
|
||||||
|
return `/projects/${$project.id}/player/${datePass}?file=${encodeURIComponent(file)}`;
|
||||||
|
}
|
||||||
return `/projects/${$project.id}/player/${datePass}`;
|
return `/projects/${$project.id}/player/${datePass}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,7 +186,7 @@
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<a class="text-orange-200" href={datePlayerURL(dateMilliseconds)}
|
<a class="text-orange-200" href={playerURL(dateMilliseconds)}
|
||||||
>Replay Changes</a
|
>Replay Changes</a
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
@ -201,7 +197,7 @@
|
|||||||
{#each Object.entries(fileSessions) as filetime}
|
{#each Object.entries(fileSessions) as filetime}
|
||||||
<div class="flex flex-row justify-between">
|
<div class="flex flex-row justify-between">
|
||||||
<div class="w-96 truncate font-mono text-zinc-300">
|
<div class="w-96 truncate font-mono text-zinc-300">
|
||||||
<a class="cursor-pointer" on:click={gotoPlayer(filetime[0])}>
|
<a class="cursor-pointer" href={playerURL(dateMilliseconds, filetime[0])}>
|
||||||
{shortPath(filetime[0], 3, 70)}
|
{shortPath(filetime[0], 3, 70)}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
<div id="player-page" class="flex h-full w-full">
|
<div id="player-page" class="flex h-full w-full flex-col">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
const currentDate = derived(page, (page) => page.params.date);
|
const currentDate = derived(page, (page) => page.params.date);
|
||||||
|
|
||||||
|
const fileFilter = derived(page, (page) => page.url.searchParams.get('file'));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $sessions.length === 0}
|
{#if $sessions.length === 0}
|
||||||
@ -24,6 +26,14 @@
|
|||||||
<p class="text-gray-500">Go code something!</p>
|
<p class="text-gray-500">Go code something!</p>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
{#if $fileFilter}
|
||||||
|
<a
|
||||||
|
href="/projects/{$page.params.projectId}/player/{$page.params.date}/{$page.params.sessionId}"
|
||||||
|
class="w-full p-2 text-left font-mono text-lg"
|
||||||
|
>
|
||||||
|
{$fileFilter}
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
<div class="flex h-full w-full flex-row gap-2 p-2">
|
<div class="flex h-full w-full flex-row gap-2 p-2">
|
||||||
<ul id="days" class="flex h-full flex-shrink-0 flex-col gap-2 overflow-y-scroll">
|
<ul id="days" class="flex h-full flex-shrink-0 flex-col gap-2 overflow-y-scroll">
|
||||||
{#each $dates as date}
|
{#each $dates as date}
|
||||||
|
@ -14,5 +14,7 @@
|
|||||||
|
|
||||||
$: firstSession = dateSessions[dateSessions.length - 1];
|
$: firstSession = dateSessions[dateSessions.length - 1];
|
||||||
|
|
||||||
onMount(() => goto(`/projects/${projectId}/player/${$page.params.date}/${firstSession.id}`));
|
onMount(() =>
|
||||||
|
goto(`/projects/${projectId}/player/${$page.params.date}/${firstSession.id}${$page.url.search}`)
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
@ -23,9 +23,13 @@
|
|||||||
if (sessionEl) {
|
if (sessionEl) {
|
||||||
sessionEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
sessionEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
}
|
}
|
||||||
|
const changedLines = document.getElementsByClassName('line-changed');
|
||||||
|
if (changedLines.length > 0) {
|
||||||
|
changedLines[0].scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
currentDeltaIndex.subscribe(scrollToSession);
|
currentSessionId.subscribe(scrollToSession);
|
||||||
|
|
||||||
page.subscribe((page) => {
|
page.subscribe((page) => {
|
||||||
currentDeltaIndex.set(parseInt(page.url.searchParams.get('delta') || '0'));
|
currentDeltaIndex.set(parseInt(page.url.searchParams.get('delta') || '0'));
|
||||||
@ -128,6 +132,11 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeFromSearchParams = (params: URLSearchParams, key: string) => {
|
||||||
|
params.delete(key);
|
||||||
|
return params;
|
||||||
|
};
|
||||||
|
|
||||||
const decrementPlayerValue = () => {
|
const decrementPlayerValue = () => {
|
||||||
if ($inputValue > 0) {
|
if ($inputValue > 0) {
|
||||||
$inputValue -= 1;
|
$inputValue -= 1;
|
||||||
@ -173,7 +182,10 @@
|
|||||||
class="session-card rounded border-[0.5px] border-gb-700 text-zinc-300 shadow-md"
|
class="session-card rounded border-[0.5px] border-gb-700 text-zinc-300 shadow-md"
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href="/projects/{projectId}/player/{$currentDate}/{session.id}?delta=0"
|
href="/projects/{projectId}/player/{$currentDate}/{session.id}?{removeFromSearchParams(
|
||||||
|
$page.url.searchParams,
|
||||||
|
'delta'
|
||||||
|
).toString()}"
|
||||||
disabled={isCurrent}
|
disabled={isCurrent}
|
||||||
class="w-full"
|
class="w-full"
|
||||||
>
|
>
|
||||||
|
@ -23,7 +23,7 @@ const enrichSession = async (projectId: string, session: Session) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params, parent }) => {
|
export const load: PageLoad = async ({ params, parent, url }) => {
|
||||||
const { sessions } = await parent();
|
const { sessions } = await parent();
|
||||||
return {
|
return {
|
||||||
sessions: asyncDerived(sessions, async (sessions) =>
|
sessions: asyncDerived(sessions, async (sessions) =>
|
||||||
@ -31,9 +31,22 @@ export const load: PageLoad = async ({ params, parent }) => {
|
|||||||
sessions
|
sessions
|
||||||
.filter((session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === params.date)
|
.filter((session) => format(session.meta.startTimestampMs, 'yyyy-MM-dd') === params.date)
|
||||||
.map((session) => enrichSession(params.projectId, session))
|
.map((session) => enrichSession(params.projectId, session))
|
||||||
).then((sessions) =>
|
).then((sessions) => {
|
||||||
sessions.sort((a, b) => a.meta.startTimestampMs - b.meta.startTimestampMs)
|
sessions = sessions.sort((a, b) => a.meta.startTimestampMs - b.meta.startTimestampMs);
|
||||||
)
|
const fileFilter = url.searchParams.get('file');
|
||||||
|
if (fileFilter) {
|
||||||
|
sessions = sessions
|
||||||
|
.filter((session) => session.files[fileFilter])
|
||||||
|
.map((session) => ({
|
||||||
|
...session,
|
||||||
|
deltas: session.deltas.filter(([path]) => path === fileFilter),
|
||||||
|
files: {
|
||||||
|
[fileFilter]: session.files[fileFilter]
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return sessions;
|
||||||
|
})
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -56,7 +56,6 @@
|
|||||||
const name = formData.get('name') as string | undefined;
|
const name = formData.get('name') as string | undefined;
|
||||||
const description = formData.get('description') as string | undefined;
|
const description = formData.get('description') as string | undefined;
|
||||||
|
|
||||||
console.log({ name, description });
|
|
||||||
try {
|
try {
|
||||||
if (name) {
|
if (name) {
|
||||||
const updated = await api.projects.update($user.access_token, $project?.api.repository_id, {
|
const updated = await api.projects.update($user.access_token, $project?.api.repository_id, {
|
||||||
|
Loading…
Reference in New Issue
Block a user