Skip to content

Commit

Permalink
Update code editor from business components (#89)
Browse files Browse the repository at this point in the history
* update code editor

* Updates

* Updates

* Update datasources.yaml

---------

Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
vitPinchuk and mikhail-vl authored Sep 13, 2024
1 parent db547a3 commit a2702db
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 30 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Changelog

## 4.3.0 (IN PROGRESS)
## 4.3.0 (2024-09-13)

### Features / Enhancements

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

## 4.2.0 (2024-07-24)

Expand Down
44 changes: 22 additions & 22 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@grafana/schema": "^11.2.0",
"@grafana/ui": "^11.2.0",
"@hello-pangea/dnd": "^16.6.0",
"@volkovlabs/components": "^3.0.0",
"@volkovlabs/components": "^3.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"tslib": "^2.7.0",
Expand All @@ -20,7 +20,7 @@
"@grafana/eslint-config": "^7.0.0",
"@grafana/plugin-e2e": "^1.8.0",
"@grafana/tsconfig": "^2.0.0",
"@playwright/test": "^1.47.0",
"@playwright/test": "^1.47.1",
"@swc/core": "^1.7.26",
"@swc/helpers": "^0.5.13",
"@swc/jest": "^0.2.36",
Expand Down
3 changes: 2 additions & 1 deletion provisioning/datasources/datasources.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: 1

datasources:
- name: Static
- name: Business Input
type: marcusolsson-static-datasource
access: proxy
isDefault: true
orgId: 1
uid: P1D2C73DC01F2359B
version: 1
editable: true
jsonData:
Expand Down
10 changes: 9 additions & 1 deletion src/components/CustomValuesEditor/CustomValuesEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ import { CustomValuesEditor } from './CustomValuesEditor';
jest.mock('@grafana/ui', () => ({
...jest.requireActual('@grafana/ui'),
CodeEditor: jest.fn(() => null),
PageToolbar: jest.fn(({ leftItems, children }) => {
return (
<>
{leftItems}
{children}
</>
);
}),
}));

/**
Expand Down Expand Up @@ -148,7 +156,7 @@ describe('Custom Values Editor', () => {
() =>
({
getVariables: jest.fn().mockImplementation(() => variables),
} as any)
}) as any
);

render(getComponent({}));
Expand Down
8 changes: 6 additions & 2 deletions src/components/CustomValuesEditor/CustomValuesEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getTemplateSrv } from '@grafana/runtime';
import { CodeEditor, CodeEditorSuggestionItem, CodeEditorSuggestionItemKind, InlineField } from '@grafana/ui';
import { CodeEditorSuggestionItem, CodeEditorSuggestionItemKind, InlineField } from '@grafana/ui';
import { AutosizeCodeEditor } from '@volkovlabs/components';
/**
* Monaco
*/
Expand Down Expand Up @@ -85,7 +86,7 @@ export const CustomValuesEditor = ({ model, onChange }: Props) => {
return (
<>
<InlineField grow={true} data-testid={TEST_IDS.customValuesEditor.root}>
<CodeEditor
<AutosizeCodeEditor
value={model?.meta?.custom?.customCode || CUSTOM_CODE}
language={CodeLanguage.JAVASCRIPT}
height={300}
Expand All @@ -95,6 +96,9 @@ export const CustomValuesEditor = ({ model, onChange }: Props) => {
showLineNumbers={true}
getSuggestions={getSuggestions}
onEditorDidMount={onEditorMount}
modalTitle="JavaScript Values Editor"
modalButtonTooltip="Expand JavaScript Values Editor"
showMiniMap={true}
/>
</InlineField>
</>
Expand Down
8 changes: 8 additions & 0 deletions src/components/QueryEditor/QueryEditor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { QueryEditor } from './QueryEditor';
jest.mock('@grafana/ui', () => ({
...jest.requireActual('@grafana/ui'),
CodeEditor: jest.fn(() => null),
PageToolbar: jest.fn(({ leftItems, children }) => {
return (
<>
{leftItems}
{children}
</>
);
}),
Select: jest.fn().mockImplementation(({ options, onChange, value, isClearable, ...restProps }) => (
<select
onChange={(event: any) => {
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"url": "https://volkovlabs.io"
},
"description": "Store and create your data",
"keywords": ["static", "test", "development", "mock", "javascript"],
"keywords": ["input", "test", "development", "mock", "javascript"],
"links": [
{
"name": "Documentation",
Expand Down

0 comments on commit a2702db

Please sign in to comment.