From e51c80f8dd524698ae81a38bb1a19800ca4b4b44 Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Wed, 10 Aug 2022 12:00:19 +0100 Subject: [PATCH] Storybook: remove `UseState` from `ButtonSelect` story (#53509) * remove UseState from ButtonSelect story * leave this type assertion for now --- .betterer.results | 4 -- .../Dropdown/ButtonSelect.story.internal.tsx | 48 +++++++------------ pkg/services/live/runstream/mock.go | 2 +- 3 files changed, 19 insertions(+), 35 deletions(-) diff --git a/.betterer.results b/.betterer.results index f3d5cf6ecf5..1f882809198 100644 --- a/.betterer.results +++ b/.betterer.results @@ -1395,10 +1395,6 @@ exports[`better eslint`] = { "packages/grafana-ui/src/components/DateTimePickers/TimeZonePicker/TimeZoneOption.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] ], - "packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.internal.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"] - ], "packages/grafana-ui/src/components/Dropdown/ButtonSelect.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "1"] diff --git a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.internal.tsx b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.internal.tsx index ad926aa87fd..950bfec818e 100644 --- a/packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.internal.tsx +++ b/packages/grafana-ui/src/components/Dropdown/ButtonSelect.story.internal.tsx @@ -1,11 +1,8 @@ import { action } from '@storybook/addon-actions'; +import { useArgs } from '@storybook/client-api'; import { ComponentMeta, ComponentStory } from '@storybook/react'; import React from 'react'; -import { SelectableValue } from '@grafana/data'; - -import { DashboardStoryCanvas } from '../../utils/storybook/DashboardStoryCanvas'; -import { UseState } from '../../utils/storybook/UseState'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { ButtonSelect } from './ButtonSelect'; @@ -16,40 +13,31 @@ const meta: ComponentMeta = { decorators: [withCenteredStory], parameters: { controls: { - exclude: ['className', 'options', 'value', 'tooltipContent'], + exclude: ['className', 'onChange', 'tooltipContent'], }, }, + args: { + value: { label: 'A label', value: 'A value' }, + options: [ + { label: 'A label', value: 'A value' }, + { label: 'Another label', value: 'Another value' }, + ], + }, }; export const Basic: ComponentStory = (args) => { - const initialValue: SelectableValue = { label: 'A label', value: 'A value' }; - const options: Array> = [initialValue, { label: 'Another label', value: 'Another value' }]; + const [, updateArgs] = useArgs(); return ( - - - {(value, updateValue) => { - return ( -
- { - action('onChanged fired')(value); - updateValue(value as any); - }} - className="refresh-select" - /> -
- ); +
+ { + action('onChange fired')(value); + updateArgs({ value }); }} - - + /> +
); }; -Basic.args = { - narrow: true, - variant: 'default', -}; export default meta; diff --git a/pkg/services/live/runstream/mock.go b/pkg/services/live/runstream/mock.go index 42a5324e34f..9b38e653c90 100644 --- a/pkg/services/live/runstream/mock.go +++ b/pkg/services/live/runstream/mock.go @@ -10,7 +10,7 @@ import ( gomock "github.com/golang/mock/gomock" backend "github.com/grafana/grafana-plugin-sdk-go/backend" - "github.com/grafana/grafana/pkg/services/user" + "github.com/grafana/grafana/pkg/services/user" ) // MockChannelLocalPublisher is a mock of ChannelLocalPublisher interface.