The tests were broken. It turns out that it is not easy to mock two
apolloClients as apollo only provides "MockedProvider" component to mock
apollo in tests.
MockedProvider Api does not allow us to mock on client level.
For now, I'm defaulting to the base ApolloClient in test mode to avoid
the issue
When writing to the normalized cache (record), it's crucial to use _refs
for relationships to avoid many problems. Essentially, we only deal with
level 0 and generate all fields to be comfortable with their defaults.
When writing in queries (which should be very rare, the only cases are
prefetch and the case of activities due to the nested query; I've
reduced this to a single file for activities
usePrepareFindManyActivitiesQuery 🙂), it's important to use queryFields
to avoid bugs. I've implemented them on the side of query generation and
record generation.
When doing an updateOne / createOne, etc., it's necessary to distinguish
between optimistic writing (which we actually want to do with _refs) and
the server response without refs. This allows for a clean write in the
optimistic cache without worrying about nesting (as the first point).
To simplify the whole activities part, write to the normalized cache
first. Then, base queries on it in an idempotent manner. This way,
there's no need to worry about the current page or action. The
normalized cache is up-to-date, so I update the queries. Same idea as
for optimisticEffects, actually.
Finally, I've triggered optimisticEffects rather than the manual update
of many queries.
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
* default value boolean fixed
* fixed creation, fixed updating a value to false
* fixed default value for default value if boolean
* fixed tests
---------
Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
* feat: wip refactor default-value
* feat: health check to migrate default value
* fix: tests
* fix: refactor defaultValue to make it more clean
* fix: unit tests
* fix: front-end default value
* feat: find duplicate objects backend init
* refactor: move duplicate criteria to constants
* fix: correct constant usage after type change
* feat: skip query generation in case its not necessary
* feat: filter out existing duplicate
* feat: FE queries and hooks
* feat: show duplicates on FE
* refactor: should-skip-query moved to workspace utils
* refactor: naming improvements
* refactor: current record typings/parsing improvements
* refactor: throw error if existing record not found
* fix: domain -> domainName duplicate criteria
* refactor: fieldNames -> columnNames
* docs: add explanation to duplicate criteria collection
* feat: add person linkedinLinkUrl as duplicate criteria
* feat: throw early when bot id and data are empty
* refactor: trying to improve readability of filter criteria query
* refactor: naming improvements
* refactor: remove shouldSkipQuery
* feat: resolve empty array in case of empty filter
* feat: hide whole section in case of no duplicates
* feat: FE display list the same way as relations
* test: basic unit test coverage
* Refactor Record detail section front
* Use Create as input argument of findDuplicates
* Improve coverage
* Fix
---------
Co-authored-by: Charles Bochet <charles@twenty.com>
* Add computed field to workspace entity
* Add activationStatus to front requests
* Update Selector
* Use activation status
* Stop using selector for mock values
* Remove isCurrentWorkspaceActiveSelector
* Use activation status
* Fix typo
* Use activation status
* Create hook for sign in up navigate
* Update hook to handle profile creation
* Use varaible
* Use more readable boolean function
* feat: display record identifier field as first column in table
& forbid hiding and moving record identifier column
Closes#3303
* refactor: add availableTableColumnKeysSelectorScopeMap
* feat: show plus icon button for label identifier column and dropdown menu for other columns
* fix: use label identifier field value in RecordShowPage title
* refactor: remove availableColumnKeys selector
* refactor: review - compute label identifier logic in mapViewFieldsToColumnDefinitions + remove selectors
* fix: several fixes
* fix: fix board fields isVisible
* fix: fix board fields reordering
* fix: more board fields fixes
* fix: fix hiddenTableColumnsSelectorScopeMap
- Created addRecordInCache to inject a record in Apollo cache and inject single read query on this record
- Created createOneRecordInCache and createManyRecordsInCache that uses this addRecordInCache
- Created useOpenCreateActivityDrawerV2 hook to create an activity in cache and inject it into all other relevant requests in the app before opening activity drawer
- Refactored DEFAULT_SEARCH_REQUEST_LIMIT constant and hardcoded arbitrary request limits
- Added Apollo dev logs to see errors in the console when manipulating cache
* Fetch messages with hard coded thread id
* Fix test
* Use first workspace member or person names
---------
Co-authored-by: Thomas Trompette <thomast@twenty.com>
* perf: apply record optimistic effects with cache.modify on mutation
Closes#3509
* refactor: return early when created records do not match filter
* fix: fix id generation on record creation
* fix: comment filtering behavior on record creation
* Fixed typing error
* refactor: review - use ??
* refactor: review - add variables in readFieldValueToSort
* docs: review - add comments for variables.first in triggerUpdateRecordOptimisticEffect
* refactor: review - add intermediary variable for 'not' filter in useMultiObjectSearchMatchesSearchFilterAndToSelectQuery
* refactor: review - add filter utils
* fix: fix tests
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
* feat: display label identifier table cell as chip with link to RecordShowPage
Closes#3502
* Fix test
---------
Co-authored-by: Charles Bochet <charles@twenty.com>
* feat: set field as custom object label identifier in Object Detail
Closes#3302
* feat: prevent disabling Object label identitifer field in back-end
* refactor: review - extract isLabelIdentifier variable
* feat: add link to relation filtered table in Record Show Page
Closes#3125
* refactor: use generateFindManyRecordsQuery for optimization
* Fixes from review
* Minor fixes
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
* WIP
* Finished cleaning favorites create, update, delete on record show page
* Fixed context menu favorite
* Fixed relation field bug
* Fix from review
* Review
---------
Co-authored-by: Charles Bochet <charles@twenty.com>
* fix: display label identifier field input in Show Page
Fixes#3003
* Cleaned a bit after comments
---------
Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
* Add Enrich to frontend
* Naive backend implementation
* Add work email check
* Rename Enrich to Quick Action
* Refactor logic to a separate service
* Refacto to separate IntelligenceService
* Small fixes
* Missing Break statement
* Address PR comments
* Create company interface
* Improve edge case handling
* Use httpService instead of Axios
* Fix server tests