Skip to content

Commit

Permalink
fix(filter-picker): fix icon (#1922)
Browse files Browse the repository at this point in the history
Co-authored-by: maxin <maxin@growingio.com>
  • Loading branch information
nnmax and maxin committed Mar 23, 2022
1 parent 48eaa36 commit 3f9207c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
22 changes: 17 additions & 5 deletions src/legacy/filter-picker/FilterPicker.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import { Meta, Story } from '@storybook/react/types-6-0';
import FilterPicker from '.';
import { FilterPickerProps } from './interfaces';
import { FilterPickerProps, FilterValue } from './interfaces';
import { PropertyValue } from '../property-selector';
import './style';
import insightDimensions from '../property-selector/demos/insightDimensions';
Expand All @@ -11,7 +11,21 @@ export default {
component: FilterPicker,
} as Meta;

const Template: Story<FilterPickerProps> = (args) => <FilterPicker {...args} propertyOptions={insightDimensions} />;
const Template: Story<FilterPickerProps> = (args) => {
const [value, setValue] = useState<FilterValue>({ op: 'and', exprs: [] });
return (
<FilterPicker
{...args}
propertyOptions={insightDimensions}
filter={value}
onConfirm={(v) => {
// eslint-disable-next-line no-console
console.log(`🚀 onConfirm`, v);
setValue(v);
}}
/>
);
};

const dimissionValue = [
'www.growingio.com',
Expand Down Expand Up @@ -57,7 +71,6 @@ const dimissionValue = [

export const Default = Template.bind({});
Default.args = {
filter: { op: 'and', exprs: [], __typename: 'directivesFilterrR2q' },
recentlyStorePrefix: 'currentUserId',
timeRange: 'day:31,1',
measurements: [
Expand All @@ -68,7 +81,6 @@ Default.args = {
__typename: 'Measurement265f',
},
],
onConfirm: (value: any) => console.log('onConfirm: ', value),
dimensionValueRequest: () =>
new Promise((resolve) => {
resolve(dimissionValue);
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/filter-picker/FilterPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export const FilterPickerContext = React.createContext<
Pick<FilterPickerProps, 'fetchDetailData' | 'operationsOption'> & {
textObject: TextObject;
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
>({ textObject: { ...defaultLocaleTextObject, code: 'zh-CN' } });

const FilterPicker = (props: FilterPickerProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function FilterCondition(props: FilterConditionProps) {
);

return exprKey ? (
<FilterPickerContext.Provider value={{ textObject }}>
<FilterPickerContext.Provider value={{ textObject } as any}>
<Selector
valueRender={valueRender}
dropdownVisible={visible}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ExpressionProps {
measurements: any[];
onChange: (expression: FilterValueType, index: number) => void;
propertyOptions: any[];
exprs: any[];
exprs: FilterValueType[];
recentlyStorePrefix: string;
}
function Expression(props: ExpressionProps) {
Expand Down Expand Up @@ -50,6 +50,8 @@ function Expression(props: ExpressionProps) {
key: exprKey,
name: exprName,
valueType,
groupId,
iconId,
...v,
};
v && setValues(v.values);
Expand Down

1 comment on commit 3f9207c

@vercel
Copy link

@vercel vercel bot commented on 3f9207c Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.