-
Notifications
You must be signed in to change notification settings - Fork 867
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
feat: Rollouts UI List view refresh #3118
Merged
zachaller
merged 21 commits into
argoproj:master
from
phclark:phclark-feat/home-ui-refresh
Nov 30, 2023
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
4024109
feat: Rollouts UI Refresh
phclark 925aab6
add test for labels and annotations
phclark 2039c47
Merge branch 'master' into phclark-feat/home-ui-refresh
phclark 9181c12
simplify regex
phclark c40c1c9
Merge branch 'phclark-feat/home-ui-refresh' of https://github.com/phc…
phclark 678cad8
make filters use OR logic
phclark 6732090
Merge branch 'master' into phclark-feat/home-ui-refresh
phclark 6869f5d
add keyboard listener
phclark 04044d1
Merge branch 'phclark-feat/home-ui-refresh' of https://github.com/phc…
phclark 65d2812
set default display mode to grid
phclark c30e7a1
set strategy column to left justify
phclark d8cb10a
add tooltips to view buttons
phclark 9404e35
consider unknown status rollouts as needing attention
phclark ff17b55
remove duplicate escape key listener
phclark 04f5391
group status filters together
phclark 4bae584
improve filter logic
phclark 9b5cd46
remove debug logging
phclark 530b942
dont show help on escape
phclark 6716d50
properly remove url search params when disabled
phclark bd848c9
rename to RolloutGridWidget
phclark c93191d
prevent help menu from loading while searching
phclark 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 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 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 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 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 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 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 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 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 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 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 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 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
134 changes: 134 additions & 0 deletions
134
ui/src/app/components/rollout-widget/rollout-widget.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,134 @@ | ||
import * as React from 'react'; | ||
import {Link} from 'react-router-dom'; | ||
|
||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; | ||
import {faCircleNotch, faRedoAlt} from '@fortawesome/free-solid-svg-icons'; | ||
import {IconDefinition} from '@fortawesome/fontawesome-svg-core'; | ||
import {faStar as faStarSolid} from '@fortawesome/free-solid-svg-icons'; | ||
import {faStar as faStarOutline} from '@fortawesome/free-regular-svg-icons/faStar'; | ||
|
||
import {Tooltip} from 'antd'; | ||
|
||
import {ParsePodStatus, PodStatus, ReplicaSets} from '../pods/pods'; | ||
import {RolloutInfo} from '../../../models/rollout/rollout'; | ||
import {useWatchRollout} from '../../shared/services/rollout'; | ||
import {useClickOutside} from '../../shared/utils/utils'; | ||
import {InfoItemKind, InfoItemRow} from '../info-item/info-item'; | ||
import {RolloutAction, RolloutActionButton} from '../rollout-actions/rollout-actions'; | ||
import {RolloutStatus, StatusIcon} from '../status-icon/status-icon'; | ||
import './rollout-widget.scss'; | ||
|
||
export const isInProgress = (rollout: RolloutInfo): boolean => { | ||
for (const rs of rollout.replicaSets || []) { | ||
for (const p of rs.pods || []) { | ||
const status = ParsePodStatus(p.status); | ||
if (status === PodStatus.Pending) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
}; | ||
|
||
export const RolloutWidget = (props: { | ||
rollout: RolloutInfo; | ||
deselect: () => void; | ||
selected?: boolean; | ||
isFavorite: boolean; | ||
onFavoriteChange: (rolloutName: string, isFavorite: boolean) => void; | ||
}) => { | ||
const [watching, subscribe] = React.useState(false); | ||
let rollout = props.rollout; | ||
useWatchRollout(props.rollout?.objectMeta?.name, watching, null, (r: RolloutInfo) => (rollout = r)); | ||
const ref = React.useRef(null); | ||
useClickOutside(ref, props.deselect); | ||
|
||
React.useEffect(() => { | ||
if (watching) { | ||
const to = setTimeout(() => { | ||
if (!isInProgress(rollout)) { | ||
subscribe(false); | ||
} | ||
}, 5000); | ||
return () => clearTimeout(to); | ||
} | ||
}, [watching, rollout]); | ||
|
||
return ( | ||
<Link | ||
to={`/rollout/${rollout.objectMeta?.namespace}/${rollout.objectMeta?.name}`} | ||
className={`rollouts-list__widget ${props.selected ? 'rollouts-list__widget--selected' : ''}`} | ||
ref={ref} | ||
> | ||
<WidgetHeader | ||
rollout={rollout} | ||
refresh={() => { | ||
subscribe(true); | ||
setTimeout(() => { | ||
subscribe(false); | ||
}, 1000); | ||
}} | ||
isFavorite={props.isFavorite} | ||
handleFavoriteChange={props.onFavoriteChange} | ||
/> | ||
<div className='rollouts-list__widget__body'> | ||
<InfoItemRow | ||
label={'Strategy'} | ||
items={{content: rollout.strategy, icon: rollout.strategy === 'BlueGreen' ? 'fa-palette' : 'fa-dove', kind: rollout.strategy.toLowerCase() as InfoItemKind}} | ||
/> | ||
{(rollout.strategy || '').toLocaleLowerCase() === 'canary' && <InfoItemRow label={'Weight'} items={{content: rollout.setWeight, icon: 'fa-weight'}} />} | ||
</div> | ||
<ReplicaSets replicaSets={rollout.replicaSets} showRevisions /> | ||
<div className='rollouts-list__widget__message'>{rollout.message !== 'CanaryPauseStep' && rollout.message}</div> | ||
<div className='rollouts-list__widget__actions'> | ||
<RolloutActionButton action={RolloutAction.Restart} rollout={rollout} callback={() => subscribe(true)} indicateLoading /> | ||
<RolloutActionButton action={RolloutAction.Promote} rollout={rollout} callback={() => subscribe(true)} indicateLoading /> | ||
</div> | ||
</Link> | ||
); | ||
}; | ||
|
||
const WidgetHeader = (props: {rollout: RolloutInfo; refresh: () => void; isFavorite: boolean; handleFavoriteChange: (rolloutName: string, isFavorite: boolean) => void}) => { | ||
const {rollout} = props; | ||
const [loading, setLoading] = React.useState(false); | ||
React.useEffect(() => { | ||
setTimeout(() => setLoading(false), 500); | ||
}, [loading]); | ||
|
||
const handleFavoriteClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
props.handleFavoriteChange(rollout.objectMeta?.name, !props.isFavorite); | ||
}; | ||
|
||
return ( | ||
<header> | ||
{props.isFavorite ? ( | ||
<button onClick={handleFavoriteClick} style={{cursor: 'pointer'}}> | ||
<FontAwesomeIcon icon={faStarSolid} size='lg' style={{marginRight: '10px'}} /> | ||
</button> | ||
) : ( | ||
<button onClick={handleFavoriteClick} style={{cursor: 'pointer'}}> | ||
<FontAwesomeIcon icon={faStarOutline as IconDefinition} size='lg' style={{marginRight: '10px'}} /> | ||
</button> | ||
)} | ||
{rollout.objectMeta?.name} | ||
<span style={{marginLeft: 'auto', display: 'flex', alignItems: 'center'}}> | ||
<Tooltip title='Refresh'> | ||
<FontAwesomeIcon | ||
icon={loading ? faCircleNotch : faRedoAlt} | ||
spin={loading} | ||
className={`rollouts-list__widget__refresh`} | ||
style={{marginRight: '10px', fontSize: '14px'}} | ||
onClick={(e) => { | ||
props.refresh(); | ||
setLoading(true); | ||
e.preventDefault(); | ||
}} | ||
/> | ||
</Tooltip> | ||
<StatusIcon status={rollout.status as RolloutStatus} /> | ||
</span> | ||
</header> | ||
); | ||
}; |
This file contains 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
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.
Since there is already a component with same name. Would it be better to rename it differently.
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.
@ashutosh16 I've renamed my new widget to
RolloutGridWidget
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'll review the PR today.