Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: change summary under prefix #2744

Merged
merged 9 commits into from
Nov 30, 2021
Merged

UI: change summary under prefix #2744

merged 9 commits into from
Nov 30, 2021

Conversation

johnnyaug
Copy link
Contributor

@johnnyaug johnnyaug commented Nov 23, 2021

When viewing a change, this feature adds a button to calculate a summary of the change under every key prefix.
When the button is clicked, the user will see a number of added/changed/deleted/conflicting objects under the prefix.

This was added to all screens where changes can be viewed: Uncommitted changes, Compare view, and when diving into a specific commit.

Peek 2021-11-23 11-52

Solves #2675.

@johnnyaug johnnyaug added the include-changelog PR description should be included in next release changelog label Nov 23, 2021
@johnnyaug johnnyaug changed the title UI/diff prefix stats UI: change summary under prefix for Diff/Compare views. Nov 23, 2021
@johnnyaug johnnyaug changed the title UI: change summary under prefix for Diff/Compare views. UI: change summary under prefix for Diff/Compare views Nov 23, 2021
@johnnyaug johnnyaug marked this pull request as ready for review November 23, 2021 11:32
class SummaryEntry {
constructor() {
this.count = 0
this.size = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.size = 0
this.sizeBytes = 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 88 to 89
<><span className={"color-fg-removed"}>{summaryData.removed.count}</span> objects removed<br/></>}
{summaryData.changed.count > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you please explain your choice not to show the size for the items removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

(I was under the false impression that the size wasn't returned for "deleted" type diffs)

pathSection = <Link href={onNavigate(entry)}>{pathSection}</Link>
}
const rowActions = []
if (onClickExpandDiff) {
rowActions.push(new RowAction(<FileDiffIcon/>, diffExpanded ? "Hide changes" : "Show changes", diffExpanded, onClickExpandDiff))
Copy link
Contributor

Choose a reason for hiding this comment

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

The FileDiffIcon should be visible by default. I think that you have a bug here because the icon becomes visible only while hovering a leaf row.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't find a reasonable way to do it, I don't want all the side-actions to be visible by default.

Copy link
Contributor

@itaiad200 itaiad200 left a comment

Choose a reason for hiding this comment

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

Requesting changes mostly for checking consistency with the actual file viewers. If it's too much for this PR let's open a separate issue for consistency and cache handling of entries in the ChangeViewer.


/**
* Widget to display a summary of a change: the number of added/changed/deleted/conflicting objects.
* Shows an error if the change is has more than {@link MAX_NUM_OBJECTS} entries.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Shows an error if the change is has more than {@link MAX_NUM_OBJECTS} entries.
* Shows an error if the change has more than {@link MAX_NUM_OBJECTS} entries.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

setResultsState({results: resultsState.results.concat(results), pagination: pagination, tooManyPages: false})
}, [resultsState.results, loading])

if (loading) return <ClockIcon/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why take this approach instead of showing results so far and keep update it forever..?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's not a good experience to show an updating number of objects.

@@ -89,65 +96,79 @@ export const TreeItem = ({ entry, repo, reference, leftDiffRefID, rightDiffRefID
return <Error error={error}/>

if (loading && results.length === 0)
return <TreeEntryRow key={entry.path+"entry-row"} entry={entry} showActions={true} loading={true} relativeTo={relativeTo} depth={depth} onRevert={onRevert} onNavigate={onNavigate} repo={repo} reference={reference}/>
return <TreeEntryRow key={entry.path+"entry-row"} entry={entry} loading={true} relativeTo={relativeTo} depth={depth} onRevert={onRevert} onNavigate={onNavigate}repo={repo} reference={reference}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return <TreeEntryRow key={entry.path+"entry-row"} entry={entry} loading={true} relativeTo={relativeTo} depth={depth} onRevert={onRevert} onNavigate={onNavigate}repo={repo} reference={reference}
return <TreeEntryRow key={entry.path+"entry-row"} entry={entry} loading={true} relativeTo={relativeTo} depth={depth} onRevert={onRevert} onNavigate={onNavigate} repo={repo} reference={reference}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines +46 to +61
useEffect(async () => {
// get pages until reaching the max change size
if (resultsState.results && resultsState.results.length >= MAX_NUM_OBJECTS) {
setResultsState({results: null, pagination: {}, tooManyPages: true})
setLoading(false)
return
}
if (!loading) {
return
}
const {results, pagination} = await getMore(resultsState.pagination.next_offset || "", prefix, false, PAGE_SIZE)
if (!pagination.has_more) {
setLoading(false)
}
setResultsState({results: resultsState.results.concat(results), pagination: pagination, tooManyPages: false})
}, [resultsState.results, loading])
Copy link
Contributor

Choose a reason for hiding this comment

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

This is inconsistent with file viewer. You may show statistics for 3 files but present 2 in the ui.
This happens because:

  1. Listing happens separately.
  2. Files are cached and statistics are not.

Copy link
Contributor Author

@johnnyaug johnnyaug Nov 28, 2021

Choose a reason for hiding this comment

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

Solving this basically means I have to refresh all expanded paths in the tree, together with all the stats that are already shown (see explanation below).

I'm not sure it's worth the effort and the performance risk. Since it is clearly shown to the user that the summary is calculated, I think inconsistencies can be expected.

Explanation

Since summaries are calculated on demand - the only way for me to be consistent with the expanded tree is to refresh all expanded paths under the given path.

After doing so, shown summaries on upper levels should be updated to be consistent with their children.
In turn, all expanded paths under these summaries should be updated to be consistent with them.

This potentially requires updating the whole tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

@johnnyaug to clarify - are you referring to a situation where you added let's say 100 objects to partition "a", and at a time 50 objects are loaded to the tree but the stats show that 100 objects were added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is described here is a scenario where data is constantly written to the repo, and you are viewing the change at different points in time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just to make sure I understand, this limitation is due to the way we built the tree structure. "Refreshing" means we need to go and fetch everything again, while the summary already did it. I don't want to block on it because I don't think it would be that common. Can we open an issue for consolidation of the summary and the tree fetching?

this.size = 0
}
add(count, size) {
this.count += count
Copy link
Contributor

Choose a reason for hiding this comment

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

guess it will be always 1

@@ -143,7 +143,7 @@ export const TreeEntryRow = ({entry, relativeTo = "", leaf = false, dirExpanded,
pathSection = <Link href={onNavigate(entry)}>{pathSection}</Link>
}
const rowActions = []
if (onClickExpandDiff) {
if (onClickExpandDiff && entry.type !== 'conflict') {
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't have to but consider exporting this and other diff types to the new constants.jsx file

Comment on lines +46 to +61
useEffect(async () => {
// get pages until reaching the max change size
if (resultsState.results && resultsState.results.length >= MAX_NUM_OBJECTS) {
setResultsState({results: null, pagination: {}, tooManyPages: true})
setLoading(false)
return
}
if (!loading) {
return
}
const {results, pagination} = await getMore(resultsState.pagination.next_offset || "", prefix, false, PAGE_SIZE)
if (!pagination.has_more) {
setLoading(false)
}
setResultsState({results: resultsState.results.concat(results), pagination: pagination, tooManyPages: false})
}, [resultsState.results, loading])
Copy link
Contributor

Choose a reason for hiding this comment

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

@johnnyaug to clarify - are you referring to a situation where you added let's say 100 objects to partition "a", and at a time 50 objects are loaded to the tree but the stats show that 100 objects were added?

Copy link
Contributor

@itaiad200 itaiad200 left a comment

Choose a reason for hiding this comment

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

Approving, great work! I mostly played around with the UI, didn't look too deeply into the code.

Copy link
Contributor

@talSofer talSofer left a comment

Choose a reason for hiding this comment

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

Awsome feature!

@johnnyaug johnnyaug changed the title UI: change summary under prefix for Diff/Compare views UI: change summary under prefix Nov 30, 2021
@johnnyaug johnnyaug merged commit 88c2ae2 into master Nov 30, 2021
@johnnyaug johnnyaug deleted the ui/diff_prefix_stats branch November 30, 2021 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include-changelog PR description should be included in next release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants