-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display copyable error message when queries fail
Co-authored-by: Alex Paxton <thealexpaxton@gmail.com>
- Loading branch information
1 parent
6840050
commit f84d25c
Showing
5 changed files
with
116 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.empty-graph-error { | ||
border-radius: $radius; | ||
background: $g2-kevlar; | ||
position: relative; | ||
color: $c-dreamsicle; | ||
border: $ix-border solid $g5-pepper; | ||
|
||
pre { | ||
font-size: 14px; | ||
padding: $ix-marg-c; | ||
user-select: text !important; | ||
cursor: text; | ||
} | ||
} | ||
|
||
.empty-graph-error--icon { | ||
display: inline-block; | ||
margin-right: $ix-marg-b; | ||
} | ||
|
||
.empty-graph-error--copy { | ||
position: absolute; | ||
top: $ix-marg-b; | ||
right: $ix-marg-b; | ||
opacity: 0.9; | ||
} |
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,63 @@ | ||
// Libraries | ||
import React, {useState, FunctionComponent} from 'react' | ||
import CopyToClipboard from 'react-copy-to-clipboard' | ||
|
||
// Components | ||
import { | ||
Button, | ||
ComponentSize, | ||
ComponentColor, | ||
IconFont, | ||
} from '@influxdata/clockface' | ||
import FancyScrollbar from 'src/shared/components/fancy_scrollbar/FancyScrollbar' | ||
|
||
interface Props { | ||
message: string | ||
testID?: string | ||
} | ||
|
||
const EmptyGraphError: FunctionComponent<Props> = ({message, testID}) => { | ||
const [didCopy, setDidCopy] = useState(false) | ||
|
||
const buttonText = didCopy ? 'Copied!' : 'Copy' | ||
const buttonColor = didCopy ? ComponentColor.Success : ComponentColor.Default | ||
|
||
const onClick = () => { | ||
setDidCopy(true) | ||
setTimeout(() => setDidCopy(false), 2000) | ||
} | ||
|
||
return ( | ||
<div className="cell--view-empty" data-testid={testID}> | ||
<div className="empty-graph-error"> | ||
<CopyToClipboard text={message}> | ||
<Button | ||
size={ComponentSize.ExtraSmall} | ||
color={buttonColor} | ||
titleText={buttonText} | ||
text={buttonText} | ||
onClick={onClick} | ||
customClass="empty-graph-error--copy" | ||
/> | ||
</CopyToClipboard> | ||
<FancyScrollbar | ||
className="empty-graph-error--scroll" | ||
autoHide={false} | ||
thumbStartColor="#FF8564" | ||
thumbStopColor="#DC4E58" | ||
> | ||
<pre> | ||
<span | ||
className={`icon ${ | ||
IconFont.AlertTriangle | ||
} empty-graph-error--icon`} | ||
/> | ||
<code>{message}</code> | ||
</pre> | ||
</FancyScrollbar> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default EmptyGraphError |
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