-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
record board card creation using pending record id #9236
record board card creation using pending record id #9236
Conversation
); | ||
|
||
return ( | ||
<FieldInput |
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.
not sure if we want this or inlineCells to be opened in edit mode.
@ehconitin I've tried to test the behavior but fixing the conflicts is not completely straightforward. Could you fix them first? Thank you! |
Taking another look |
import { RecordBoardContext } from '../contexts/RecordBoardContext'; | ||
import { recordBoardPendingRecordIdByColumnComponentFamilyState } from '../states/recordBoardPendingRecordIdByColumnComponentFamilyState'; | ||
|
||
export const useUpsertBoardOpportunityRecord = (recordBoardId: 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.
This looks duplicated with useUpsertBoardRecord below. I'm not fully against it if it's hard to merge them (I would prefer two clear hooks over one which is hard to maintin) but I feel we could try to merge them.
Long term, we plan to address record creation through the RightDrawer so I would not over invest on this area. The abstract reason why for "opportunity" we need to fill the "company" is that "company" would be a REQUIRED field on opportunity. Right now it's hard coded for opportunity and it's fine keeping it like this as long as we haven't introduced both required relations and creation in Right Drawer.
So I would not over engineer this and why not just making company optional in useUpsertBoardRecord for now and merge both hooks
); | ||
|
||
const [pendingRecord] = useRecoilState( | ||
recordBoardPendingRecordIdByColumnState(columnId), |
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 should be a componentState
}} | ||
> | ||
<RecordInlineCellEditMode> | ||
<RecordBoardCellFieldInput /> |
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 is much better
import { useContext } from 'react'; | ||
import { useRecoilCallback } from 'recoil'; | ||
|
||
export const RecordBoardCellFieldInput = () => { |
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 would name this component differently. I feel it's RecordBoardPendingTextIdentifierFieldInput
|
||
const handleEnter: FieldInputEvent = (persistField) => { | ||
persistField(); | ||
onUpsertRecord({ |
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.
shouldn't we call useUpsertBoardRecord here?
Looks like the main challenge:
- if we wouldn't have the opporunity (+ company case), we only upsert the record once the name is filled (so calling useUpsertBoardRecord here), I think that's what's done on the RecordTable
- but as we need to persist the company too, you are persisting the record sooner and only updating it here now.
I would try to call useUpsertBoardRecord (so no persist it sooner), and instead for the opportunity.company case, I would write in the recordStore { recordId: pendingRecordId, company: xxx, position: xxx } in useCreateNewBoardRecord
It should work!
@@ -166,7 +154,9 @@ export const RecordBoardColumnHeader = () => { | |||
<LightIconButton | |||
accent="tertiary" | |||
Icon={IconPlus} | |||
onClick={() => handleNewButtonClick('first', isOpportunity)} | |||
onClick={() => | |||
createNewBoardRecord(columnDefinition.id, 'first') |
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 is right
onCancel={() => createNewBoardRecord(columnId, position)} | ||
onRecordSelected={(company) => { | ||
if (isDefined(company)) { | ||
upsertBoardOpportunityRecord(columnId, company); |
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.
so I would not upsert here but createNewBoardRecord + write in recordStore instead.
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 is much better. I have left one important comment:
- on Add New click, let's not upsert but always call createNewBoardRecord (set pendingRecordId + write in record store if necessary)
- on TextIdentfier submit, lets call upsert
@ehconitin I'm closing the PR to keep the history clean, I'm happy to re-review it once ready / help on this one if needed :) |
#8941 (review)