-
Notifications
You must be signed in to change notification settings - Fork 361
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
Conversation
class SummaryEntry { | ||
constructor() { | ||
this.count = 0 | ||
this.size = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.size = 0 | |
this.sizeBytes = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
<><span className={"color-fg-removed"}>{summaryData.removed.count}</span> objects removed<br/></>} | ||
{summaryData.changed.count > 0 && |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* 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. |
There was a problem hiding this comment.
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/> |
There was a problem hiding this comment.
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..?
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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]) |
There was a problem hiding this comment.
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:
- Listing happens separately.
- Files are cached and statistics are not.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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
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]) |
There was a problem hiding this comment.
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?
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awsome feature!
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.
Solves #2675.