-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check validity of regexes before sending them to Historian backend
- Loading branch information
Showing
15 changed files
with
267 additions
and
73 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 |
---|---|---|
|
@@ -35,3 +35,4 @@ node-modules/ | |
factry-historian-datasource/ | ||
*.zip | ||
*.sha1 | ||
.eslintcache |
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,3 +1,3 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
"typescript.tsdk": "node_modules/typescript/lib" | ||
} |
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,6 +1,6 @@ | ||
major = 2 | ||
minor = 0 | ||
patch = 4 | ||
minor = 1 | ||
patch = 1 | ||
prerelease = | ||
project_name=factry-historian-datasource | ||
|
||
|
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
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,43 @@ | ||
import React, { ChangeEvent, FormEvent, useState } from 'react' | ||
import { Input, Tooltip } from '@grafana/ui' | ||
import { isRegex, isValidRegex } from 'util/util' | ||
|
||
export interface MaybeRegexInputProps { | ||
onChange: (val: string, valid: boolean) => void | ||
initialValue?: string | ||
placeHolder?: string | ||
} | ||
|
||
export function MaybeRegexInput(props: MaybeRegexInputProps) { | ||
const [error, setError] = useState<string | undefined>() | ||
|
||
const onChange = (event: FormEvent<HTMLInputElement>) => { | ||
const keyword = (event as ChangeEvent<HTMLInputElement>).target.value as string | ||
let valid = false | ||
if (isRegex(keyword)) { | ||
if (isValidRegex(keyword)) { | ||
setError(undefined) | ||
valid = true | ||
} else { | ||
setError('Invalid regex') | ||
} | ||
} else { | ||
setError(undefined) | ||
valid = true | ||
} | ||
|
||
props.onChange(keyword, valid) | ||
} | ||
|
||
return ( | ||
<Tooltip | ||
content={() => <>{error}</>} | ||
theme="error" | ||
placement="right" | ||
show={error !== undefined} | ||
interactive={false} | ||
> | ||
<Input value={props.initialValue} onChange={(e) => onChange(e)} /> | ||
</Tooltip> | ||
) | ||
} |
Oops, something went wrong.