mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* add page and basic things * quick annotations * added so we can run queries on the view rule page. * wip. * merge * cleaned up the combined rule hook. * readd queries * fixing so you can run queries. * renamed variable. * fix rerenders and visualizing * minor fixes. * work in progress. * wip * a working version that can be tested. * changing check if we have data. * removed unused styling. * removed unused dep. * removed another dep. * Update public/app/features/alerting/unified/hooks/useCombinedRule.ts Co-authored-by: Domas <domas.lapinskas@grafana.com> * Update public/app/features/alerting/unified/hooks/useCombinedRule.ts Co-authored-by: Domas <domas.lapinskas@grafana.com> * refactored and changed UI according to figma. * resseting menu item. * removing unused external link. * refactor according to feedback. * changed so we always fetch the rule. * fixing so datasource only is displayed once. Also changed so we only navigate to alert list when rule has been deleted. * removed unused dep. * Will display query as json if we can't find data source. * changed to a function instead of the React.FC. * refactoring of id generation and added support to generate ids for native prometheus alerts without ruler. * set max width on page content * added page where you can easily link to a rule in grafana. * listing rules with same name. * fixing error cases. * updates after pr feedback * more pr feedback * use 1h-now as timerange * remove unused import * start on test * add test for cloud case * add ruleview render test * add render tests for grafana and cloud alerts * add mock for backendsrv * add rendering test for the find route * check if cards are rendered Co-authored-by: Peter Holmberg <peter.hlmbrg@gmail.com> Co-authored-by: Domas <domas.lapinskas@grafana.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import { SelectableValue } from '@grafana/data';
|
|
import { config } from '@grafana/runtime';
|
|
import { RadioButtonGroup } from '@grafana/ui';
|
|
import React, { useMemo } from 'react';
|
|
import { STAT, TABLE, TIMESERIES } from '../utils/constants';
|
|
|
|
export type SupportedPanelPlugins = 'timeseries' | 'table' | 'stat';
|
|
|
|
type Props = {
|
|
value: SupportedPanelPlugins;
|
|
onChange: (value: SupportedPanelPlugins) => void;
|
|
size?: 'sm' | 'md';
|
|
};
|
|
|
|
export function PanelPluginsButtonGroup(props: Props): JSX.Element | null {
|
|
const { value, onChange, size = 'md' } = props;
|
|
const panels = useMemo(() => getSupportedPanels(), []);
|
|
|
|
return <RadioButtonGroup options={panels} value={value} onChange={onChange} size={size} />;
|
|
}
|
|
|
|
function getSupportedPanels(): Array<SelectableValue<SupportedPanelPlugins>> {
|
|
return Object.values(config.panels).reduce((panels: Array<SelectableValue<SupportedPanelPlugins>>, panel) => {
|
|
if (isSupportedPanelPlugin(panel.id)) {
|
|
panels.push({
|
|
value: panel.id,
|
|
label: panel.name,
|
|
imgUrl: panel.info.logos.small,
|
|
});
|
|
}
|
|
return panels;
|
|
}, []);
|
|
}
|
|
|
|
function isSupportedPanelPlugin(id: string): id is SupportedPanelPlugins {
|
|
switch (id) {
|
|
case TIMESERIES:
|
|
case TABLE:
|
|
case STAT:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|