Skip to content

Commit

Permalink
[frontend] increase and sort values in bulk update lists (#6326)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit committed Mar 14, 2024
1 parent ca1404a commit 1278c91
Showing 1 changed file with 32 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -746,11 +746,14 @@ class ToolBar extends Component {
.toPromise()
.then((data) => {
const elements = data.containers.edges.map((e) => e.node);
const containers = elements.map((n) => ({
label: n.representative.main,
type: n.entity_type,
value: n.id,
}));
const containers = elements
.map((n) => ({
label: n.representative.main,
type: n.entity_type,
value: n.id,
}))
.sort((a, b) => a.label.localeCompare(b.label))
.sort((a, b) => a.type.localeCompare(b.type));
this.setState({ containers });
});
}
Expand All @@ -767,14 +770,13 @@ class ToolBar extends Component {
fetchQuery(objectMarkingFieldAllowedMarkingsQuery)
.toPromise()
.then((data) => {
const markingDefinitions = R.pipe(
R.pathOr([], ['me', 'allowed_marking']),
R.map((n) => ({
const markingDefinitions = (data?.me?.allowed_marking ?? [])
.map((n) => ({
label: n.definition,
value: n.id,
color: n.x_opencti_color,
})),
)(data);
}))
.sort((a, b) => a.label.localeCompare(b.label));
this.setState({ markingDefinitions });
});
}
Expand All @@ -793,14 +795,13 @@ class ToolBar extends Component {
})
.toPromise()
.then((data) => {
const labels = R.pipe(
R.pathOr([], ['labels', 'edges']),
R.map((n) => ({
const labels = (data?.labels?.edges ?? [])
.map((n) => ({
label: n.node.value,
value: n.node.id,
color: n.node.color,
})),
)(data);
}))
.sort((a, b) => a.label.localeCompare(b.label));
this.setState({
labels: R.union(this.state.labels, labels),
});
Expand All @@ -821,17 +822,15 @@ class ToolBar extends Component {
})
.toPromise()
.then((data) => {
const externalReferences = R.pipe(
R.pathOr([], ['externalReferences', 'edges']),
R.sortWith([R.ascend(R.path(['node', 'source_name']))]),
R.map((n) => ({
const externalReferences = (data?.externalReferences?.edges ?? [])
.map((n) => ({
label: `[${n.node.source_name}] ${truncate(
n.node.description || n.node.external_id,
150,
)} ${n.node.url && `(${n.node.url})`}`,
value: n.node.id,
})),
)(data);
}))
.sort((a, b) => a.label.localeCompare(b.label));
this.setState({
externalReferences: R.union(
this.state.externalReferences,
Expand All @@ -853,18 +852,18 @@ class ToolBar extends Component {
fetchQuery(identitySearchIdentitiesSearchQuery, {
types: ['Individual', 'Organization', 'System'],
search: newValue && newValue.length > 0 ? newValue : '',
first: 10,
first: 100,
})
.toPromise()
.then((data) => {
const identities = R.pipe(
R.pathOr([], ['identities', 'edges']),
R.map((n) => ({
const identities = (data?.identities?.edges ?? [])
.map((n) => ({
label: n.node.name,
value: n.node.id,
type: n.node.entity_type,
})),
)(data);
}))
.sort((a, b) => a.label.localeCompare(b.label))
.sort((a, b) => a.type.localeCompare(b.type));
this.setState({
identities: R.union(this.state.identities, identities),
});
Expand All @@ -881,7 +880,7 @@ class ToolBar extends Component {
);
this.setState({ actionsInputs });
fetchQuery(statusFieldStatusesSearchQuery, {
first: 10,
first: 100,
filters: {
mode: 'and',
filterGroups: [],
Expand All @@ -893,15 +892,15 @@ class ToolBar extends Component {
})
.toPromise()
.then((data) => {
const statuses = R.pipe(
R.pathOr([], ['statuses', 'edges']),
R.map((n) => ({
const statuses = (data?.statuses?.edges ?? [])
.map((n) => ({
label: n.node.template.name,
value: n.node.id,
order: n.node.order,
color: n.node.template.color,
})),
)(data);
}))
.sort((a, b) => a.label.localeCompare(b.label))
.sort((a, b) => a.order - b.order);
this.setState({ statuses: R.union(this.state.statuses, statuses) });
});
}
Expand Down

0 comments on commit 1278c91

Please sign in to comment.