-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor kanban new card creation (#8339)
On the kanban page, the record creation was changed a few weeks ago to enable creation on top / bottom of the columns. However, this introduced a glitch (missing background opacity). While fixing it, I have refactored the component structure to: - separate "New" button from the Empty record card
- Loading branch information
1 parent
be8141c
commit 84b0b78
Showing
7 changed files
with
141 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...ct-record/record-board/record-board-column/components/RecordBoardColumnNewOpportunity.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
import { useAddNewCard } from '@/object-record/record-board/record-board-column/hooks/useAddNewCard'; | ||
import { recordBoardNewRecordByColumnIdSelector } from '@/object-record/record-board/states/selectors/recordBoardNewRecordByColumnIdSelector'; | ||
import { SingleEntitySelect } from '@/object-record/relation-picker/components/SingleEntitySelect'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
const StyledCompanyPickerContainer = styled.div` | ||
align-items: center; | ||
align-self: baseline; | ||
background-color: ${({ theme }) => theme.background.primary}; | ||
border: none; | ||
border-radius: ${({ theme }) => theme.border.radius.sm}; | ||
color: ${({ theme }) => theme.font.color.tertiary}; | ||
cursor: pointer; | ||
display: flex; | ||
gap: ${({ theme }) => theme.spacing(1)}; | ||
`; | ||
|
||
export const RecordBoardColumnNewOpportunity = ({ | ||
columnId, | ||
position, | ||
}: { | ||
columnId: string; | ||
position: 'last' | 'first'; | ||
}) => { | ||
const newRecord = useRecoilValue( | ||
recordBoardNewRecordByColumnIdSelector({ | ||
familyKey: columnId, | ||
scopeId: columnId, | ||
}), | ||
); | ||
const { handleCreateSuccess, handleEntitySelect } = useAddNewCard(); | ||
|
||
return ( | ||
<> | ||
{newRecord.isCreating && newRecord.position === position && ( | ||
<StyledCompanyPickerContainer> | ||
<SingleEntitySelect | ||
disableBackgroundBlur | ||
onCancel={() => handleCreateSuccess(position, columnId, false)} | ||
onEntitySelected={(company) => | ||
company ? handleEntitySelect(position, company) : null | ||
} | ||
relationObjectNameSingular={CoreObjectNameSingular.Company} | ||
relationPickerScopeId="relation-picker" | ||
selectedRelationRecordIds={[]} | ||
/> | ||
</StyledCompanyPickerContainer> | ||
)} | ||
</> | ||
); | ||
}; |
62 changes: 0 additions & 62 deletions
62
...ord/record-board/record-board-column/components/RecordBoardColumnNewOpportunityButton.tsx
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
.../object-record/record-board/record-board-column/components/RecordBoardColumnNewRecord.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { RecordBoardCard } from '@/object-record/record-board/record-board-card/components/RecordBoardCard'; | ||
import { useAddNewCard } from '@/object-record/record-board/record-board-column/hooks/useAddNewCard'; | ||
import { recordBoardNewRecordByColumnIdSelector } from '@/object-record/record-board/states/selectors/recordBoardNewRecordByColumnIdSelector'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
export const RecordBoardColumnNewRecord = ({ | ||
columnId, | ||
position, | ||
}: { | ||
columnId: string; | ||
position: 'first' | 'last'; | ||
}) => { | ||
const newRecord = useRecoilValue( | ||
recordBoardNewRecordByColumnIdSelector({ | ||
familyKey: columnId, | ||
scopeId: columnId, | ||
}), | ||
); | ||
const { handleCreateSuccess } = useAddNewCard(); | ||
|
||
return ( | ||
<> | ||
{newRecord.isCreating && newRecord.position === position && ( | ||
<RecordBoardCard | ||
isCreating={true} | ||
onCreateSuccess={() => handleCreateSuccess(position)} | ||
position={position} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters