Skip to content
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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

marieflorescontact
Copy link
Member

@marieflorescontact marieflorescontact commented Jan 17, 2025

Proposed changes

  • Update of Citizenship / Nationality / Country of residence can be done directly from the overview tab. (alignment with others StixCoreRelationships)

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

Further comments

@github-actions github-actions bot added the filigran team use to identify PR from the Filigran team label Jan 17, 2025
@marieflorescontact marieflorescontact self-assigned this Jan 17, 2025
@marieflorescontact marieflorescontact marked this pull request as ready for review January 17, 2025 16:50
Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.26%. Comparing base (f681660) to head (e6b99e3).

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.
📢 Have feedback on the report? Share it here.

@marieflorescontact marieflorescontact marked this pull request as draft January 20, 2025 08:09
@marieflorescontact marieflorescontact marked this pull request as ready for review January 20, 2025 08:22
@marieflorescontact marieflorescontact changed the title [frontend] Update demographic stixCoreRelationships from entity [frontend] Update demographic stixCoreRelationships from entity overview Jan 20, 2025
@lndrtrbn lndrtrbn self-requested a review January 20, 2025 09:16
Copy link
Member

@lndrtrbn lndrtrbn left a 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>(
Copy link
Member

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?

Copy link
Member

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 }} />
Copy link
Member

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?

Comment on lines +138 to +140
useEffect(() => {
refetch({});
}, [data]);
Copy link
Member

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

Comment on lines +147 to +156
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');
};
Copy link
Member

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

Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless?

Copy link
Member

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To remove

@marieflorescontact marieflorescontact marked this pull request as draft January 20, 2025 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent behavior on overview of demographics
2 participants