mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 11:01:44 +00:00
## UI Updates for Perforce Depots and Git Repos Fixes SRCH-530 **NOTE: This PR is a refactor of an earlier [PR](https://github.com/sourcegraph/sourcegraph/pull/64014) that was reverted. For that reason, the PR description is largely the same.** This PR introduces changes to the UI to differentiate between Perforce Depots and Git repositories. Below are the key changes included in this commit: ### 1. Dynamic Top-Level Navigation **For Perforce Depots:**  **For Git Repos:**  ### 2. Tabs on Revision Picker **For Perforce Depots:** Since we only need one tab for changelists, no tabs are shown.  **For Git Repos:** We have tabs for Branches, Tags, and Commits.  ### 3. Commits/Changelists Page **For Git Repos:** The page displays Git commits.  **For Perforce Depots:** The page displays Perforce changelists.  ### 4. Vocabulary Adjustments - We display either Git commit SHAs or Changelist IDs based on the project type. - For authorship, we use "submitted by" for Perforce and "committed by" for Git. - We refer to "Commits" for Git projects and "Changelists" for Perforce projects. **Examples:** - **For Git Commits:**  - **For Perforce Changelists:**  ### 5. URL Mapping URLs are now structured differently based on the project type: - **Commits Page:** - Git: `/[repo-name]/-/commits` - Perforce: `/[repo-name]/-/changelists` - **Individual Item Page:** - Git: `/[repo-name]/-/commit/[commit-hash]` - Perforce: `/[depot-name]/-/changelist/[changelist-ID]` When viewing a specific commit or changelist: - **Git:** `/[repo-name]@[git-commit-hash]` - **Perforce:** `/[repo-name]@changelist/[changelist-id]` _NOTE: The value displayed in the search field will also change accordingly._ ### What is left to be done? **On repo search results, when searching a revision, we still show the git commit SHA instead of the changelist ID for perforce depots:**  I plan to make a follow-up issue for this and begin work on it immediately. It's a little trickier than the other changes because in the RepositoryMatch type, there is no value that can help us determine whether a project is a depot or a repo. We need to find another way to fetch that data. ### Request for reviewers: 1. Please try to break these new features and tell me what you find. I stumbled on a number of little gotchas while working on this, and I'm sure I've missed some. ## Test plan <!-- REQUIRED; info at https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> - Manual/Visual testing - Adjust e2e and integration tests to obtain a passing CI - Test directly visiting a URL versus getting there via click - Add unit tests for new/updated helper functions --------- Co-authored-by: Camden Cheek <camden@ccheek.com>
60 lines
1.6 KiB
Svelte
60 lines
1.6 KiB
Svelte
<!--
|
|
@component
|
|
Renders a permalink to the current page with the given Git commit ID.
|
|
-->
|
|
<script lang="ts">
|
|
import { goto } from '$app/navigation'
|
|
import { page } from '$app/stores'
|
|
import { createHotkey } from '$lib/Hotkey'
|
|
import Icon from '$lib/Icon.svelte'
|
|
import { replaceRevisionInURL } from '$lib/shared'
|
|
import Tooltip from '$lib/Tooltip.svelte'
|
|
import { parseBrowserRepoURL } from '$lib/web'
|
|
|
|
export let revID: string
|
|
export let tooltip: string
|
|
|
|
const hotkey = createHotkey({
|
|
keys: { key: 'y' },
|
|
ignoreInputFields: true,
|
|
handler: () => {
|
|
const { revision } = parseBrowserRepoURL($page.url.pathname)
|
|
// Only navigate if necessary. We don't want to add unnecessary history entries.
|
|
if (revision !== revID) {
|
|
goto(href, { noScroll: true, keepFocus: true }).catch(() => {
|
|
// TODO: log error with Sentry
|
|
})
|
|
}
|
|
},
|
|
})
|
|
|
|
$: href = revID ? replaceRevisionInURL($page.url.toString(), revID) : ''
|
|
$: if (href) {
|
|
hotkey.enable()
|
|
} else {
|
|
hotkey.disable()
|
|
}
|
|
</script>
|
|
|
|
{#if href}
|
|
<Tooltip {tooltip}>
|
|
<a {href}><Icon icon={ILucideLink} inline aria-hidden /> <span data-action-label>Permalink</span></a>
|
|
</Tooltip>
|
|
{/if}
|
|
|
|
<style lang="scss">
|
|
a {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 0.5rem;
|
|
color: var(--text-body);
|
|
text-decoration: none;
|
|
white-space: nowrap;
|
|
|
|
&:hover {
|
|
color: var(--text-title);
|
|
}
|
|
}
|
|
</style>
|