-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add plots error message below ribbon #5165
Changes from all commits
ecf6ecc
1df1191
b4935b9
361b96f
6490e38
3aded0c
1b08674
1e62dda
1990649
780f737
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { useSelector } from 'react-redux' | ||
import styles from './styles.module.scss' | ||
import { Error } from '../../shared/components/icons' | ||
import { PlotsState } from '../store' | ||
import { useModalOpenClass } from '../hooks/useModalOpenClass' | ||
|
||
export const ErrorsModal: React.FC = () => { | ||
const errors = useSelector((state: PlotsState) => state.webview.plotErrors) | ||
useModalOpenClass() | ||
|
||
return ( | ||
<div className={styles.errorsModal} data-testid="errors-modal"> | ||
<h3 className={styles.errorsModalTitle}> | ||
julieg18 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<Error className={styles.errorsModalIcon} width="20" height="20" /> | ||
Errors | ||
</h3> | ||
<table> | ||
<tbody> | ||
{errors.map(({ path, revs }) => ( | ||
<React.Fragment key={path}> | ||
<tr> | ||
<th colSpan={2} className={styles.errorsModalPlot}> | ||
{path} | ||
</th> | ||
</tr> | ||
{revs.map(({ rev, msg }) => ( | ||
<tr key={`${rev}-${msg}`}> | ||
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. Similar blocks of code found in 2 locations. Consider refactoring. |
||
<td className={styles.errorsModalRev}>{rev}</td> | ||
<td className={styles.errorsModalMsgs}>{msg}</td> | ||
</tr> | ||
))} | ||
</React.Fragment> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import React, { useEffect, useRef } from 'react' | ||
import React, { useRef } from 'react' | ||
import { PlotsSection } from 'dvc/src/plots/webview/contract' | ||
import { View } from 'react-vega' | ||
import { ExtendedVegaLite } from './vegaLite/ExtendedVegaLite' | ||
|
@@ -15,6 +15,7 @@ import { | |
exportPlotDataAsJson, | ||
exportPlotDataAsTsv | ||
} from '../util/messages' | ||
import { useModalOpenClass } from '../hooks/useModalOpenClass' | ||
|
||
type ZoomedInPlotProps = { | ||
id: string | ||
|
@@ -43,15 +44,7 @@ export const ZoomedInPlot: React.FC<ZoomedInPlotProps> = ({ | |
openActionsMenu | ||
}: ZoomedInPlotProps) => { | ||
const zoomedInPlotRef = useRef<HTMLDivElement>(null) | ||
|
||
useEffect(() => { | ||
const modalOpenClass = 'modalOpen' | ||
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. Moved this |
||
document.body.classList.add(modalOpenClass) | ||
|
||
return () => { | ||
document.body.classList.remove(modalOpenClass) | ||
} | ||
}, []) | ||
useModalOpenClass() | ||
|
||
const onNewView = (view: View) => { | ||
const actions: HTMLDivElement | null | undefined = | ||
|
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 a note to self, we should reduce the number of branches in this switch/case by having an enum instead:
and a simple
dispatch(actionToDispatch[key](data.data.key))
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 open an issue for that. And don't worry, it's totally out of scope and has nothing to do with your PR.