From 1d3122632fb2925a181d33393a09751cb11b4cf1 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Thu, 24 Jan 2019 15:35:50 +0100 Subject: [PATCH] Move Switch component to grafana-ui --- .../grafana-ui/src}/components/Switch/Switch.tsx | 12 +++++++----- packages/grafana-ui/src/components/index.ts | 1 + .../features/dashboard/panel_editor/QueryOptions.tsx | 2 +- .../features/datasources/settings/BasicSettings.tsx | 5 +++-- public/app/features/explore/Logs.tsx | 3 +-- .../app/plugins/panel/gauge/GaugeOptionsEditor.tsx | 3 +-- .../app/plugins/panel/graph2/GraphPanelOptions.tsx | 4 +--- 7 files changed, 15 insertions(+), 15 deletions(-) rename {public/app/core => packages/grafana-ui/src}/components/Switch/Switch.tsx (76%) diff --git a/public/app/core/components/Switch/Switch.tsx b/packages/grafana-ui/src/components/Switch/Switch.tsx similarity index 76% rename from public/app/core/components/Switch/Switch.tsx rename to packages/grafana-ui/src/components/Switch/Switch.tsx index d53a3d68878..36475e55acb 100644 --- a/public/app/core/components/Switch/Switch.tsx +++ b/packages/grafana-ui/src/components/Switch/Switch.tsx @@ -4,10 +4,11 @@ import _ from 'lodash'; export interface Props { label: string; checked: boolean; + className?: string; labelClass?: string; switchClass?: string; transparent?: boolean; - onChange: (event) => any; + onChange: (event?: React.SyntheticEvent) => void; } export interface State { @@ -19,20 +20,21 @@ export class Switch extends PureComponent { id: _.uniqueId(), }; - internalOnChange = event => { + internalOnChange = (event: React.FormEvent) => { event.stopPropagation(); - this.props.onChange(event); + + this.props.onChange(); }; render() { - const { labelClass = '', switchClass = '', label, checked, transparent } = this.props; + const { labelClass = '', switchClass = '', label, checked, transparent, className } = this.props; const labelId = `check-${this.state.id}`; const labelClassName = `gf-form-label ${labelClass} ${transparent ? 'gf-form-label--transparent' : ''} pointer`; const switchClassName = `gf-form-switch ${switchClass} ${transparent ? 'gf-form-switch--transparent' : ''}`; return ( -