mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Storybook: remove UseState
from ButtonSelect
story (#53509)
* remove UseState from ButtonSelect story * leave this type assertion for now
This commit is contained in:
parent
aaccb592cc
commit
e51c80f8dd
@ -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"]
|
||||
|
@ -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;
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user