-
Notifications
You must be signed in to change notification settings - Fork 237
feat(compass-indexes): add index build progress COMPASS-9495 #7200
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
d16ee17
feat(compass-indexes): add index build progress COMPASS-9495
nbbeeken 3408a51
fix: tests
nbbeeken ab39f35
fix: switch back to 10s intervals and round the number at the component
nbbeeken 7d4209f
chore: dont need math
nbbeeken df84f03
chore: copilot
nbbeeken 891d3d0
fix: move index progress to data-service
nbbeeken 9106a0a
fix hook deps
nbbeeken e10b79d
fix: styles and types
nbbeeken 764f474
test: buildProgress display
nbbeeken 3f5faa5
fix: styles
nbbeeken 0853225
fix: rename indexActionsContainerStyles
nbbeeken dbfa09f
fix: use …
nbbeeken b43a671
fix: spacing
nbbeeken d2a93a2
docs: comments on filter
nbbeeken a902b7f
feat: make the agg run the division
nbbeeken e2e309f
fix: remove progress from "in-progress"
nbbeeken 990a128
fix: assert thrown error correctly
nbbeeken 4cced3e
fix: use trunc
nbbeeken c92237b
remove double pass
nbbeeken 163e40c
fix: return index filtering to what it was
nbbeeken c179d47
chore: diff
nbbeeken 10b2237
test: fix using ... vs …
nbbeeken 8ab3c95
chore: try without setting "allUsers"
nbbeeken 9cc7114
chore: set badge correctly
nbbeeken 3ad263b
chore: remove mergeIndexes logic for buildprogress
nbbeeken fbbdd21
fix: building -> inprogress
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,22 +1,29 @@ | ||||||
import semver from 'semver'; | ||||||
import React, { useCallback, useMemo } from 'react'; | ||||||
import type { GroupedItemAction } from '@mongodb-js/compass-components'; | ||||||
import { css, ItemActionGroup } from '@mongodb-js/compass-components'; | ||||||
import { | ||||||
css, | ||||||
ItemActionGroup, | ||||||
SpinLoader, | ||||||
Body, | ||||||
spacing, | ||||||
} from '@mongodb-js/compass-components'; | ||||||
import type { RegularIndex } from '../../modules/regular-indexes'; | ||||||
|
||||||
const styles = css({ | ||||||
// Align actions with the end of the table | ||||||
justifyContent: 'flex-end', | ||||||
}); | ||||||
|
||||||
type Index = { | ||||||
name: string; | ||||||
extra?: { | ||||||
hidden?: boolean; | ||||||
}; | ||||||
}; | ||||||
const buildProgressStyles = css({ | ||||||
display: 'flex', | ||||||
alignItems: 'center', | ||||||
justifyContent: 'flex-end', | ||||||
gap: spacing[200], | ||||||
}); | ||||||
|
||||||
type IndexActionsProps = { | ||||||
index: Index; | ||||||
index: RegularIndex; | ||||||
serverVersion: string; | ||||||
onDeleteIndexClick: (name: string) => void; | ||||||
onHideIndexClick: (name: string) => void; | ||||||
|
@@ -44,33 +51,46 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({ | |||||
}) => { | ||||||
const indexActions: GroupedItemAction<IndexAction>[] = useMemo(() => { | ||||||
const actions: GroupedItemAction<IndexAction>[] = []; | ||||||
const buildProgress = index.buildProgress; | ||||||
const isBuilding = buildProgress > 0 && buildProgress < 1; | ||||||
|
||||||
if (serverSupportsHideIndex(serverVersion)) { | ||||||
actions.push( | ||||||
index.extra?.hidden | ||||||
? { | ||||||
action: 'unhide', | ||||||
label: `Unhide Index ${index.name}`, | ||||||
tooltip: `Unhide Index`, | ||||||
icon: 'Visibility', | ||||||
} | ||||||
: { | ||||||
action: 'hide', | ||||||
label: `Hide Index ${index.name}`, | ||||||
tooltip: `Hide Index`, | ||||||
icon: 'VisibilityOff', | ||||||
} | ||||||
); | ||||||
} | ||||||
if (isBuilding) { | ||||||
// partially built | ||||||
actions.push({ | ||||||
action: 'delete', | ||||||
label: `Cancel Index ${index.name}`, | ||||||
icon: 'XWithCircle', | ||||||
variant: 'destructive', | ||||||
}); | ||||||
} else { | ||||||
// completed | ||||||
if (serverSupportsHideIndex(serverVersion)) { | ||||||
actions.push( | ||||||
index.extra?.hidden | ||||||
? { | ||||||
action: 'unhide', | ||||||
label: `Unhide Index ${index.name}`, | ||||||
tooltip: `Unhide Index`, | ||||||
icon: 'Visibility', | ||||||
} | ||||||
: { | ||||||
action: 'hide', | ||||||
label: `Hide Index ${index.name}`, | ||||||
tooltip: `Hide Index`, | ||||||
icon: 'VisibilityOff', | ||||||
} | ||||||
); | ||||||
} | ||||||
|
||||||
actions.push({ | ||||||
action: 'delete', | ||||||
label: `Drop Index ${index.name}`, | ||||||
icon: 'Trash', | ||||||
}); | ||||||
actions.push({ | ||||||
action: 'delete', | ||||||
label: `Drop Index ${index.name}`, | ||||||
icon: 'Trash', | ||||||
}); | ||||||
} | ||||||
|
||||||
return actions; | ||||||
}, [index, serverVersion]); | ||||||
}, [index.name, index.extra?.hidden, index.buildProgress, serverVersion]); | ||||||
|
||||||
const onAction = useCallback( | ||||||
(action: IndexAction) => { | ||||||
|
@@ -85,6 +105,21 @@ const IndexActions: React.FunctionComponent<IndexActionsProps> = ({ | |||||
[onDeleteIndexClick, onHideIndexClick, onUnhideIndexClick, index] | ||||||
); | ||||||
|
||||||
const buildProgress = index.buildProgress; | ||||||
if (buildProgress > 0 && buildProgress < 1) { | ||||||
return ( | ||||||
<div className={buildProgressStyles} data-testid="index-building-spinner"> | ||||||
<Body>Building... {(buildProgress * 100) | 0}%</Body> | ||||||
|
<Body>Building... {(buildProgress * 100) | 0}%</Body> | |
<Body>Building… {Math.trunc(buildProgress * 100)}%</Body> |
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!
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Needs to be called to validate
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, dunno how I missed this. On the node team I recall we either had a lint rule or we monkey-patched this assertion to require it has an argument because you could start throwing something else and not realize.
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.
Hmmm, do you mind digging up what ruleset that was if you have time for this? I just did a quick search through the codebase and seems like we have a bunch of those uncalled ones, I didn't realize that this is easy to miss... 😬 "Worst" case we can probably just add our own custom rule for this
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 found it, we modified the chai assertion: https://github.com/mongodb/js-bson/blob/d32397730426cc8423b89ddc1dd20ef4180f1677/test/register-bson.js#L14-L41
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.
Which I realize won't help bc you won't hit this unless you call it, I think I fixed those mistakes with search and replace back when I introduced this. No "throw;" was pretty easy to eliminate 😅