Projects STRLCPY opencti Commits 0b968a3c
🤬
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/private/components/events/StixSightingRelationships.tsx
    skipped 7 lines
    8 8  import { convertFilters } from '../../../utils/ListParameters';
    9 9  import useLocalStorage, { localStorageToPaginationOptions } from '../../../utils/hooks/useLocalStorage';
    10 10  import { isUniqFilter } from '../common/lists/Filters';
    11  -import { Filters, PaginationOptions } from '../../../components/list_lines';
     11 +import { Filters } from '../../../components/list_lines';
     12 +import {
     13 + StixSightingRelationshipsLinesPaginationQuery$variables,
     14 +} from './stix_sighting_relationships/__generated__/StixSightingRelationshipsLinesPaginationQuery.graphql';
    12 15   
    13 16  const dataColumns = {
    14 17   x_opencti_negative: {
    skipped 99 lines
    114 117   }
    115 118   };
    116 119   
    117  - const renderLines = (paginationOptions: PaginationOptions) => (
     120 + const renderLines = (paginationOptions: StixSightingRelationshipsLinesPaginationQuery$variables) => (
    118 121   <ListLines
    119 122   sortBy={sortBy}
    120 123   orderAsc={orderAsc}
    skipped 23 lines
    144 147   >
    145 148   <QueryRenderer
    146 149   query={stixSightingRelationshipsLinesQuery}
    147  - variables={{ count: 25, ...paginationOptions }}
     150 + variables={paginationOptions}
    148 151   render={({ props }: { props: unknown }) => (
    149 152   <StixSightingRelationshipsLines
    150 153   // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    skipped 20 lines
    171 174   processedFilters = R.dissoc('toSightingId', processedFilters);
    172 175   }
    173 176   const finalFilters = convertFilters(processedFilters) as unknown as Filters;
    174  - const paginationOptions = localStorageToPaginationOptions({ ...viewStorage, toId: toSightingId, filters: finalFilters });
     177 + const paginationOptions = localStorageToPaginationOptions<StixSightingRelationshipsLinesPaginationQuery$variables>({
     178 + ...viewStorage,
     179 + toId: toSightingId,
     180 + filters: finalFilters,
     181 + count: 25,
     182 + });
    175 183   return (
    176 184   <div>{renderLines(paginationOptions)}</div>
    177 185   );
    skipped 4 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/utils/Store.js
    skipped 10 lines
    11 11  export const insertNode = (store, key, filters, rootField) => {
    12 12   // Build record ids
    13 13   const record = store.get(store.getRoot().getDataID());
    14  - const conn = ConnectionHandler.getConnection(record, key, filters);
     14 + 
     15 + // Connections cannot use count as a filter because we NEED to update the count when we push new elements
     16 + const params = { ...filters };
     17 + delete params.count;
     18 + 
     19 + const conn = ConnectionHandler.getConnection(record, key, params);
    15 20   if (conn) {
    16 21   // Build the payload to add
    17 22   const payload = store.getRootField(rootField);
    skipped 9 lines
    27 32   
    28 33  export const deleteNode = (store, key, filters, id) => {
    29 34   const record = store.get(store.getRoot().getDataID());
    30  - const conn = ConnectionHandler.getConnection(record, key, filters);
     35 + 
     36 + // Connections cannot use count as a filter because we NEED to update the count when we remove new elements
     37 + const params = { ...filters };
     38 + delete params.count;
     39 + 
     40 + const conn = ConnectionHandler.getConnection(record, key, params);
    31 41   if (conn) {
    32 42   ConnectionHandler.deleteNode(conn, id);
    33 43   } else {
    skipped 5 lines
  • ■ ■ ■ ■ ■
    opencti-platform/opencti-front/src/utils/hooks/useLocalStorage.ts
    skipped 8 lines
    9 9   sortBy?: string,
    10 10   orderAsc?: boolean,
    11 11   openExports?: boolean,
     12 + count?: number
    12 13  }
    13 14   
    14  -export const localStorageToPaginationOptions = <T extends LocalStorage>({ searchTerm, filters, sortBy, orderAsc, ...props }: T): PaginationOptions => ({
    15  - ...props,
    16  - search: searchTerm,
    17  - orderMode: orderAsc ? OrderMode.asc : OrderMode.desc,
    18  - orderBy: sortBy,
     15 +export const localStorageToPaginationOptions = <U>({
     16 + searchTerm,
    19 17   filters,
    20  -});
     18 + sortBy,
     19 + orderAsc,
     20 + ...props
     21 +}: LocalStorage & Omit<U, 'filters'>): unknown extends U ? PaginationOptions : U => {
     22 + // OpenExports and NumberOfElements are only display options, not query linked
     23 + // eslint-disable-next-line @typescript-eslint/naming-convention
     24 + const { openExports: _, numberOfElements: __, ...localOptions } = props;
     25 + return ({
     26 + ...localOptions,
     27 + search: searchTerm,
     28 + orderMode: orderAsc ? OrderMode.asc : OrderMode.desc,
     29 + orderBy: sortBy,
     30 + filters,
     31 + }) as unknown extends U ? PaginationOptions : U;
     32 +};
    21 33   
    22 34  const useLocalStorage = <T = LocalStorage>(key: string, initialValue: T): [value: T, setValue: Dispatch<SetStateAction<T>>] => {
    23 35   // State to store our value
    skipped 38 lines
Please wait...
Page is in error, reload to recover