Skip to content

Commit

Permalink
Do not try to get the length of extractedVariables if it's null (#34)
Browse files Browse the repository at this point in the history
* Make checker for grafana happy by not calling console.log()

* Do not try to get the length of extractedVariables if it's null

The URL can (although of limited utility) be without variables, let's
deal with it.

Signed-off-by: Matthieu Patou <mat@matws.net>

---------

Signed-off-by: Matthieu Patou <mat@matws.net>
  • Loading branch information
ekacnet authored Sep 28, 2024
1 parent 5c3980a commit 86f5f4a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cubism-grafana-panel",
"version": "0.1.0",
"version": "0.1.1",
"description": "A panel to display cubism like graph in grafana",
"scripts": {
"build": "webpack -c ./webpack.config.ts --env production",
Expand Down
9 changes: 6 additions & 3 deletions src/components/DataLinksEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { css } from '@emotion/css';

// filter out suggestions that we don't support
type getSuggestionsFunc = () => VariableSuggestion[]

const DataLinkEditorWarning: React.FC<{
links: Array<DataLink<any>>
}> = ({ links}) => {
Expand All @@ -19,9 +20,11 @@ const DataLinkEditorWarning: React.FC<{
const pattern = /\${[^}]*}/g;
const extractedVariables: string[] = url.match(pattern)!;
let unsupported: string[] = [];
for (let j = 0; j < extractedVariables.length; j++) {
if (!extractedVariables[j].slice(2, -1).startsWith('__field.labels')) {
unsupported.push(extractedVariables[j])
if (extractedVariables) {
for (let j = 0; j < extractedVariables.length; j++) {
if (!extractedVariables[j].slice(2, -1).startsWith('__field.labels')) {
unsupported.push(extractedVariables[j])
}
}
}
if (unsupported.length > 0) {
Expand Down

0 comments on commit 86f5f4a

Please sign in to comment.