This repository was archived by the owner on Sep 30, 2024. It is now read-only.
fix(svelte): Preserve selected lines in codehost URL#63334
Merged
fkling merged 1 commit intoJun 26, 2024
Merged
Conversation
It was reported that the new web app doesn't preserve the selected lines when navigating to the corresponding file in the code host. This commit fixes that. Additionally this commit adds file actions (most importantly the 'view in codehost' one) to the 'file at revision' view. And while working on that I also fixed the 'view at commit' button in the history panel, which should not show 'close commit' when the inline diff view is open.
fkling
commented
Jun 19, 2024
Comment on lines
+93
to
+94
| <Tooltip tooltip={selected && !diffEnabled ? 'Close commit' : 'View at commit'}> | ||
| <a href={selected && !diffEnabled ? closeURL : `?rev=${commit.oid}`} |
Contributor
Author
There was a problem hiding this comment.
It should only say 'Close commit' when the we are in 'at commit' mode, not 'inline diff' mode.
Comment on lines
+19
to
+42
| switch (externalLink.serviceKind) { | ||
| case ExternalServiceKind.GITHUB: { | ||
| // Add range or position path to the code host URL. | ||
| if (lineOrPosition?.line !== undefined) { | ||
| url += `#L${lineOrPosition.line}` | ||
|
|
||
| if (lineOrPosition.endLine) { | ||
| url += `-L${lineOrPosition.endLine}` | ||
| } | ||
| } | ||
| break | ||
| } | ||
| case ExternalServiceKind.GITLAB: { | ||
| // Add range or position path to the code host URL. | ||
| if (lineOrPosition?.line !== undefined) { | ||
| url += `#L${lineOrPosition.line}` | ||
|
|
||
| if (lineOrPosition.endLine) { | ||
| url += `-${lineOrPosition.endLine}` | ||
| } | ||
| } | ||
| break | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Comment on lines
+22
to
+26
| <svelte:fragment slot="icon"> | ||
| {#if $commit.value?.blob} | ||
| <FileIcon file={$commit.value.blob} inline /> | ||
| {/if} | ||
| </svelte:fragment> |
Contributor
Author
There was a problem hiding this comment.
It's not possible to 'assign' to a named slot inside a conditional, but apparently there is no error thrown when using a component with slot (only for elements). The Svelte team decided not add support for this in favor of Svelte 5's snippets (where this seems to be possible).
camdencheek
approved these changes
Jun 25, 2024
| $: rawURL = (function () { | ||
| const url = `${repoURL}/-/raw/${filePath}` | ||
| return revisionOverride ? replaceRevisionInURL(url, revisionOverride.abbreviatedOID) : url | ||
| })() |
Member
There was a problem hiding this comment.
It's times like this that I really miss Rust's block expressions 🙂
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes srch-131
It was reported that the new web app doesn't preserve the selected lines when navigating to the corresponding file in the code host. This commit fixes that.
Additionally this commit adds file actions (most importantly the 'view in codehost' one) to the 'file at revision' view. I've excluded the 'open in editor' action from that view because I don't think it works with different commits (although that would also be a problem if someone was browsing the repo at a specific commit).
And while working on that I also fixed the 'view at commit' button in the history panel, which should not show 'close commit' when the inline diff view is open and the missing file icon in the inline diff view.
Test plan
Manual testing:
Changelog