Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit a2702db

Browse files
Update code editor from business components (#89)
* update code editor * Updates * Updates * Update datasources.yaml --------- Co-authored-by: Mikhail Volkov <mikhail@volkovlabs.io>
1 parent db547a3 commit a2702db

File tree

8 files changed

+52
-30
lines changed

8 files changed

+52
-30
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Changelog
22

3-
## 4.3.0 (IN PROGRESS)
3+
## 4.3.0 (2024-09-13)
44

55
### Features / Enhancements
66

77
- Updated "Add a row" below the rows list (#83, #84)
88
- Added toDataFrame helper to code parameters (#86)
99
- Updated to Grafana 11.2 and dependencies (#87)
10+
- Updated code editor from business components (#89)
1011

1112
## 4.2.0 (2024-07-24)
1213

package-lock.json

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@grafana/schema": "^11.2.0",
99
"@grafana/ui": "^11.2.0",
1010
"@hello-pangea/dnd": "^16.6.0",
11-
"@volkovlabs/components": "^3.0.0",
11+
"@volkovlabs/components": "^3.1.0",
1212
"react": "^18.3.1",
1313
"react-dom": "^18.3.1",
1414
"tslib": "^2.7.0",
@@ -20,7 +20,7 @@
2020
"@grafana/eslint-config": "^7.0.0",
2121
"@grafana/plugin-e2e": "^1.8.0",
2222
"@grafana/tsconfig": "^2.0.0",
23-
"@playwright/test": "^1.47.0",
23+
"@playwright/test": "^1.47.1",
2424
"@swc/core": "^1.7.26",
2525
"@swc/helpers": "^0.5.13",
2626
"@swc/jest": "^0.2.36",

provisioning/datasources/datasources.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
apiVersion: 1
22

33
datasources:
4-
- name: Static
4+
- name: Business Input
55
type: marcusolsson-static-datasource
66
access: proxy
77
isDefault: true
88
orgId: 1
9+
uid: P1D2C73DC01F2359B
910
version: 1
1011
editable: true
1112
jsonData:

src/components/CustomValuesEditor/CustomValuesEditor.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import { CustomValuesEditor } from './CustomValuesEditor';
1212
jest.mock('@grafana/ui', () => ({
1313
...jest.requireActual('@grafana/ui'),
1414
CodeEditor: jest.fn(() => null),
15+
PageToolbar: jest.fn(({ leftItems, children }) => {
16+
return (
17+
<>
18+
{leftItems}
19+
{children}
20+
</>
21+
);
22+
}),
1523
}));
1624

1725
/**
@@ -148,7 +156,7 @@ describe('Custom Values Editor', () => {
148156
() =>
149157
({
150158
getVariables: jest.fn().mockImplementation(() => variables),
151-
} as any)
159+
}) as any
152160
);
153161

154162
render(getComponent({}));

src/components/CustomValuesEditor/CustomValuesEditor.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getTemplateSrv } from '@grafana/runtime';
2-
import { CodeEditor, CodeEditorSuggestionItem, CodeEditorSuggestionItemKind, InlineField } from '@grafana/ui';
2+
import { CodeEditorSuggestionItem, CodeEditorSuggestionItemKind, InlineField } from '@grafana/ui';
3+
import { AutosizeCodeEditor } from '@volkovlabs/components';
34
/**
45
* Monaco
56
*/
@@ -85,7 +86,7 @@ export const CustomValuesEditor = ({ model, onChange }: Props) => {
8586
return (
8687
<>
8788
<InlineField grow={true} data-testid={TEST_IDS.customValuesEditor.root}>
88-
<CodeEditor
89+
<AutosizeCodeEditor
8990
value={model?.meta?.custom?.customCode || CUSTOM_CODE}
9091
language={CodeLanguage.JAVASCRIPT}
9192
height={300}
@@ -95,6 +96,9 @@ export const CustomValuesEditor = ({ model, onChange }: Props) => {
9596
showLineNumbers={true}
9697
getSuggestions={getSuggestions}
9798
onEditorDidMount={onEditorMount}
99+
modalTitle="JavaScript Values Editor"
100+
modalButtonTooltip="Expand JavaScript Values Editor"
101+
showMiniMap={true}
98102
/>
99103
</InlineField>
100104
</>

src/components/QueryEditor/QueryEditor.test.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ import { QueryEditor } from './QueryEditor';
1414
jest.mock('@grafana/ui', () => ({
1515
...jest.requireActual('@grafana/ui'),
1616
CodeEditor: jest.fn(() => null),
17+
PageToolbar: jest.fn(({ leftItems, children }) => {
18+
return (
19+
<>
20+
{leftItems}
21+
{children}
22+
</>
23+
);
24+
}),
1725
Select: jest.fn().mockImplementation(({ options, onChange, value, isClearable, ...restProps }) => (
1826
<select
1927
onChange={(event: any) => {

src/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"url": "https://volkovlabs.io"
1313
},
1414
"description": "Store and create your data",
15-
"keywords": ["static", "test", "development", "mock", "javascript"],
15+
"keywords": ["input", "test", "development", "mock", "javascript"],
1616
"links": [
1717
{
1818
"name": "Documentation",

0 commit comments

Comments
 (0)