-
Notifications
You must be signed in to change notification settings - Fork 975
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
[frontend] Update demographic stixCoreRelationships from entity overview #9637
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #9637 +/- ##
==========================================
- Coverage 65.26% 65.26% -0.01%
==========================================
Files 630 630
Lines 60244 60244
Branches 6760 6757 -3
==========================================
- Hits 39319 39317 -2
- Misses 20925 20927 +2 ☔ View full report in Codecov by Sentry. |
65d188e
to
48c5ccd
Compare
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.
Functionally seems good
const handleClose = () => setOpen(false); | ||
const handleSearch = (term: string) => setSearch(term); | ||
|
||
const data = useLazyLoadQuery<AddThreatActorIndividualDemographicLinesQuery>( |
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.
Why using useLazyLoadQuery
instead of usePreloadedQuery
?
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.
Change to use usePreloadedQuery
.
First you need to prepare the query Ref in a parent componant using useQueryLoading
and then replace useLazyLoadQuery
with usePreloadedQuery
.
variant='inDrawer' | ||
onSubmit={handleSearch} | ||
/> | ||
<div style={{ height: 5 }} /> |
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.
What is the purpose of that div?
useEffect(() => { | ||
refetch({}); | ||
}, [data]); |
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 to understand this useEffect. Why making a refetch every time the result of the query changes? That looks to me pretty close to an infinite loop
const [currentTargets, setCurrentTargets] = useState<string[]>(initialTargets); | ||
|
||
const updateDelete = (store: RecordSourceSelectorProxy, path: string, rootId: string, deleteId: string) => { | ||
const node = store.get(rootId); | ||
const records = node?.getLinkedRecord(path); | ||
const edges = records?.getLinkedRecords('edges'); | ||
if (!records || !edges) { return; } | ||
const newEdges = edges.filter((n) => n.getLinkedRecord('node')?.getValue('toId') !== deleteId); | ||
records.setLinkedRecords(newEdges, 'edges'); | ||
}; |
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 code is a duplicate and seems pretty generic.
In fact it seems to be the same as deleteNodeFromEdge
from store.js
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.
Remove it and use the function from store.js
}; | ||
if (isSelected) { | ||
commitRelationDelete({ | ||
...defaultCommitMutation, |
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.
Useless?
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.
To remove
}); | ||
} else { | ||
commitRelationAdd({ | ||
...defaultCommitMutation, |
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.
Useless?
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.
To remove
3d2daf6
to
e6b99e3
Compare
Proposed changes
Related issues
Checklist
Further comments