-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added parallel code path to set new record sorts state #10345
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState'; | ||
import { filterSortableFieldMetadataItems } from '@/object-metadata/utils/filterSortableFieldMetadataItems'; | ||
import { selectorFamily } from 'recoil'; | ||
import { isDefined } from 'twenty-shared'; | ||
|
||
export const availableFieldMetadataItemsForSortFamilySelector = selectorFamily({ | ||
key: 'availableFieldMetadataItemsForSortFamilySelector', | ||
get: | ||
({ objectMetadataItemId }: { objectMetadataItemId: string }) => | ||
({ get }) => { | ||
const objectMetadataItems = get(objectMetadataItemsState); | ||
|
||
const objectMetadataItem = objectMetadataItems.find( | ||
(item) => item.id === objectMetadataItemId, | ||
); | ||
|
||
if (!isDefined(objectMetadataItem)) { | ||
return []; | ||
} | ||
|
||
const availableFieldMetadataItemsForSort = | ||
objectMetadataItem.fields.filter(filterSortableFieldMetadataItems); | ||
|
||
return availableFieldMetadataItemsForSort; | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { SORTABLE_FIELD_METADATA_TYPES } from '@/object-metadata/constants/SortableFieldMetadataTypes'; | ||
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem'; | ||
|
||
export const filterSortableFieldMetadataItems = (field: FieldMetadataItem) => { | ||
const isSystemField = field.isSystem; | ||
const isFieldActive = field.isActive; | ||
|
||
const isFieldTypeSortable = SORTABLE_FIELD_METADATA_TYPES.includes( | ||
field.type, | ||
); | ||
|
||
return !isSystemField && isFieldActive && isFieldTypeSortable; | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { ObjectSortDropdownComponentInstanceContext } from '@/object-record/object-sort-dropdown/states/context/ObjectSortDropdownComponentInstanceContext'; | ||
import { createComponentStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentStateV2'; | ||
|
||
export const isSortSelectedComponentState = createComponentStateV2<boolean>({ | ||
key: 'isSortSelectedComponentState', | ||
defaultValue: false, | ||
componentInstanceContext: ObjectSortDropdownComponentInstanceContext, | ||
}); | ||
export const isRecordSortDirectionMenuUnfoldedComponentState = | ||
createComponentStateV2<boolean>({ | ||
key: 'isRecordSortDirectionMenuUnfoldedComponentState', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: i'm just wondering if the naming should be even more "scoped": isRecordSortDirectionDropdownMenuUnfoldedComponentState There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes sure |
||
defaultValue: false, | ||
componentInstanceContext: ObjectSortDropdownComponentInstanceContext, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { ObjectSortDropdownComponentInstanceContext } from '@/object-record/object-sort-dropdown/states/context/ObjectSortDropdownComponentInstanceContext'; | ||
import { createComponentStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentStateV2'; | ||
|
||
export const isSortDirectionMenuUnfoldedComponentState = | ||
export const isRecordSortSelectedComponentState = | ||
createComponentStateV2<boolean>({ | ||
key: 'isSortDirectionMenuUnfoldedComponentState', | ||
key: 'isRecordSortSelectedComponentState', | ||
defaultValue: false, | ||
componentInstanceContext: ObjectSortDropdownComponentInstanceContext, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { ObjectSortDropdownComponentInstanceContext } from '@/object-record/object-sort-dropdown/states/context/ObjectSortDropdownComponentInstanceContext'; | ||
import { RecordSort } from '@/object-record/record-sort/types/RecordSort'; | ||
import { createComponentStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentStateV2'; | ||
import { Sort } from '../types/Sort'; | ||
|
||
export const onSortSelectComponentState = createComponentStateV2< | ||
((sort: Sort) => void) | undefined | ||
((sort: RecordSort) => void) | undefined | ||
>({ | ||
key: 'onSortSelectComponentState', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: Consider adding a more descriptive key that includes 'record' to match the new type (e.g., 'onRecordSortSelectComponentState') |
||
defaultValue: undefined, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { ObjectSortDropdownComponentInstanceContext } from '@/object-record/object-sort-dropdown/states/context/ObjectSortDropdownComponentInstanceContext'; | ||
import { SortDirection } from '@/object-record/object-sort-dropdown/types/SortDirection'; | ||
import { RecordSortDirection } from '@/object-record/record-sort/types/RecordSortDirection'; | ||
import { createComponentStateV2 } from '@/ui/utilities/state/component-state/utils/createComponentStateV2'; | ||
|
||
export const selectedSortDirectionComponentState = | ||
createComponentStateV2<SortDirection>({ | ||
key: 'selectedSortDirectionComponentState', | ||
export const selectedRecordSortDirectionComponentState = | ||
createComponentStateV2<RecordSortDirection>({ | ||
key: 'selectedRecordSortDirectionComponentState', | ||
defaultValue: 'asc', | ||
componentInstanceContext: ObjectSortDropdownComponentInstanceContext, | ||
}); |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
import { SortDirection } from './SortDirection'; | ||
|
||
export type SortDefinition = { | ||
fieldMetadataId: string; | ||
label: string; | ||
iconName: string; | ||
getOrderByTemplate?: (direction: SortDirection) => any[]; | ||
}; |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Using array index as key prop may cause issues with React reconciliation if items are reordered. Consider using sortDirection as the key instead