Skip to content

Commit c98855f

Browse files
[backend/frontend] Adapt for new changes format
1 parent e4bf8c1 commit c98855f

File tree

19 files changed

+507
-737
lines changed

19 files changed

+507
-737
lines changed

opencti-platform/opencti-front/src/private/components/common/drawer/HistoryDrawer.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const HistoryDrawer: FunctionComponent<HistoryDrawerProps> = ({ open, onClose, t
3232
const data = useFragment(drawerFragment, node);
3333
const theme = useTheme<Theme>();
3434
const { t_i18n } = useFormatter();
35-
const changes = data?.context_data?.changes;
35+
const changes = data?.context_data?.history_changes;
3636

3737
return (
3838
<Drawer
@@ -72,7 +72,6 @@ const HistoryDrawer: FunctionComponent<HistoryDrawerProps> = ({ open, onClose, t
7272
<TableRow>
7373
<TableCell></TableCell>
7474
<TableCell align="left">{t_i18n('Previous value')}</TableCell>
75-
<TableCell align="left">{t_i18n('New value')}</TableCell>
7675
<TableCell align="left">{t_i18n('Added')}</TableCell>
7776
<TableCell align="left">{t_i18n('Removed')}</TableCell>
7877
</TableRow>
@@ -84,22 +83,18 @@ const HistoryDrawer: FunctionComponent<HistoryDrawerProps> = ({ open, onClose, t
8483
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
8584
>
8685
<TableCell component="th" scope="row">
87-
{row?.field}
86+
{row?.field.split('--')[1]}
8887
</TableCell>
89-
<TableCell align="left">{row?.previous && row.previous.length > 0
90-
? row.previous.join(', ')
88+
<TableCell align="left">{row?.history_previous && row.history_previous.length > 0
89+
? row.history_previous.map((s) => s.translated).join(', ')
9190
: '-'}
9291
</TableCell>
93-
<TableCell align="left">{row?.new && row.new.length > 0
94-
? row.new.join(', ')
92+
<TableCell align="left">{row?.history_added && row.history_added.length > 0
93+
? row.history_added.map((s) => s.translated).join(', ')
9594
: '-'}
9695
</TableCell>
97-
<TableCell align="left">{row?.added && row.added.length > 0
98-
? row.added.join(', ')
99-
: '-'}
100-
</TableCell>
101-
<TableCell align="left">{row?.removed && row.removed.length > 0
102-
? row.removed.join(', ')
96+
<TableCell align="left">{row?.history_removed && row.history_removed.length > 0
97+
? row.history_removed.map((s) => s.translated).join(', ')
10398
: '-'}
10499
</TableCell>
105100
</TableRow>

opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectHistoryLine.jsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,17 @@ export const StixCoreObjectHistoryFragment = graphql`
4848
url
4949
description
5050
}
51-
changes{
51+
history_changes {
5252
field
53-
previous
54-
new
55-
added
56-
removed
53+
history_previous {
54+
translated
55+
}
56+
history_added {
57+
translated
58+
}
59+
history_removed {
60+
translated
61+
}
5762
}
5863
}
5964
}

opencti-platform/opencti-front/src/private/components/common/stix_core_relationships/StixCoreRelationshipHistoryLine.jsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ export const StixCoreRelationshipHistoryFragment = graphql`
4646
url
4747
description
4848
}
49-
changes{
50-
field
51-
previous
52-
new
53-
added
54-
removed
55-
}
5649
}
5750
}
5851
`;

opencti-platform/opencti-front/src/private/components/settings/activity/audit/Audit.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,6 @@ export const AuditCSVQuery = graphql`
8484
entity_type
8585
entity_name
8686
message
87-
changes{
88-
field
89-
previous
90-
new
91-
added
92-
removed
93-
}
9487
}
9588
}
9689
}

opencti-platform/opencti-front/src/private/components/settings/activity/audit/AuditLine.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,17 @@ const AuditLineFragment = graphql`
7878
message
7979
from_id
8080
to_id
81-
changes{
81+
history_changes {
8282
field
83-
previous
84-
new
85-
added
86-
removed
83+
history_previous {
84+
translated
85+
}
86+
history_added {
87+
translated
88+
}
89+
history_removed {
90+
translated
91+
}
8792
}
8893
}
8994
}
@@ -100,7 +105,7 @@ export const AuditLine: FunctionComponent<AuditLineProps> = ({
100105
const data = useFragment(AuditLineFragment, node);
101106
const message = useGenerateAuditMessage<AuditLine_node$data>(data);
102107
const color = data.event_status === 'error' ? theme.palette.error.main : undefined;
103-
const changes = data?.context_data?.changes;
108+
const changes = data?.context_data?.history_changes;
104109

105110
return (
106111
<>
@@ -149,7 +154,6 @@ export const AuditLine: FunctionComponent<AuditLineProps> = ({
149154
<TableRow>
150155
<TableCell></TableCell>
151156
<TableCell align="left">Previous value</TableCell>
152-
<TableCell align="left">New value</TableCell>
153157
<TableCell align="left">Added</TableCell>
154158
<TableCell align="left">Removed</TableCell>
155159
</TableRow>
@@ -161,22 +165,18 @@ export const AuditLine: FunctionComponent<AuditLineProps> = ({
161165
sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
162166
>
163167
<TableCell component="th" scope="row">
164-
{row?.field}
168+
{row?.field.split('--')[1]}
165169
</TableCell>
166-
<TableCell align="left">{row?.previous && row.previous.length > 0
167-
? row.previous.join(', ')
170+
<TableCell align="left">{row?.history_previous && row.history_previous.length > 0
171+
? row.history_previous.join(', ')
168172
: '-'}
169173
</TableCell>
170-
<TableCell align="left">{row?.new && row.new.length > 0
171-
? row.new.join(', ')
174+
<TableCell align="left">{row?.history_added && row.history_added.length > 0
175+
? row.history_added.join(', ')
172176
: '-'}
173177
</TableCell>
174-
<TableCell align="left">{row?.added && row.added.length > 0
175-
? row.added.join(', ')
176-
: '-'}
177-
</TableCell>
178-
<TableCell align="left">{row?.removed && row.removed.length > 0
179-
? row.removed.join(', ')
178+
<TableCell align="left">{row?.history_removed && row.history_removed.length > 0
179+
? row.history_removed.join(', ')
180180
: '-'}
181181
</TableCell>
182182
</TableRow>

opencti-platform/opencti-front/src/schema/relay.schema.graphql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,16 @@ type LogEdge {
527527
node: Log!
528528
}
529529

530-
type Change {
530+
type DataChange {
531+
raw: String!
532+
translated: String
533+
}
534+
535+
type HistoryChange {
531536
field: String!
532-
previous: [String!]
533-
new: [String!]
534-
added: [String!]
535-
removed: [String!]
537+
history_previous: [DataChange!]
538+
history_added: [DataChange!]
539+
history_removed: [DataChange!]
536540
}
537541

538542
type ContextData {
@@ -548,7 +552,7 @@ type ContextData {
548552
pir_ids: [String!]
549553
pir_score: Int
550554
pir_match_from: Boolean
551-
changes: [Change]
555+
history_changes: [HistoryChange]
552556
}
553557

554558
type Log {

opencti-platform/opencti-graphql/config/schema/opencti.graphql

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,16 @@ type LogEdge {
497497
cursor: String!
498498
node: Log!
499499
}
500-
type Change {
500+
501+
type DataChange {
502+
raw: String!
503+
translated: String
504+
}
505+
type HistoryChange {
501506
field: String!
502-
previous: [String!]
503-
new: [String!]
504-
added: [String!]
505-
removed: [String!]
507+
history_previous: [DataChange!]
508+
history_added: [DataChange!]
509+
history_removed: [DataChange!]
506510
}
507511
type ContextData {
508512
entity_id: String
@@ -517,7 +521,7 @@ type ContextData {
517521
pir_ids: [String!] @auth(for: [PIRAPI])
518522
pir_score: Int @auth(for: [PIRAPI])
519523
pir_match_from: Boolean @auth(for: [PIRAPI])
520-
changes: [Change]
524+
history_changes: [HistoryChange]
521525
}
522526
type Log {
523527
id: ID!

0 commit comments

Comments
 (0)