Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

File tree improvements #9916

Merged
merged 9 commits into from
Apr 17, 2020
Merged

File tree improvements #9916

merged 9 commits into from
Apr 17, 2020

Conversation

attfarhan
Copy link
Contributor

Addresses outstanding comments in https://github.com/sourcegraph/sourcegraph/pull/9842.

Also fixes a small unintended bug in #9842. When the go-to-def or find refs button is clicked, the ?subtree param would be included in the URL, so when the references or definition panel appears, the file tree updates to only show the current directory, which is not what we want. So I check to make sure the tab= parameter is not present before updating the tree. cc @uwedeportivo I would like to get this cherry-picked into the release.

- Use a single ?subtree query parameter instead for suggestions and actions.
- Construct the url with the query param in the web directory.
- Do not refresh tree when panel is open
@attfarhan attfarhan requested a review from a team April 16, 2020 15:20
Copy link
Member

@eseliger eseliger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good but I have no insight where these could be used elsewhere so what it might affect.
I'd love to get someone with more insight here for a review as well :)

@eseliger eseliger requested a review from a team April 16, 2020 18:33
@attfarhan
Copy link
Contributor Author

I am going to merge this, I am quite sure that the tab param is used only for panels.

cc @felixfbecker in case you want to take another look since you left the original PR comments.

web/src/platform/context.ts Outdated Show resolved Hide resolved
web/src/search/input/Suggestion.tsx Outdated Show resolved Hide resolved
web/src/search/input/Suggestion.tsx Outdated Show resolved Hide resolved
web/src/tree/Tree.tsx Outdated Show resolved Hide resolved
web/src/tree/Tree.tsx Outdated Show resolved Hide resolved
queryParams.delete('action')
// Strip the ?subtree query param. Handle both when going from ancestor -> child and child -> ancestor.
if (queryParams.has('subtree')) {
queryParams.delete('subtree')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this after the if so it would remove false values to (delete() is a noop if the param does not exist)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the entire content of this if statement? Can't move just the delete statement out since the history update needs the new queryParams.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you move it after the if, the history update inside the if will still have access to it, wouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear I mean only the delete call.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The history update will have access to the old query params... without the subtree deleted. We want to delete the subtree param before updating history, otherwise it's just going to update to the same URL infinitely.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you're right, I misunderstood the intention. I'd change my proposal to move it above the if.

@felixfbecker
Copy link
Contributor

I can't find any mention of the tab parameter in the diff, could you clarify?

attfarhan and others added 2 commits April 17, 2020 16:03
Co-Authored-By: Felix Becker <felix.b@outlook.com>
Co-Authored-By: Felix Becker <felix.b@outlook.com>
@codecov
Copy link

codecov bot commented Apr 17, 2020

Codecov Report

Merging #9916 into master will increase coverage by 0.00%.
The diff coverage is 27.27%.

@@           Coverage Diff           @@
##           master    #9916   +/-   ##
=======================================
  Coverage   42.76%   42.76%           
=======================================
  Files        1347     1347           
  Lines       73949    73947    -2     
  Branches     6641     6636    -5     
=======================================
  Hits        31625    31625           
+ Misses      39464    39462    -2     
  Partials     2860     2860           
Flag Coverage Δ
#unit 42.76% <27.27%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
shared/src/components/FileMatchChildren.tsx 72.72% <ø> (ø)
shared/src/components/RepoFileLink.tsx 100.00% <ø> (ø)
web/src/platform/context.ts 0.00% <0.00%> (ø)
web/src/search/input/Suggestion.tsx 13.63% <ø> (ø)
web/src/tree/Tree.tsx 0.00% <0.00%> (ø)
shared/src/util/url.ts 89.75% <75.00%> (ø)

attfarhan and others added 4 commits April 17, 2020 16:03
Co-Authored-By: Felix Becker <felix.b@outlook.com>
Co-Authored-By: Felix Becker <felix.b@outlook.com>
Co-Authored-By: Felix Becker <felix.b@outlook.com>
@attfarhan
Copy link
Contributor Author

@felixfbecker I just added it in the latest commit.

@attfarhan attfarhan merged commit 0fd04e3 into master Apr 17, 2020
@attfarhan attfarhan deleted the fa/tree-comments branch April 17, 2020 12:06
attfarhan added a commit that referenced this pull request Apr 17, 2020
- Use a single ?subtree query parameter instead for suggestions and actions.
- Construct the url with the query param in the web directory.
- Do not refresh tree when panel is open
@lguychard lguychard mentioned this pull request Apr 17, 2020
36 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants