-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Redirect to select option creation when no result #14460
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
base: main
Are you sure you want to change the base?
Conversation
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.
Greptile Summary
This PR implements the ability to add new multi-select options on-the-fly, addressing issue #13877 to improve the user experience from a cumbersome 7-step process to a streamlined workflow similar to AirTable's functionality.
The implementation works by adding a "No results" + "Add option" interface in the filter dropdown that appears when users search for non-existent options. When clicked, it navigates to the field settings page with the new option name passed via React Router's location state, where a useEffect
hook automatically detects and creates the new option.
Key changes include:
- New Component:
ObjectFilterDropdownCreateNewOption
displays the "Add option" interface with permission checks - Enhanced Existing Components:
ObjectFilterDropdownOptionSelect
now conditionally renders the new option creation component when no results are found - Automatic Option Creation:
SettingsDataModelFieldSelectForm
detects new options via location state and automatically adds them to the form - Utility Enhancement:
generateNewSelectOption
now accepts an optional name parameter for custom option labels - Code Cleanup: Minor whitespace cleanup in
useUpdateOneFieldMetadataItem
The solution maintains existing permissions through the DATA_MODEL flag and integrates with the current settings infrastructure while providing a seamless user experience for dynamic option creation.
PR Description Notes:
- Contains a typo: "fix:Ability" should be "fix: Ability" (missing space after colon)
- Issue reference format could be improved: "Issues:#13877" should be "Issues: #13877"
Confidence score: 3/5
- This PR has moderate risk due to several implementation concerns that could cause issues in production
- Score reflects reliance on potentially unreliable navigation state mechanism and inconsistent coding patterns that don't follow established conventions
- Pay close attention to the navigation state handling in
SettingsDataModelFieldSelectForm.tsx
and the naming conventions inObjectFilterDropdownCreateNewOption.tsx
Context used:
Rule - Extract utility functions like 'includesExpectedScopes' to utils modules instead of keeping them in service classes. (link)
Rule - Error messages should be user-friendly rather than technical. Avoid technical jargon like 'missing scopes' in user-facing error messages. (link)
Context - Avoid using abbreviations in the codebase; prefer full descriptive names, e.g., use 'record' instead of 'r'. (link)
Context - Use 'type' instead of 'interface' for type definitions in the project. (link)
Context - When using styled components, prefer to use theme spacing directly in calculations instead of wrapping them in template literals. (link)
Context - Use TypeScript interface definitions for component props to enhance maintainability. (link)
Context - Always consider adding tests for new functionality, especially for edge cases like empty responses. (link)
5 files reviewed, 6 comments
...ules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
Outdated
Show resolved
Hide resolved
...ules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
Outdated
Show resolved
Hide resolved
...modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx
Outdated
Show resolved
Hide resolved
...modules/object-record/object-filter-dropdown/components/ObjectFilterDropdownOptionSelect.tsx
Outdated
Show resolved
Hide resolved
...ules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCreateNewOption.tsx
Outdated
Show resolved
Hide resolved
...ules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCreateNewOption.tsx
Outdated
Show resolved
Hide resolved
🚀 Preview Environment Ready! Your preview environment is available at: http://bore.pub:36863 This environment will automatically shut down when the PR is closed or after 5 hours. |
...ules/object-record/object-filter-dropdown/components/ObjectFilterDropdownCreateNewOption.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-metadata/hooks/useUpdateOneFieldMetadataItem.ts
Show resolved
Hide resolved
...ules/settings/data-model/fields/forms/select/components/SettingsDataModelFieldSelectForm.tsx
Outdated
Show resolved
Hide resolved
@FelixMalfait I’ve run all the tests and they all passed and remove useEffect— can you check it now ? |
Hey @animesh65432 could you please merge main and fix conclits? The tests can't run otherwise. I haven't tested the PR yet it was just preliminary comments. Thanks! |
@FelixMalfait check it now |
I am taking over! The idea was correct, just in the wrong place |
@ehconitin can i do it |
sorry can i fix it |
@animesh65432 don't be! Yes, of course you can try! I will wait on the push till tomorrow |
@greptileai trigger |
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.
Greptile Summary
This review covers only the changes made since the last review, not the entire PR. The latest changes focus on implementing a comprehensive solution for adding multi-select options on-the-fly, addressing issue #13877. The implementation allows users to create new select options directly from field inputs without navigating through the lengthy settings workflow.
The key architectural change involves updating the navigationMemorizedUrlState
from a simple string to an object structure containing both a url
property and an optional isAddingFieldOption
boolean flag. This enables the application to track navigation context when users are redirected to create new options and ensures they return to their original location afterward.
The feature is implemented across multiple layers: input components (SelectFieldInput
, MultiSelectFieldInput
, SelectInput
, MultiSelectInput
) now accept an optional onAddSelectOption
prop that triggers navigation to the field edit page with the desired option name passed via router state. The SettingsDataModelFieldSelectForm
component automatically detects this state and creates a new option using the existing generateNewSelectOption
utility. The SettingsObjectFieldEdit
component handles the return navigation by checking the isAddingFieldOption
flag and redirecting users back to their memorized URL.
A new AddSelectOptionMenuItem
component provides the UI for creating options when no search results are found. The useUpdateOneFieldMetadataItem
hook was enhanced to refresh related views after field updates, ensuring consistency across the application. All changes maintain backward compatibility through optional props and follow the established patterns in the codebase.
Confidence score: 4/5
- This PR significantly improves user experience but introduces complex navigation state management that requires careful testing
- Score reflects well-structured implementation following existing patterns, but the complexity of navigation flow between multiple components needs thorough validation
- Pay close attention to the navigation state management in
SettingsObjectFieldEdit.tsx
and ensure all navigation flows work correctly across different user paths
21 files reviewed, 4 comments
packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx
Outdated
Show resolved
Hide resolved
...t/src/modules/settings/data-model/fields/forms/select/components/AddSelectOptionMenuItem.tsx
Outdated
Show resolved
Hide resolved
...t/src/modules/settings/data-model/fields/forms/select/components/AddSelectOptionMenuItem.tsx
Outdated
Show resolved
Hide resolved
.../modules/object-record/record-field/ui/meta-types/input/components/MultiSelectFieldInput.tsx
Outdated
Show resolved
Hide resolved
|
||
type NavigationMemorizedUrl = { | ||
url: string; | ||
isAddingFieldOption?: boolean; |
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.
I couldn't think of a generic naming here! Any suggestions?
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.
This seems much too specific too be in a NavigationMemorizedUrl
; it doesn't seem like the right approach
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.
Should we use a seperate state for this use case?
We definitely want it to be specific, because we would need to know if we want to navigate to objects field table page or go back to the view?
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.
Ah may be shouldNavigateBackToViewOnSave?
And keep it a diff state?
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.
Agree we should revert everything around this modification including this,
I am struggling to make the form dirty when we navigate to settings on click. |
@ehconitin okay i will try to fix it |
@animesh65432 I dont think its possible without a hacky solution! lets wait for a review from a third person before we make anymore changes to keep PR clean! thanks! |
@ehconitin okay |
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.
Try by creating an independant atom for this
|
||
type NavigationMemorizedUrl = { | ||
url: string; | ||
isAddingFieldOption?: boolean; |
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.
Agree we should revert everything around this modification including this,
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.
The save / cancel buttons should be enabled when we land on the settings page, right now we have to modify something to have save passing from disabled to enabled.
fix:Ability to add a new option for a multi-select on the fly
Issues:#13877