-
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.
fix: make changes regarding comments
- Loading branch information
Showing
19 changed files
with
350 additions
and
186 deletions.
There are no files selected for viewing
37 changes: 0 additions & 37 deletions
37
...ty-front/src/modules/object-record/record-group/components/RecordGroupContextProvider.tsx
This file was deleted.
Oops, something went wrong.
27 changes: 20 additions & 7 deletions
27
...nty-front/src/modules/object-record/record-group/hooks/useCurrentRecordGroupDefinition.ts
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 |
---|---|---|
@@ -1,24 +1,37 @@ | ||
import { useCurrentRecordGroupId } from '@/object-record/record-group/hooks/useCurrentRecordGroupId'; | ||
import { RecordGroupContext } from '@/object-record/record-group/states/context/RecordGroupContext'; | ||
import { hasRecordGroupDefinitionsComponentSelector } from '@/object-record/record-group/states/hasRecordGroupDefinitionsComponentSelector'; | ||
import { recordGroupDefinitionsComponentState } from '@/object-record/record-group/states/recordGroupDefinitionsComponentState'; | ||
import { recordGroupDefaultId } from '@/object-record/record-group/types/RecordGroupDefinition'; | ||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; | ||
import { useMemo } from 'react'; | ||
import { useContext, useMemo } from 'react'; | ||
|
||
export const useCurrentRecordGroupDefinition = (recordTableId?: string) => { | ||
const currentRecordGroupId = useCurrentRecordGroupId(); | ||
const context = useContext(RecordGroupContext); | ||
|
||
const hasRecordGroups = useRecoilComponentValueV2( | ||
hasRecordGroupDefinitionsComponentSelector, | ||
recordTableId, | ||
); | ||
|
||
const recordGroupDefinitions = useRecoilComponentValueV2( | ||
recordGroupDefinitionsComponentState, | ||
recordTableId, | ||
); | ||
|
||
const recordGroupDefinition = useMemo(() => { | ||
if (currentRecordGroupId === recordGroupDefaultId) { | ||
if (!hasRecordGroups) { | ||
return undefined; | ||
} | ||
|
||
return recordGroupDefinitions.find(({ id }) => id === currentRecordGroupId); | ||
}, [currentRecordGroupId, recordGroupDefinitions]); | ||
if (!context) { | ||
throw new Error( | ||
'useCurrentRecordGroupDefinition must be used within a RecordGroupContextProvider.', | ||
); | ||
} | ||
|
||
return recordGroupDefinitions.find( | ||
({ id }) => id === context.recordGroupId, | ||
); | ||
}, [context, hasRecordGroups, recordGroupDefinitions]); | ||
|
||
return recordGroupDefinition; | ||
}; |
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
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
21 changes: 21 additions & 0 deletions
21
...c/modules/object-record/record-group/states/hasRecordGroupDefinitionsComponentSelector.ts
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,21 @@ | ||
import { recordGroupDefinitionsComponentState } from '@/object-record/record-group/states/recordGroupDefinitionsComponentState'; | ||
|
||
import { createComponentSelectorV2 } from '@/ui/utilities/state/component-state/utils/createComponentSelectorV2'; | ||
import { ViewComponentInstanceContext } from '@/views/states/contexts/ViewComponentInstanceContext'; | ||
|
||
export const hasRecordGroupDefinitionsComponentSelector = | ||
createComponentSelectorV2<boolean>({ | ||
key: 'hasRecordGroupDefinitionsComponentSelector', | ||
componentInstanceContext: ViewComponentInstanceContext, | ||
get: | ||
({ instanceId }) => | ||
({ get }) => { | ||
const recordGroupDefinitions = get( | ||
recordGroupDefinitionsComponentState.atomFamily({ | ||
instanceId, | ||
}), | ||
); | ||
|
||
return recordGroupDefinitions.length > 0; | ||
}, | ||
}); |
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
19 changes: 19 additions & 0 deletions
19
...nty-front/src/modules/object-record/record-table/components/RecordTableRecordGroupRow.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,19 @@ | ||
import { useCurrentRecordGroupId } from '@/object-record/record-group/hooks/useCurrentRecordGroupId'; | ||
import { RecordTableRow } from '@/object-record/record-table/record-table-row/components/RecordTableRow'; | ||
import { tableRowIdsByGroupComponentFamilyState } from '@/object-record/record-table/states/tableRowIdsByGroupComponentFamilyState'; | ||
import { useRecoilComponentFamilyValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentFamilyValueV2'; | ||
|
||
export const RecordTableRecordGroupRows = () => { | ||
const recordGroupId = useCurrentRecordGroupId(); | ||
|
||
const recordGroupRowIds = useRecoilComponentFamilyValueV2( | ||
tableRowIdsByGroupComponentFamilyState, | ||
recordGroupId, | ||
); | ||
|
||
return recordGroupRowIds.map((recordId, rowIndex) => { | ||
return ( | ||
<RecordTableRow key={recordId} recordId={recordId} rowIndex={rowIndex} /> | ||
); | ||
}); | ||
}; |
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
Oops, something went wrong.