■ ■ ■ ■ ■ ■
opencti-platform/opencti-front/src/private/components/techniques/data_components/DataComponentKnowledge.tsx
1 | 1 | | import React, { FunctionComponent } from 'react'; |
2 | 2 | | import { Route, Switch } from 'react-router-dom'; |
3 | | - | import { createFragmentContainer, graphql } from 'react-relay'; |
| 3 | + | import { graphql, useFragment } from 'react-relay'; |
4 | 4 | | import makeStyles from '@mui/styles/makeStyles'; |
5 | 5 | | import StixCoreRelationship from '../../common/stix_core_relationships/StixCoreRelationship'; |
6 | 6 | | import StixDomainObjectHeader from '../../common/stix_domain_objects/StixDomainObjectHeader'; |
7 | 7 | | import DataComponentPopover from './DataComponentPopover'; |
8 | | - | import { DataComponentKnowledge_dataComponent$data } from './__generated__/DataComponentKnowledge_dataComponent.graphql'; |
| 8 | + | import { DataComponentKnowledge_dataComponent$key } from './__generated__/DataComponentKnowledge_dataComponent.graphql'; |
9 | 9 | | |
10 | 10 | | const styles = makeStyles(() => ({ |
11 | 11 | | container: { |
| skipped 2 lines |
14 | 14 | | })); |
15 | 15 | | |
16 | 16 | | interface DataComponentKnowledgeComponentProps { |
17 | | - | dataComponent: DataComponentKnowledge_dataComponent$data |
| 17 | + | data: DataComponentKnowledge_dataComponent$key |
18 | 18 | | enableReferences: boolean |
19 | 19 | | } |
20 | 20 | | |
21 | | - | const DataComponentKnowledgeComponent: FunctionComponent<DataComponentKnowledgeComponentProps> = ({ dataComponent, enableReferences }) => { |
| 21 | + | const DataComponentKnowledgeComponent: FunctionComponent<DataComponentKnowledgeComponentProps> = ({ |
| 22 | + | data, |
| 23 | + | enableReferences |
| 24 | + | }) => { |
22 | 25 | | const classes = styles(); |
| 26 | + | |
| 27 | + | const dataComponent = useFragment(DataComponentKnowledgeFragment, data); |
23 | 28 | | |
24 | 29 | | return ( |
25 | | - | <div className={classes.container}> |
26 | | - | <StixDomainObjectHeader |
27 | | - | stixDomainObject={dataComponent} |
28 | | - | PopoverComponent={<DataComponentPopover dataComponentId={dataComponent.id} enableReferences={enableReferences}/>} |
29 | | - | // isOpenctiAlias={true} // TODO: ask to Samuel |
| 30 | + | <div className={classes.container}> |
| 31 | + | <StixDomainObjectHeader |
| 32 | + | stixDomainObject={dataComponent} |
| 33 | + | PopoverComponent={<DataComponentPopover dataComponentId={dataComponent.id} />} |
| 34 | + | enableReferences={enableReferences} |
| 35 | + | // isOpenctiAlias={true} // TODO: ask to Samuel |
| 36 | + | /> |
| 37 | + | <Switch> |
| 38 | + | <Route |
| 39 | + | path="/dashboard/techniques/data_component/:dataComponentId/knowledge/relations/:relationId" |
| 40 | + | // @ts-ignore: incompatibility type |
| 41 | + | // TODO: required migration to V6 |
| 42 | + | render={(routeProps) => ( |
| 43 | + | <StixCoreRelationship |
| 44 | + | entityId={dataComponent.id} |
| 45 | + | {...routeProps} |
| 46 | + | /> |
| 47 | + | )} |
30 | 48 | | /> |
31 | | - | <Switch> |
32 | | - | <Route |
33 | | - | path="/dashboard/techniques/data_component/:dataComponentId/knowledge/relations/:relationId" |
34 | | - | // @ts-ignore: incompatibility type |
35 | | - | // TODO: required migration to V6 |
36 | | - | render={(routeProps) => ( |
37 | | - | <StixCoreRelationship |
38 | | - | entityId={dataComponent.id} |
39 | | - | {...routeProps} |
40 | | - | /> |
41 | | - | )} |
42 | | - | /> |
43 | | - | {/* TODO: ask Samuel ? */} |
44 | | - | </Switch> |
45 | | - | </div> |
| 49 | + | {/* TODO: ask Samuel ? */} |
| 50 | + | </Switch> |
| 51 | + | </div> |
46 | 52 | | ); |
47 | | - | }; |
| 53 | + | } |
48 | 54 | | |
49 | | - | const DataComponentKnowledge = createFragmentContainer( |
50 | | - | DataComponentKnowledgeComponent, |
51 | | - | { |
52 | | - | dataComponent: graphql` |
53 | | - | fragment DataComponentKnowledge_dataComponent on DataComponent { |
54 | | - | id |
55 | | - | name |
56 | | - | aliases |
57 | | - | } |
58 | | - | `, |
59 | | - | }, |
60 | | - | ); |
| 55 | + | const DataComponentKnowledgeFragment = graphql` |
| 56 | + | fragment DataComponentKnowledge_dataComponent on DataComponent { |
| 57 | + | id |
| 58 | + | name |
| 59 | + | aliases |
| 60 | + | } |
| 61 | + | `; |
61 | 62 | | |
62 | | - | export default DataComponentKnowledge; |
| 63 | + | export default DataComponentKnowledgeComponent; |
63 | 64 | | |