Skip to content

Commit

Permalink
Fixed story
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbordeau committed Oct 10, 2024
1 parent d97a0f9 commit 83b250c
Showing 1 changed file with 65 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import { Meta, StoryObj } from '@storybook/react';
import { TaskGroups } from '@/activities/tasks/components/TaskGroups';
import { MultipleFiltersDropdownButton } from '@/object-record/object-filter-dropdown/components/MultipleFiltersDropdownButton';
import { ObjectFilterDropdownScope } from '@/object-record/object-filter-dropdown/scopes/ObjectFilterDropdownScope';
import { ObjectFilterDropdownComponentInstanceContext } from '@/object-record/object-filter-dropdown/states/contexts/ObjectFilterDropdownComponentInstanceContext';
import { useRecordTableStates } from '@/object-record/record-table/hooks/internal/useRecordTableStates';
import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
import { availableFilterDefinitionsComponentState } from '@/views/states/availableFilterDefinitionsComponentState';
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext';
import { within } from '@storybook/test';
import { useSetRecoilState } from 'recoil';
import { ComponentDecorator } from 'twenty-ui';
import { FieldMetadataType } from '~/generated/graphql';
import { IconsProviderDecorator } from '~/testing/decorators/IconsProviderDecorator';
Expand All @@ -25,6 +30,53 @@ const meta: Meta<typeof MultipleFiltersDropdownButton> = {
instanceId,
);

const { tableColumnsState } = useRecordTableStates(instanceId);

const setTableColumns = useSetRecoilState(tableColumnsState);

setTableColumns([
{
fieldMetadataId: '1',
iconName: 'IconUser',
label: 'Text',
type: FieldMetadataType.Text,
isVisible: true,
metadata: {
fieldName: 'text',
},
} as ColumnDefinition<any>,
{
fieldMetadataId: '2',
iconName: 'Icon123',
label: 'Email',
type: FieldMetadataType.Email,
isVisible: true,
metadata: {
fieldName: 'email',
},
} as ColumnDefinition<any>,
{
fieldMetadataId: '3',
iconName: 'IconNumber',
label: 'Number',
type: FieldMetadataType.Number,
isVisible: true,
metadata: {
fieldName: 'number',
},
} as ColumnDefinition<any>,
{
fieldMetadataId: '4',
iconName: 'IconCalendar',
label: 'Date',
type: FieldMetadataType.DateTime,
isVisible: true,
metadata: {
fieldName: 'date',
},
} as ColumnDefinition<any>,
]);

setAvailableFilterDefinitions([
{
fieldMetadataId: '1',
Expand Down Expand Up @@ -52,11 +104,19 @@ const meta: Meta<typeof MultipleFiltersDropdownButton> = {
},
]);
return (
<ViewComponentInstanceContext.Provider value={{ instanceId }}>
<ObjectFilterDropdownScope filterScopeId={instanceId}>
<Story />
</ObjectFilterDropdownScope>
</ViewComponentInstanceContext.Provider>
<ObjectFilterDropdownComponentInstanceContext.Provider
value={{ instanceId }}
>
<RecordTableScopeInternalContext.Provider
value={{ scopeId: instanceId, onColumnsChange: () => {} }}
>
<ViewComponentInstanceContext.Provider value={{ instanceId }}>
<ObjectFilterDropdownScope filterScopeId={instanceId}>
<Story />
</ObjectFilterDropdownScope>
</ViewComponentInstanceContext.Provider>
</RecordTableScopeInternalContext.Provider>
</ObjectFilterDropdownComponentInstanceContext.Provider>
);
},
ObjectMetadataItemsDecorator,
Expand Down

0 comments on commit 83b250c

Please sign in to comment.