From 82c3d8b518947b82be2123261b77c22c6a82040b Mon Sep 17 00:00:00 2001 From: Jason Harris <jason.harris@sourcegraph.com> Date: Thu, 15 Aug 2024 15:29:50 -0500 Subject: [PATCH 1/2] history panel should update ui elements if scoped to perforce depot --- client/web-sveltekit/src/lib/repo/HistoryPanel.gql | 4 ++++ .../web-sveltekit/src/lib/repo/HistoryPanel.svelte | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/web-sveltekit/src/lib/repo/HistoryPanel.gql b/client/web-sveltekit/src/lib/repo/HistoryPanel.gql index 9c5a69ebf984..5e2e40eca7e7 100644 --- a/client/web-sveltekit/src/lib/repo/HistoryPanel.gql +++ b/client/web-sveltekit/src/lib/repo/HistoryPanel.gql @@ -11,6 +11,10 @@ fragment HistoryPanel_HistoryConnection on GitCommitConnection { ...Avatar_Person } } + perforceChangelist { + cid + canonicalURL + } canonicalURL } pageInfo { diff --git a/client/web-sveltekit/src/lib/repo/HistoryPanel.svelte b/client/web-sveltekit/src/lib/repo/HistoryPanel.svelte index 61e0a457da3f..faa849ae8537 100644 --- a/client/web-sveltekit/src/lib/repo/HistoryPanel.svelte +++ b/client/web-sveltekit/src/lib/repo/HistoryPanel.svelte @@ -61,13 +61,17 @@ <tbody> {#each $history.data as commit (commit.id)} {@const selected = commit.abbreviatedOID === selectedRev || commit.oid === selectedRev} + {@const isPerforceDepot = commit.perforceChangelist !== null} + {@const revURL = isPerforceDepot ? commit.perforceChangelist?.canonicalURL : commit.canonicalURL} + {@const revID = isPerforceDepot ? commit.perforceChangelist?.cid : commit.abbreviatedOID} + <tr class:selected use:scrollIntoViewOnMount={selected}> <td class="revision"> - <Badge variant="link"><a href={commit.canonicalURL}>{commit.abbreviatedOID}</a></Badge> + <Badge variant="link"><a href={revURL}>{revID}</a></Badge> </td> <td class="subject"> {#if enableInlineDiff} - <a href={selected ? closeURL : `?rev=${commit.oid}&diff=1`}>{commit.subject}</a> + <a href={selected ? closeURL : `?rev=${revID}&diff=1`}>{commit.subject}</a> {:else} {commit.subject} {/if} @@ -78,7 +82,7 @@ </td> <td class="timestamp"><Timestamp date={new Date(commit.author.date)} strict /></td> <td class="actions"> - {#if enableViewAtCommit} + {#if enableViewAtCommit && !isPerforceDepot} <Tooltip tooltip={selected && !diffEnabled ? 'Close commit' : 'View at commit'}> <a href={selected && !diffEnabled ? closeURL : `?rev=${commit.oid}`} ><Icon icon={ILucideFileText} inline aria-hidden /></a @@ -89,7 +93,7 @@ <a href={replaceRevisionInURL( SourcegraphURL.from($page.url).deleteSearchParameter('rev', 'diff').toString(), - commit.oid + isPerforceDepot ? `changelist/${revID}` : revID || '' )}><Icon icon={ILucideFolderGit} inline aria-hidden /></a > </Tooltip> From de12d4fb18b317ada3f6e6ab5035eaf1ff957754 Mon Sep 17 00:00:00 2001 From: Peter Guy <peter.guy@sourcegraph.com> Date: Thu, 15 Aug 2024 14:17:58 -0700 Subject: [PATCH 2/2] Include both the changelist and commit in the query --- .../(validrev)/(code)/-/blob/[...path]/+page.ts | 6 +++++- .../(validrev)/(code)/-/blob/[...path]/page.gql | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/+page.ts b/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/+page.ts index 3514d1d6d075..bba78e78e45b 100644 --- a/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/+page.ts +++ b/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/+page.ts @@ -46,7 +46,11 @@ async function loadDiffView({ params, url }: PageLoadEvent) { revspec: revisionOverride, path: filePath, }) - .then(mapOrThrow(result => result.data?.repository?.commit ?? null)), + .then( + mapOrThrow( + result => result.data?.repository?.changelist?.commit ?? result.data?.repository?.commit ?? null + ) + ), } } diff --git a/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/page.gql b/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/page.gql index dd5827fd627f..5df000d0130a 100644 --- a/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/page.gql +++ b/client/web-sveltekit/src/routes/[...repo=reporev]/(validrev)/(code)/-/blob/[...path]/page.gql @@ -1,6 +1,21 @@ query BlobDiffViewCommitQuery($repoName: String!, $revspec: String!, $path: String!) { repository(name: $repoName) { id + changelist(cid: $revspec) { + commit { + id + perforceChangelist { + cid + canonicalURL + } + + blob(path: $path) { + ...DiffViewGitBlob + } + + ...DiffViewCommit + } + } commit(rev: $revspec) { id perforceChangelist {