-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Current workspace member filter (#8016) #9182
base: main
Are you sure you want to change the base?
Current workspace member filter (#8016) #9182
Conversation
This reverts commit d86416a.
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.
PR Summary
This PR adds filtering functionality based on the current workspace member across relation fields, similar to Linear's "Assigned to me" feature.
- Added new
FilterValueDependencies
interface anduseFilterValueDependencies
hook in/packages/twenty-front/src/modules/object-record/record-filter/
to manage current workspace member context - Introduced
ObjectFilterDropdownRecordPinnedItems
component and "Me" filter option withCURRENT_WORKSPACE_MEMBER_SELECTABLE_ITEM_ID
constant - Added
relationFilterValueSchema
with Zod validation for handling workspace member selection state - Modified filter computation logic in
computeContextStoreFilters
andcomputeViewRecordGqlOperationFilter
to support current member filtering - Updated multiple hooks and components to propagate
filterValueDependencies
through the filtering system
25 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile
const queryFilter = computeContextStoreFilters( | ||
contextStoreTargetedRecordsRule, | ||
contextStoreFilters, | ||
objectMetadataItem, | ||
filterValueDependencies, | ||
); |
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.
logic: filterValueDependencies is now required by computeContextStoreFilters but no error handling if dependencies are undefined
) => { | ||
let queryFilter: RecordGqlOperationFilter | undefined; | ||
|
||
if (contextStoreTargetedRecordsRule.mode === 'exclusion') { | ||
queryFilter = makeAndFilterVariables([ | ||
computeViewRecordGqlOperationFilter( | ||
filterValueDependencies, | ||
contextStoreFilters, | ||
objectMetadataItem?.fields ?? [], |
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: optional chaining on fields is redundant since empty array is already the fallback
@@ -39,6 +42,7 @@ export const computeContextStoreFilters = ( | |||
}, | |||
} | |||
: computeViewRecordGqlOperationFilter( | |||
filterValueDependencies, | |||
contextStoreFilters, | |||
objectMetadataItem?.fields ?? [], |
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: optional chaining on fields is redundant since empty array is already the fallback
onSelectChange={(newCheckedValue) => { | ||
props.onChange(selectableItem, newCheckedValue); | ||
}} |
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: ensure onChange handler is memoized in parent component to prevent unnecessary re-renders
if (!isDefined(objectNameSingular)) { | ||
throw new Error('objectNameSingular is not defined'); | ||
} |
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.
logic: Duplicate check for objectNameSingular - already checked on line 79
padding-left: 0px; | ||
padding-right: 0px; |
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: padding values should use theme.spacing() for consistency with other padding values
@@ -22,11 +23,14 @@ export const useQueryVariablesFromActiveFieldsOfViewOrDefaultView = ({ | |||
|
|||
const isJsonFilterEnabled = useIsFeatureEnabled('IS_JSON_FILTER_ENABLED'); | |||
|
|||
const { filterValueDependencies } = useFilterValueDependencies(); |
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: filterValueDependencies is destructured but not type-checked. Consider adding type annotation for better type safety.
const { selectedRecordIds } = relationFilterValueSchema | ||
.catch({ | ||
isCurrentWorkspaceMemberSelected: false, | ||
selectedRecordIds: [], | ||
}) | ||
.parse(viewFilterUsedInDropdown?.value); |
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: catch block provides default values but swallows parsing errors silently - consider logging parse errors for debugging
isCurrentWorkspaceMemberSelected: z.boolean(), | ||
selectedRecordIds: z.array(z.string()), |
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: Consider adding a default value of false for isCurrentWorkspaceMemberSelected to handle cases where it's not provided.
.pipe( | ||
z.object({ | ||
isCurrentWorkspaceMemberSelected: z.boolean(), | ||
selectedRecordIds: z.array(z.string()), |
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: Consider adding validation for non-empty selectedRecordIds array when isCurrentWorkspaceMemberSelected is false to prevent invalid states.
If this looks good, I can
|
New branch based on feedback in PR #8950 and issue #8016