Skip to content
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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

eliasylonen
Copy link
Contributor

New branch based on feedback in PR #8950 and issue #8016

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 and useFilterValueDependencies hook in /packages/twenty-front/src/modules/object-record/record-filter/ to manage current workspace member context
  • Introduced ObjectFilterDropdownRecordPinnedItems component and "Me" filter option with CURRENT_WORKSPACE_MEMBER_SELECTABLE_ITEM_ID constant
  • Added relationFilterValueSchema with Zod validation for handling workspace member selection state
  • Modified filter computation logic in computeContextStoreFilters and computeViewRecordGqlOperationFilter 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

Comment on lines 36 to 41
const queryFilter = computeContextStoreFilters(
contextStoreTargetedRecordsRule,
contextStoreFilters,
objectMetadataItem,
filterValueDependencies,
);
Copy link
Contributor

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 ?? [],
Copy link
Contributor

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 ?? [],
Copy link
Contributor

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

Comment on lines +26 to +28
onSelectChange={(newCheckedValue) => {
props.onChange(selectableItem, newCheckedValue);
}}
Copy link
Contributor

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

Comment on lines 89 to 91
if (!isDefined(objectNameSingular)) {
throw new Error('objectNameSingular is not defined');
}
Copy link
Contributor

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

Comment on lines +8 to +9
padding-left: 0px;
padding-right: 0px;
Copy link
Contributor

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();
Copy link
Contributor

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.

Comment on lines +73 to +78
const { selectedRecordIds } = relationFilterValueSchema
.catch({
isCurrentWorkspaceMemberSelected: false,
selectedRecordIds: [],
})
.parse(viewFilterUsedInDropdown?.value);
Copy link
Contributor

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

Comment on lines +18 to +19
isCurrentWorkspaceMemberSelected: z.boolean(),
selectedRecordIds: z.array(z.string()),
Copy link
Contributor

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()),
Copy link
Contributor

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.

@eliasylonen
Copy link
Contributor Author

If this looks good, I can

  • delete the resolveFilterValue functions and make schemas like relationFilterValueSchema for them instead
  • move value parsing logic to the components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants