Skip to content

Commit

Permalink
[frontend] added draft chip in datatable draft lines
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyCloarec committed Oct 30, 2024
1 parent 3aba679 commit 1c2392c
Show file tree
Hide file tree
Showing 41 changed files with 177 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export interface DataTableColumn {
label?: string
size?: number
percentWidth: number
render?: (v: any, helpers?: any) => ReactNode
render?: (v: any, helpers?: any, draftVersion?: boolean) => React.ReactNode
visible?: boolean
order: number
lastX?: number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import StixCoreObjectLabels from '@components/common/stix_core_objects/StixCoreO
import Tooltip from '@mui/material/Tooltip';
import { Link } from 'react-router-dom';
import { useTheme } from '@mui/styles';
import { DraftChip } from '@components/common/draft/DraftChip';
import type { DataTableColumn, DataTableContextProps } from './dataTableTypes';
import { DataTableProps, DataTableVariant } from './dataTableTypes';
import ItemMarkings from '../ItemMarkings';
Expand Down Expand Up @@ -98,9 +99,14 @@ const useStyles = makeStyles<Theme>((theme) => ({
},
}));

const defaultRender: DataTableColumn['render'] = (data, { column: { size } }) => (<Tooltip title={data}>
<div>{truncate(data, size * MAGICAL_SIZE)}</div>
</Tooltip>);
const defaultRender: DataTableColumn['render'] = (data, { column: { size } }, displayDraftChip = false) => {
return (<Tooltip title={data}>
<div>
{truncate(data, size * MAGICAL_SIZE)}
{displayDraftChip && (<DraftChip/>)}
</div>
</Tooltip>);
};

const defaultColumns: DataTableProps['dataColumns'] = {
allowed_markings: {
Expand Down Expand Up @@ -156,8 +162,8 @@ const defaultColumns: DataTableProps['dataColumns'] = {
label: 'Abstract',
percentWidth: 25,
isSortable: true,
render: ({ attribute_abstract, content }, helpers) => {
return defaultRender(attribute_abstract || content, helpers);
render: ({ attribute_abstract, content, draftVersion }, helpers) => {
return defaultRender(attribute_abstract || content, helpers, draftVersion);
},
},
attribute_count: {
Expand Down Expand Up @@ -430,7 +436,10 @@ const defaultColumns: DataTableProps['dataColumns'] = {
label: 'Name',
percentWidth: 25,
isSortable: true,
render: (data, helpers) => defaultRender(getMainRepresentative(data), helpers),
render: (data, helpers) => {
const displayDraftChip = !!data.draftVersion;
return defaultRender(getMainRepresentative(data), helpers, displayDraftChip);
},
},
note_types: {
id: 'note_types',
Expand Down Expand Up @@ -526,16 +535,16 @@ const defaultColumns: DataTableProps['dataColumns'] = {
/>
</Tooltip>
<div>
{defaultRender(observable.observable_value, helpers)}
{defaultRender(observable.observable_value, helpers, observable.draftVersion)}
</div>
</div>
);
}
}
return defaultRender(observable.observable_value, helpers);
return defaultRender(observable.observable_value, helpers, observable.draftVersion);
}
default:
return defaultRender(observable.observable_value, helpers);
return defaultRender(observable.observable_value, helpers, observable.draftVersion);
}
},
},
Expand Down Expand Up @@ -686,7 +695,7 @@ const defaultColumns: DataTableProps['dataColumns'] = {
label: 'Result name',
percentWidth: 15,
isSortable: true,
render: ({ result_name }, helpers) => defaultRender(result_name, helpers),
render: ({ result_name, draftVersion }, helpers) => defaultRender(result_name, helpers, draftVersion),
},
secondary_motivations: {
id: 'secondary_motivations',
Expand Down Expand Up @@ -728,7 +737,7 @@ const defaultColumns: DataTableProps['dataColumns'] = {
label: 'Source name',
percentWidth: 15,
isSortable: true,
render: ({ source_name }, helpers) => defaultRender(source_name, helpers),
render: ({ source_name, draftVersion }, helpers) => defaultRender(source_name, helpers, draftVersion),
},
start_time: {
id: 'start_time',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const externalReferencesLineFragment = graphql`
external_id
url
created
draftVersion {
draft_id
draft_operation
}
creators {
id
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const groupingLineFragment = graphql`
name
description
context
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const malwareAnalysisFragment = graphql`
}
submitted
result_name
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const notesLineFragment = graphql`
note_types
likelihood
confidence
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const reportLineFragment = graphql`
description
published
report_types
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const channelLineFragment = graphql`
created
modified
confidence
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const toolLineFragment = graphql`
created
modified
confidence
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const vulnerabilityLineFragment = graphql`
modified
confidence
entity_type
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const MalwareCardFragment = graphql`
created
modified
is_family
draftVersion {
draft_id
draft_operation
}
createdBy {
name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ const caseIncidentFragment = graphql`
created
entity_type
response_types
draftVersion {
draft_id
draft_operation
}
objectAssignee {
entity_type
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const caseFragment = graphql`
priority
severity
entity_type
draftVersion {
draft_id
draft_operation
}
objectAssignee {
entity_type
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const caseFragment = graphql`
takedown_types
priority
severity
draftVersion {
draft_id
draft_operation
}
objectAssignee {
entity_type
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const feedbackFragment = graphql`
rating
entity_type
created
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export const TaskFragment = graphql`
description
workflowEnabled
entity_type
draftVersion {
draft_id
draft_operation
}
objectMarking {
definition
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const eventLineFragment = graphql`
modified
start_time
stop_time
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const individualLineFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ const organizationLineFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const systemLineFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ const observedDataFragment = graphql`
last_observed
number_observed
confidence
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const stixSightingsLineFragment = graphql`
first_seen
last_seen
description
draftVersion {
draft_id
draft_operation
}
status {
id
order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export const incidentLineFragment = graphql`
modified
confidence
entity_type
draftVersion {
draft_id
draft_operation
}
objectAssignee {
entity_type
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const AdministrativeAreaFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const cityFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const countryLineFragment = graphql`
x_opencti_aliases
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ const positionLineFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ const regionLineFragment = graphql`
name
created
modified
draftVersion {
draft_id
draft_operation
}
objectMarking {
id
definition_type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ const artifactLineFragment = graphql`
parent_types
observable_value
created_at
draftVersion {
draft_id
draft_operation
}
createdBy {
... on Identity {
id
Expand Down
Loading

0 comments on commit 1c2392c

Please sign in to comment.