Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add theme suggestions #266

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/utils/code-parameters.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
import { AlertPayload, EventBus, GrafanaTheme2, InterpolateFunction, PanelData } from '@grafana/data';
import { AlertPayload, EventBus, InterpolateFunction, PanelData } from '@grafana/data';
import { LocationService } from '@grafana/runtime';
import { CodeEditorSuggestionItemKind } from '@grafana/ui';
import { CodeEditorSuggestionItemKind, getTheme } from '@grafana/ui';
import { CodeParameterItem, CodeParametersBuilder } from '@volkovlabs/components';
import { ECharts } from 'echarts';

import { SeriesItem } from '../types';

/**
* Get theme params
* @param theme
* @param detail
*/
const getThemeParams = <TObject extends object>(theme: TObject, detail: string): any => ({

Check warning on line 14 in src/utils/code-parameters.ts

View workflow job for this annotation

GitHub Actions / tests

Unexpected any. Specify a different type

Check warning on line 14 in src/utils/code-parameters.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

Check warning on line 14 in src/utils/code-parameters.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
detail,
items: {
...Object.entries(theme).reduce((acc, [key, value]) => {
if (typeof value === 'object' && !Array.isArray(value)) {
return {
...acc,
[key]: getThemeParams(value, key),
};
}

return {
...acc,
[key]: new CodeParameterItem<typeof value>(key),
};
}, {}),
},
});

/**
* Base Code Parameters Config
*/
Expand All @@ -28,7 +52,7 @@
'Interpolate variables.',
CodeEditorSuggestionItemKind.Method
),
theme: new CodeParameterItem<GrafanaTheme2>('Location service.'),
theme: getThemeParams(getTheme(), 'Theme object'),
notifySuccess: new CodeParameterItem<(payload: AlertPayload) => void>(
'Display successful notification.',
CodeEditorSuggestionItemKind.Method
Expand Down
Loading