-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add loading indicator, refresh button And keep track of a global state * Add show promql toggle * Revert change to icon * Remove useRequestData hook * Simplify * Fix loading * Fix alignment issue * Persist timerange in extension instead of panel * Cleanup * Tweak color scheme and add click outside handler For datepicker * Add copy to clipboard * Persist showingQuery in extension This way switching tabs means queries no longer disappear (as they are hidden by default right now) Not just in the react app. This way when you switch tabs data is * Improve formatting for some queries * Refactor src/chart/utils * Additional styling tweaks * upgrade to typescript 5 * Refactor so more styling is shared Between SingleChart and the Multi/Functions chart * Fix lint issues * Remove loading delay * Feedback on pr * Update changelog * Fix build
- Loading branch information
Showing
41 changed files
with
1,095 additions
and
413 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
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,57 @@ | ||
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 && 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.