-
Notifications
You must be signed in to change notification settings - Fork 59
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 Feature] Add full-list log output to execution detail panel #744
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3d1820b
fix: added scrollable mono text for log messages
james-union 4be536b
Merge branch 'master' into james/execution-running-log
james-union debbb85
Merge branch 'master' into james/execution-running-log
james-union f84576e
fix: update flyteidl, use reasons instead of reason
james-union 69d7276
fix: yarn lock file updated
james-union 334c560
fix: only messages
james-union 6d93cb0
fix: added fallback for reason
james-union 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,8 @@ import { | |
} from 'models/Execution/types'; | ||
import { Routes } from 'routes/routes'; | ||
import { PaginatedEntityResponse } from 'models/AdminEntity/types'; | ||
import { compareTimestampsAscending, timestampToDate } from 'common/utils'; | ||
import { formatDateUTC } from 'common/formatters'; | ||
|
||
export function isSingleTaskExecution(execution: Execution) { | ||
return execution.spec.launchPlan.resourceType === ResourceType.TASK; | ||
|
@@ -27,10 +29,22 @@ export function getExecutionBackLink(execution: Execution): string { | |
export function getTaskExecutionDetailReasons( | ||
taskExecutionDetails?: PaginatedEntityResponse<TaskExecution>, | ||
): (string | null | undefined)[] { | ||
return ( | ||
const reasons = ( | ||
taskExecutionDetails?.entities.map( | ||
taskExecution => taskExecution.closure.reason, | ||
taskExecution => taskExecution.closure.reasons || [], | ||
) || [] | ||
) | ||
.flat() | ||
.sort((a, b) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also don't want to do sorting here; just print the array as returned. |
||
if (!a || !a.occurredAt) return -1; | ||
if (!b || !b.occurredAt) return 1; | ||
return compareTimestampsAscending(a.occurredAt, b.occurredAt); | ||
}); | ||
return reasons.map( | ||
reason => | ||
(reason.occurredAt | ||
? formatDateUTC(timestampToDate(reason.occurredAt)) + '\n' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't want to format the date; just show the text as-is here. |
||
: '') + reason.message, | ||
); | ||
} | ||
|
||
|
119 changes: 119 additions & 0 deletions
119
packages/console/src/components/common/ScrollableMonospaceText.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,119 @@ | ||
import { Button } from '@material-ui/core'; | ||
import { makeStyles, Theme } from '@material-ui/core/styles'; | ||
import FileCopy from '@material-ui/icons/FileCopy'; | ||
import classnames from 'classnames'; | ||
import { | ||
errorBackgroundColor, | ||
listhoverColor, | ||
nestedListColor, | ||
primaryHighlightColor, | ||
separatorColor, | ||
} from 'components/Theme/constants'; | ||
import copyToClipboard from 'copy-to-clipboard'; | ||
import * as React from 'react'; | ||
|
||
const showOnHoverClass = 'showOnHover'; | ||
|
||
export const useScrollableMonospaceTextStyles = makeStyles((theme: Theme) => ({ | ||
actionContainer: { | ||
transition: theme.transitions.create('opacity', { | ||
duration: theme.transitions.duration.shorter, | ||
easing: theme.transitions.easing.easeInOut, | ||
}), | ||
}, | ||
wrapper: { | ||
position: 'relative', | ||
}, | ||
container: { | ||
backgroundColor: errorBackgroundColor, | ||
border: `1px solid ${separatorColor}`, | ||
borderRadius: 4, | ||
height: theme.spacing(12), | ||
minHeight: theme.spacing(12), | ||
overflowY: 'scroll', | ||
padding: theme.spacing(2), | ||
display: 'flex', | ||
flexDirection: 'column-reverse', | ||
'$nestedParent &': { | ||
backgroundColor: theme.palette.common.white, | ||
}, | ||
// All children using the showOnHover class will be hidden until | ||
// the mouse enters the container | ||
[`& .${showOnHoverClass}`]: { | ||
opacity: 0, | ||
}, | ||
[`&:hover .${showOnHoverClass}`]: { | ||
opacity: 1, | ||
}, | ||
}, | ||
copyButton: { | ||
backgroundColor: theme.palette.common.white, | ||
border: `1px solid ${primaryHighlightColor}`, | ||
borderRadius: theme.spacing(1), | ||
color: theme.palette.text.secondary, | ||
height: theme.spacing(4), | ||
minWidth: 0, | ||
padding: 0, | ||
position: 'absolute', | ||
right: theme.spacing(3), | ||
top: theme.spacing(1), | ||
width: theme.spacing(4), | ||
'&:hover': { | ||
backgroundColor: listhoverColor, | ||
}, | ||
}, | ||
errorMessage: { | ||
fontFamily: 'monospace', | ||
whiteSpace: 'pre-wrap', | ||
wordBreak: 'break-all', | ||
wordWrap: 'break-word', | ||
}, | ||
// Apply this class to an ancestor container to have the expandable text | ||
// use an alternate background color scheme. | ||
nestedParent: { | ||
backgroundColor: nestedListColor, | ||
}, | ||
})); | ||
|
||
export interface ScrollableMonospaceTextProps { | ||
text: string; | ||
} | ||
|
||
/** An expandable/collapsible container which renders the provided text in a | ||
* monospace font. It also provides a button to copy the text. | ||
*/ | ||
export const ScrollableMonospaceText: React.FC< | ||
ScrollableMonospaceTextProps | ||
> = ({ text }) => { | ||
const styles = useScrollableMonospaceTextStyles(); | ||
const scrollRef = React.useRef<HTMLDivElement>(null); | ||
const onClickCopy = (e: React.MouseEvent<HTMLElement>) => { | ||
// prevent the parent row body onClick event trigger | ||
e.stopPropagation(); | ||
copyToClipboard(text); | ||
}; | ||
|
||
React.useEffect(() => { | ||
scrollRef.current?.scrollTo({ | ||
top: scrollRef.current.scrollHeight, | ||
}); | ||
}, [text, scrollRef.current]); | ||
|
||
return ( | ||
<div className={classnames(styles.wrapper)}> | ||
<div className={classnames(styles.container)} ref={scrollRef}> | ||
<div className={styles.errorMessage}>{`${text}`}</div> | ||
<div className={classnames(styles.actionContainer, showOnHoverClass)}> | ||
<Button | ||
color="primary" | ||
className={styles.copyButton} | ||
onClick={onClickCopy} | ||
variant="outlined" | ||
> | ||
<FileCopy fontSize="small" /> | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
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
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.
We need to add a fallback here for cases where users are running older versions of admin; fall back to
reason
.