-
Notifications
You must be signed in to change notification settings - Fork 2
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
Major overhaul of charts #44
Merged
Changes from 18 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
cbaa394
Add loading indicator, refresh button
flenter 8562cb7
Add show promql toggle
flenter 06b2b64
Revert change to icon
flenter a77ee71
Remove useRequestData hook
flenter 6e6a90e
Simplify
flenter 276b30c
Fix loading
flenter 2288861
Fix alignment issue
flenter 8c319b2
Persist timerange in extension instead of panel
flenter cc4d3c4
Cleanup
flenter 70e0d87
Tweak color scheme and add click outside handler
flenter 7431949
Add copy to clipboard
flenter 73530ea
Persist showingQuery in extension
flenter 7feeb1c
Improve formatting for some queries
flenter 4374713
Refactor src/chart/utils
flenter 8dbf2d8
Additional styling tweaks
flenter ef69315
upgrade to typescript 5
flenter dc87dca
Refactor so more styling is shared
flenter cefb973
Fix lint issues
flenter 40fcbff
Remove loading delay
flenter e81b9be
Feedback on pr
flenter 79ec8a6
Update changelog
flenter e3fd2b2
Fix build
flenter 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,59 @@ | ||
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; | ||
import { styles } from "./prismStyles"; | ||
import styled from "styled-components"; | ||
import { Button } from "../Button"; | ||
import { Copy } from "./Copy"; | ||
import { useRef } from "react"; | ||
import { pxToEm } from "../../utils"; | ||
|
||
export function CodeBlock({ query }: { query: string }) { | ||
const ref = useRef<HTMLDivElement | null>(null); | ||
return ( | ||
<SyntaxHighlighter language="promql" style={styles}> | ||
{query} | ||
</SyntaxHighlighter> | ||
<Container> | ||
<CodeContainer ref={ref}> | ||
<SyntaxHighlighter language="promql" style={styles}> | ||
{query} | ||
</SyntaxHighlighter> | ||
</CodeContainer> | ||
<StyledButton | ||
onClick={() => { | ||
navigator.clipboard.writeText(query); | ||
if (ref.current) { | ||
if (window.getSelection) { | ||
const selection = window.getSelection(); | ||
const range = document.createRange(); | ||
range.selectNodeContents(ref.current); | ||
if (selection) { | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
return; | ||
} | ||
} | ||
}} | ||
> | ||
<Copy width="17" height="17" /> | ||
</StyledButton> | ||
</Container> | ||
); | ||
} | ||
|
||
const Container = styled.div` | ||
display: grid; | ||
grid-template-columns: auto 38px; | ||
background:var(--vscode-dropdown-background, --vscode-editor-background, #ffffff); | ||
margin: 0; | ||
margin-top: ${pxToEm(13)}; | ||
border-radius: ${pxToEm(4)}; | ||
border: 1px solid var(--vscode-dropdown-border, --vscode-widget-border, #ccc); | ||
`; | ||
|
||
const CodeContainer = styled.div` | ||
overflow: auto; | ||
`; | ||
|
||
const StyledButton = styled(Button)` | ||
border-radius: var(--vscode-corner-size, ${pxToEm(4)}); | ||
border-top-left-radius: 0; | ||
border-bottom-left-radius: 0; | ||
`; |
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,27 @@ | ||
import * as React from "react"; | ||
export const Copy = (props: React.SVGAttributes<HTMLOrSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={26} | ||
height={26} | ||
fill="none" | ||
viewBox="0 0 26 26" | ||
{...props} | ||
> | ||
<title>Copy</title> | ||
<path | ||
fill="currentColor" | ||
fillOpacity={0.4} | ||
fillRule="evenodd" | ||
d="M21 5H8.714v12.286H21V5ZM8.714 3h-2v16.286H23V3H8.714Z" | ||
clipRule="evenodd" | ||
/> | ||
<path | ||
fill="currentColor" | ||
fillOpacity={0.4} | ||
fillRule="evenodd" | ||
d="M5 7v14h14v2H3V7h2Z" | ||
clipRule="evenodd" | ||
/> | ||
</svg> | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import * as React from "react"; | ||
export const ErrorIcon = (props: React.SVGAttributes<HTMLOrSVGElement>) => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={23} | ||
height={20} | ||
fill="none" | ||
viewBox="0 0 23 20" | ||
{...props} | ||
> | ||
<title>Error icon</title> | ||
<path | ||
fill="currentColor" | ||
d="M22.906 19.464 11.921.178a.35.35 0 0 0-.608 0L5.816 9.821.323 19.464a.362.362 0 0 0 0 .356.35.35 0 0 0 .303.18h21.978a.35.35 0 0 0 .303-.18.363.363 0 0 0 0-.356ZM12.67 17.143H10.56V15h2.11v2.143Zm0-3.572H10.56V8.096h2.11v5.475Z" | ||
/> | ||
</svg> | ||
); |
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.
i think you can safely combine the two ifs here? perhaps i'm missing something