■ ■ ■ ■ ■ ■
opencti-platform/opencti-front/src/private/components/techniques/data_components/DataComponentsLines.tsx
1 | 1 | | import React, { FunctionComponent } from 'react'; |
2 | 2 | | import { createPaginationContainer, graphql, RelayPaginationProp } from 'react-relay'; |
3 | | - | import makeStyles from '@mui/styles/makeStyles'; |
4 | 3 | | import { DataComponentLine, DataComponentLineDummyComponent } from './DataComponentLine'; |
5 | 4 | | import { DataComponentsLines_data$data } from './__generated__/DataComponentsLines_data.graphql'; |
6 | 5 | | import { DataColumns, PaginationOptions } from '../../../../components/list_lines'; |
7 | 6 | | import ListLinesContent from '../../../../components/list_lines/ListLinesContent'; |
8 | 7 | | |
9 | | - | const useStyles = makeStyles(() => ({ |
10 | | - | root: { |
11 | | - | margin: 0, |
12 | | - | }, |
13 | | - | })); |
14 | | - | |
15 | 8 | | interface DataComponentsLinesProps { |
16 | 9 | | data?: DataComponentsLines_data$data, |
17 | 10 | | dataColumns: DataColumns, |
| skipped 3 lines |
21 | 14 | | } |
22 | 15 | | |
23 | 16 | | const DataComponentsLines: FunctionComponent<DataComponentsLinesProps> = ({ relay, data, dataColumns, paginationOptions, initialLoading }) => { |
24 | | - | const dataComponents = data?.dataComponents?.edges ?? []; |
25 | | - | const classes = useStyles(); |
26 | 17 | | return ( |
27 | 18 | | <ListLinesContent |
28 | | - | className={classes.root} |
29 | 19 | | initialLoading={initialLoading} |
30 | 20 | | isLoading={relay.isLoading} |
31 | 21 | | loadMore={relay.loadMore} |
32 | 22 | | hasMore={relay.hasMore} |
33 | | - | dataList={dataComponents} |
| 23 | + | dataList={data?.dataComponents?.edges ?? []} |
34 | 24 | | LineComponent={ DataComponentLine } |
35 | 25 | | DummyLineComponent={ <DataComponentLineDummyComponent /> } |
36 | 26 | | dataColumns={dataColumns} |
| skipped 3 lines |
40 | 30 | | }; |
41 | 31 | | |
42 | 32 | | export const dataComponentsLinesQuery = graphql` |
43 | | - | query DataComponentsLinesPaginationQuery($count: Int!, $cursor: ID) { |
44 | | - | ...DataComponentsLines_data @arguments(count: $count, cursor: $cursor) |
| 33 | + | query DataComponentsLinesPaginationQuery( |
| 34 | + | $search: String |
| 35 | + | $count: Int! |
| 36 | + | $cursor: ID |
| 37 | + | $orderBy: DataComponentsOrdering |
| 38 | + | $orderMode: OrderingMode |
| 39 | + | ) { |
| 40 | + | ...DataComponentsLines_data @arguments( |
| 41 | + | search: $search |
| 42 | + | count: $count |
| 43 | + | cursor: $cursor |
| 44 | + | orderBy: $orderBy |
| 45 | + | orderMode: $orderMode |
| 46 | + | ) |
45 | 47 | | } |
46 | 48 | | `; |
47 | 49 | | |
| skipped 3 lines |
51 | 53 | | data: graphql` |
52 | 54 | | fragment DataComponentsLines_data on Query |
53 | 55 | | @argumentDefinitions( |
| 56 | + | search: { type: "String" } |
54 | 57 | | count: { type: "Int", defaultValue: 25 } |
55 | 58 | | cursor: { type: "ID" } |
| 59 | + | orderBy: { type: "DataComponentsOrdering", defaultValue: name } |
| 60 | + | orderMode: { type: "OrderingMode", defaultValue: asc } |
56 | 61 | | ) { |
57 | | - | dataComponents(first: $count, after: $cursor) |
| 62 | + | dataComponents( |
| 63 | + | search: $search |
| 64 | + | first: $count |
| 65 | + | after: $cursor |
| 66 | + | orderBy: $orderBy |
| 67 | + | orderMode: $orderMode |
| 68 | + | ) |
58 | 69 | | @connection(key: "Pagination_dataComponents") { |
59 | 70 | | edges { |
60 | 71 | | node { |
61 | | - | id |
62 | | - | name |
63 | | - | description |
64 | 72 | | ...DataComponentLine_node |
65 | 73 | | } |
66 | 74 | | } |
| skipped 17 lines |
84 | 92 | | count: totalCount, |
85 | 93 | | }; |
86 | 94 | | }, |
87 | | - | getVariables(props, { count, cursor }) { |
| 95 | + | getVariables(props, { count, cursor }, fragmentVariables) { |
88 | 96 | | return { |
| 97 | + | search: fragmentVariables.search, |
89 | 98 | | count, |
90 | 99 | | cursor, |
| 100 | + | orderBy: fragmentVariables.orderBy, |
| 101 | + | orderMode: fragmentVariables.orderMode, |
91 | 102 | | }; |
92 | 103 | | }, |
93 | 104 | | query: dataComponentsLinesQuery, |
| skipped 3 lines |