Storybook: remove UseState from ButtonSelect story (#53509)

* remove UseState from ButtonSelect story

* leave this type assertion for now
This commit is contained in:
Ashley Harrison 2022-08-10 12:00:19 +01:00 committed by GitHub
parent aaccb592cc
commit e51c80f8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 35 deletions

View File

@ -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"]

View File

@ -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<typeof ButtonSelect> = {
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<typeof ButtonSelect> = (args) => {
const initialValue: SelectableValue<string> = { label: 'A label', value: 'A value' };
const options: Array<SelectableValue<string>> = [initialValue, { label: 'Another label', value: 'Another value' }];
const [, updateArgs] = useArgs();
return (
<DashboardStoryCanvas>
<UseState initialState={initialValue}>
{(value, updateValue) => {
return (
<div style={{ marginLeft: '100px', position: 'relative', display: 'inline-block' }}>
<ButtonSelect
{...args}
value={value}
options={options}
onChange={(value) => {
action('onChanged fired')(value);
updateValue(value as any);
}}
className="refresh-select"
/>
</div>
);
<div style={{ marginLeft: '100px', position: 'relative', display: 'inline-block' }}>
<ButtonSelect
{...args}
onChange={(value) => {
action('onChange fired')(value);
updateArgs({ value });
}}
</UseState>
</DashboardStoryCanvas>
/>
</div>
);
};
Basic.args = {
narrow: true,
variant: 'default',
};
export default meta;

View File

@ -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.