mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* First try * Update * app with drilldowns * Progres * Progress * update * Update * update * Update * Update * Progress * Update * Progress * Update * Progress * logs url sync * related metrics * Progress * progress * Progress * Update * Update * Update * Update * Update * fix * Update * update * Update * update * Update * Update * Update * Update * Update * Update * Update * Update * Update * Update * update * Update * Update * Settings * Update * Tweaks * update * Improve auto queries * Update * Update * Fixes * Update * Update * Update * fix * Update * Removing logs view, cleanup * Update * Update * disabled not implemented buttons * Update * Feature toggle on dashboard menu * remove unused prometheus change * removed bit * Fix failing test * chore: added `/public/app/features/trails/` to CODEOWNERS * go mod tidy * go mod tidy * fix: added missing arg * Moved panel action * Moved panel action --------- Co-authored-by: André Pereira <adrapereira@gmail.com> Co-authored-by: Darren Janeczek <darren.janeczek@grafana.com>
94 lines
2.9 KiB
TypeScript
94 lines
2.9 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { SceneComponentProps, SceneObjectBase, SceneObjectState } from '@grafana/scenes';
|
|
import { Dropdown, Switch, ToolbarButton, useStyles2 } from '@grafana/ui';
|
|
|
|
export interface DataTrailSettingsState extends SceneObjectState {
|
|
showQuery?: boolean;
|
|
showAdvanced?: boolean;
|
|
multiValueVars?: boolean;
|
|
isOpen?: boolean;
|
|
}
|
|
|
|
export class DataTrailSettings extends SceneObjectBase<DataTrailSettingsState> {
|
|
constructor(state: Partial<DataTrailSettingsState>) {
|
|
super({
|
|
showQuery: state.showQuery ?? false,
|
|
showAdvanced: state.showAdvanced ?? false,
|
|
isOpen: state.isOpen ?? false,
|
|
});
|
|
}
|
|
|
|
public onToggleShowQuery = () => {
|
|
this.setState({ showQuery: !this.state.showQuery });
|
|
};
|
|
|
|
public onToggleAdvanced = () => {
|
|
this.setState({ showAdvanced: !this.state.showAdvanced });
|
|
};
|
|
|
|
public onToggleMultiValue = () => {
|
|
this.setState({ multiValueVars: !this.state.multiValueVars });
|
|
};
|
|
|
|
public onToggleOpen = (isOpen: boolean) => {
|
|
this.setState({ isOpen });
|
|
};
|
|
|
|
static Component = ({ model }: SceneComponentProps<DataTrailSettings>) => {
|
|
const { showQuery, showAdvanced, multiValueVars, isOpen } = model.useState();
|
|
const styles = useStyles2(getStyles);
|
|
|
|
const renderPopover = () => {
|
|
return (
|
|
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
<div className={styles.popover} onClick={(evt) => evt.stopPropagation()}>
|
|
<div className={styles.heading}>Settings</div>
|
|
<div className={styles.options}>
|
|
<div>Multi value variables</div>
|
|
<Switch value={multiValueVars} onChange={model.onToggleMultiValue} />
|
|
<div>Advanced options</div>
|
|
<Switch value={showAdvanced} onChange={model.onToggleAdvanced} />
|
|
<div>Show query</div>
|
|
<Switch value={showQuery} onChange={model.onToggleShowQuery} />
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
return (
|
|
<Dropdown overlay={renderPopover} placement="bottom" onVisibleChange={model.onToggleOpen}>
|
|
<ToolbarButton icon="cog" variant="canvas" isOpen={isOpen} />
|
|
</Dropdown>
|
|
);
|
|
};
|
|
}
|
|
|
|
function getStyles(theme: GrafanaTheme2) {
|
|
return {
|
|
popover: css({
|
|
display: 'flex',
|
|
padding: theme.spacing(2),
|
|
flexDirection: 'column',
|
|
background: theme.colors.background.primary,
|
|
boxShadow: theme.shadows.z3,
|
|
borderRadius: theme.shape.borderRadius(),
|
|
border: `1px solid ${theme.colors.border.weak}`,
|
|
zIndex: 1,
|
|
marginRight: theme.spacing(2),
|
|
}),
|
|
heading: css({
|
|
fontWeight: theme.typography.fontWeightMedium,
|
|
paddingBottom: theme.spacing(2),
|
|
}),
|
|
options: css({
|
|
display: 'grid',
|
|
gridTemplateColumns: '1fr 50px',
|
|
rowGap: theme.spacing(1),
|
|
columnGap: theme.spacing(2),
|
|
}),
|
|
};
|
|
}
|