Refator/sorts dropdown (#1568)

* WIP

* Fixed lint

* Ok for sorts

* Fixed on dropdown toggle

* Fix lint
This commit is contained in:
Lucas Bordeau
2023-09-14 01:38:11 +02:00
committed by GitHub
parent a392a81994
commit 8627416d60
55 changed files with 339 additions and 309 deletions

View File

@ -10,29 +10,23 @@ import { BoardOptionsHotkeyScope } from '../types/BoardOptionsHotkeyScope';
import { BoardOptionsDropdown } from './BoardOptionsDropdown';
export type BoardHeaderProps<SortField> = ComponentProps<'div'> & {
export type BoardHeaderProps = ComponentProps<'div'> & {
onStageAdd?: (boardColumn: BoardColumnDefinition) => void;
} & Pick<
ViewBarProps<SortField>,
| 'availableSorts'
| 'defaultViewName'
| 'onViewsChange'
| 'onViewSubmit'
| 'scopeContext'
ViewBarProps,
'defaultViewName' | 'onViewsChange' | 'onViewSubmit' | 'scopeContext'
>;
export function BoardHeader<SortField>({
export function BoardHeader({
onStageAdd,
onViewsChange,
onViewSubmit,
scopeContext,
availableSorts,
defaultViewName,
}: BoardHeaderProps<SortField>) {
}: BoardHeaderProps) {
return (
<RecoilScope SpecificContext={DropdownRecoilScopeContext}>
<ViewBar
availableSorts={availableSorts}
defaultViewName={defaultViewName}
onViewsChange={onViewsChange}
onViewSubmit={onViewSubmit}

View File

@ -27,7 +27,7 @@ export function BoardOptionsDropdown({
/>
}
dropdownHotkeyScope={customHotkeyScope}
dropdownKey={BoardOptionsDropdownKey}
dropdownId={BoardOptionsDropdownKey}
/>
);
}

View File

@ -5,7 +5,7 @@ import { BoardOptionsDropdownKey } from '../types/BoardOptionsDropdownKey';
export function BoardOptionsDropdownButton() {
const { isDropdownButtonOpen, toggleDropdownButton } = useDropdownButton({
key: BoardOptionsDropdownKey,
dropdownId: BoardOptionsDropdownKey,
});
function handleClick() {

View File

@ -126,7 +126,7 @@ export function BoardOptionsDropdownContent({
const { handleFieldVisibilityChange } = useBoardCardFields({ scopeContext });
const { closeDropdownButton } = useDropdownButton({
key: BoardOptionsDropdownKey,
dropdownId: BoardOptionsDropdownKey,
});
useScopedHotkeys(

View File

@ -22,7 +22,6 @@ import {
PipelineStage,
useUpdateOnePipelineProgressStageMutation,
} from '~/generated/graphql';
import { PipelineProgressOrderByWithRelationInput as PipelineProgresses_Order_By } from '~/generated/graphql';
import { useCurrentCardSelected } from '../hooks/useCurrentCardSelected';
import { useSetCardSelected } from '../hooks/useSetCardSelected';
@ -41,7 +40,7 @@ export type EntityBoardProps = {
onEditColumnTitle: (columnId: string, title: string, color: string) => void;
scopeContext: Context<string | null>;
} & Pick<
BoardHeaderProps<PipelineProgresses_Order_By>,
BoardHeaderProps,
'defaultViewName' | 'onViewsChange' | 'onViewSubmit'
>;
@ -142,7 +141,6 @@ export function EntityBoard({
<StyledWrapper>
<StyledBoardHeader
defaultViewName={defaultViewName}
availableSorts={boardOptions.sorts}
onStageAdd={onColumnAdd}
onViewsChange={onViewsChange}
onViewSubmit={onViewSubmit}

View File

@ -1,13 +1,12 @@
import type { ComponentType, Context } from 'react';
import { FilterDefinitionByEntity } from '@/ui/view-bar/types/FilterDefinitionByEntity';
import { SortType } from '@/ui/view-bar/types/interface';
import { SortDefinition } from '@/ui/view-bar/types/SortDefinition';
import { PipelineProgress } from '~/generated/graphql';
import { PipelineProgressOrderByWithRelationInput as PipelineProgresses_Order_By } from '~/generated/graphql';
export type BoardOptions = {
newCardComponent: React.ReactNode;
CardComponent: ComponentType<{ scopeContext: Context<string | null> }>;
filters: FilterDefinitionByEntity<PipelineProgress>[];
sorts: Array<SortType<PipelineProgresses_Order_By>>;
sorts: SortDefinition[];
};