You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/10/11 01:50:29 UTC
[GitHub] [incubator-devlake] mintsweet commented on a diff in pull request #3297: fix(config-ui): transformation not updating correctly when switching boards
mintsweet commented on code in PR #3297:
URL: https://github.com/apache/incubator-devlake/pull/3297#discussion_r991746741
##########
config-ui/src/pages/configure/settings/jira.jsx:
##########
@@ -177,58 +177,35 @@ export default function JiraSettings(props) {
}, [typeMappingAll, onSettingsChange, configuredBoard?.id])
useEffect(() => {
- if (typeMappingBug && typeMappingIncident && typeMappingRequirement) {
- const RequirementMappings =
- typeMappingRequirement !== ''
- ? typeMappingRequirement.map((r) =>
- createTypeMapObject(r.value, MAPPING_TYPES.Requirement)
- )
- : []
- const IncidentMappings =
- typeMappingIncident !== ''
- ? typeMappingIncident.map((i) =>
- createTypeMapObject(i.value, MAPPING_TYPES.Incident)
- )
- : []
- const BugMappings =
- typeMappingBug !== ''
- ? typeMappingBug.map((b) =>
- createTypeMapObject(b.value, MAPPING_TYPES.Bug)
- )
- : []
- const CombinedMappings = [
- ...RequirementMappings,
- ...IncidentMappings,
- ...BugMappings
- ].filter((m) => m !== null)
- const MappingTypeObjects = CombinedMappings.reduce((pV, cV) => {
- return { ...cV, ...pV }
- }, {})
- setTypeMappingAll(MappingTypeObjects)
- console.log(
- '>> INCIDENT TYPE MAPPING OBJECTS....',
- RequirementMappings,
- IncidentMappings,
- BugMappings
- )
- console.log('>> ALL MAPPINGS COMBINED...', CombinedMappings)
- console.log(
- '>> FINAL MAPPING OBJECTS FOR API REQUEST...',
- MappingTypeObjects
- )
- }
- }, [typeMappingBug, typeMappingIncident, typeMappingRequirement])
+ setTypeMappingAll((ma) => ({
+ ...ma,
+ ...(typeMappingBug || [])
+ .map((r) => createTypeMapObject(r.value, MAPPING_TYPES.Bug))
+ .reduce((c, p) => ({ ...c, ...p }), {})
+ }))
+ }, [typeMappingBug])
useEffect(() => {
- console.log('>> CONN SETTINGS OBJECT ', connection)
- if (connection && connection.id) {
- // Parse Type Mappings (V2)
- // setStatusMappings([])
- }
- }, [connection])
+ setTypeMappingAll((ma) => ({
+ ...ma,
+ ...(typeMappingIncident || [])
+ .map((r) => createTypeMapObject(r.value, MAPPING_TYPES.Incident))
+ .reduce((c, p) => ({ ...c, ...p }), {})
+ }))
+ }, [typeMappingIncident])
+
+ useEffect(() => {
+ setTypeMappingAll((ma) => ({
+ ...ma,
+ ...(typeMappingRequirement || [])
+ .map((r) => createTypeMapObject(r.value, MAPPING_TYPES.Requirement))
+ .reduce((c, p) => ({ ...c, ...p }), {})
+ }))
+ }, [typeMappingRequirement])
Review Comment:
Independent dependencies allow **react** to distinguish which needs to be recalculated. If merged, individual changes will cause the whole to be recalculated, wasting performance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org