Skip to content

Commit

Permalink
[front] Align ui filters on runtime mapping capability (#2936)
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-julien authored Mar 5, 2023
1 parent f28b4b9 commit c079add
Show file tree
Hide file tree
Showing 70 changed files with 2,208 additions and 1,874 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class Search extends Component {
creator: {
label: 'Creator',
width: '12%',
isSortable: true,
isSortable: isRuntimeSort,
},
objectLabel: {
label: 'Labels',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const ExternalReferences: FunctionComponent<ExternalReferencesProps> = () => {
},
);
const { sortBy, orderAsc, searchTerm, filters, numberOfElements } = viewStorage;
const isRuntimeSort = helper?.isRuntimeFieldEnable();
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const dataColumns = {
source_name: {
label: 'Source name',
Expand All @@ -60,7 +60,7 @@ const ExternalReferences: FunctionComponent<ExternalReferencesProps> = () => {
creator: {
label: 'Creator',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
created: {
label: 'Creation date',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent } from 'react';
import React, { FunctionComponent, useContext } from 'react';
import ListLines from '../../../components/list_lines/ListLines';
import GroupingsLines, {
groupingsLinesQuery,
Expand All @@ -16,7 +16,6 @@ import {
GroupingsLinesPaginationQuery$variables,
} from './groupings/__generated__/GroupingsLinesPaginationQuery.graphql';
import { GroupingLine_node$data } from './groupings/__generated__/GroupingLine_node.graphql';
import { ModuleHelper } from '../../../utils/platformModulesHelper';
import { GroupingLineDummy } from './groupings/GroupingLine';

const LOCAL_STORAGE_KEY = 'view-groupings';
Expand All @@ -33,6 +32,7 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
authorId,
onChangeOpenExports,
}) => {
const { helper } = useContext(UserContext);
const additionnalFilters = [];
if (authorId) {
additionnalFilters.push({
Expand Down Expand Up @@ -87,7 +87,7 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
groupingsLinesQuery,
paginationOptions,
);
const renderLines = (helper: ModuleHelper | undefined) => {
const renderLines = () => {
let exportContext = null;
if (objectId) {
exportContext = `of-entity-${objectId}`;
Expand All @@ -104,7 +104,7 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
...finalFilters,
entity_type: [{ id: 'Grouping', value: 'Grouping' }],
};
const isRuntimeSort = helper?.isRuntimeFieldEnable();
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const dataColumns = {
name: {
label: 'Name',
Expand All @@ -119,12 +119,12 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
createdBy: {
label: 'Author',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
creator: {
label: 'Creators',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
objectLabel: {
label: 'Labels',
Expand All @@ -143,7 +143,7 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
},
objectMarking: {
label: 'Marking',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
width: '8%',
},
};
Expand Down Expand Up @@ -221,16 +221,12 @@ const Groupings: FunctionComponent<GroupingsProps> = ({
);
};
return (
<UserContext.Consumer>
{({ helper }) => (
<div>
{renderLines(helper)}
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<GroupingCreation paginationOptions={paginationOptions} />
</Security>
</div>
)}
</UserContext.Consumer>
<div>
{renderLines()}
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<GroupingCreation paginationOptions={paginationOptions} />
</Security>
</div>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FunctionComponent } from 'react';
import React, { FunctionComponent, useContext } from 'react';
import ListLines from '../../../components/list_lines/ListLines';
import ReportsLines, { reportsLinesQuery } from './reports/ReportsLines';
import ReportCreation from './reports/ReportCreation';
Expand All @@ -12,7 +12,6 @@ import {
ReportsLinesPaginationQuery$variables,
} from './reports/__generated__/ReportsLinesPaginationQuery.graphql';
import { Filters } from '../../../components/list_lines';
import { ModuleHelper } from '../../../utils/platformModulesHelper';
import { ReportLine_node$data } from './reports/__generated__/ReportLine_node.graphql';
import useEntityToggle from '../../../utils/hooks/useEntityToggle';
import useQueryLoading from '../../../utils/hooks/useQueryLoading';
Expand All @@ -32,6 +31,7 @@ const Reports: FunctionComponent<ReportsProps> = ({
authorId,
onChangeOpenExports,
}) => {
const { helper } = useContext(UserContext);
const additionnalFilters = [];
if (authorId) {
additionnalFilters.push({
Expand Down Expand Up @@ -87,7 +87,7 @@ const Reports: FunctionComponent<ReportsProps> = ({
reportsLinesQuery,
paginationOptions,
);
const renderLines = (helper: ModuleHelper | undefined) => {
const renderLines = () => {
let exportContext = null;
if (objectId) {
exportContext = `of-entity-${objectId}`;
Expand All @@ -99,7 +99,7 @@ const Reports: FunctionComponent<ReportsProps> = ({
...renderFilters,
entity_type: [{ id: 'Report', value: 'Report' }],
};
const isRuntimeSort = helper?.isRuntimeFieldEnable();
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const dataColumns = {
name: {
label: 'Title',
Expand All @@ -114,12 +114,12 @@ const Reports: FunctionComponent<ReportsProps> = ({
createdBy: {
label: 'Author',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
creator: {
label: 'Creators',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
objectLabel: {
label: 'Labels',
Expand All @@ -138,7 +138,7 @@ const Reports: FunctionComponent<ReportsProps> = ({
},
objectMarking: {
label: 'Marking',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
width: '8%',
},
};
Expand Down Expand Up @@ -220,18 +220,14 @@ const Reports: FunctionComponent<ReportsProps> = ({
);
};
return (
<UserContext.Consumer>
{({ helper }) => (
<ExportContextProvider>
<ExportContextProvider>
<div>
{renderLines(helper)}
{renderLines()}
<Security needs={[KNOWLEDGE_KNUPDATE]}>
<ReportCreation paginationOptions={paginationOptions} />
</Security>
</div>
</ExportContextProvider>
)}
</UserContext.Consumer>
</ExportContextProvider>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import ListLines from '../../../components/list_lines/ListLines';
import VulnerabilitiesLines, {
vulnerabilitiesLinesQuery,
Expand All @@ -14,8 +14,11 @@ import {
VulnerabilitiesLinesPaginationQuery$variables,
} from './vulnerabilities/__generated__/VulnerabilitiesLinesPaginationQuery.graphql';
import { usePaginationLocalStorage } from '../../../utils/hooks/useLocalStorage';
import { UserContext } from '../../../utils/hooks/useAuth';

const Vulnerabilities = () => {
const { helper } = useContext(UserContext);
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const { viewStorage, helpers, paginationOptions } = usePaginationLocalStorage<VulnerabilitiesLinesPaginationQuery$variables>(
'view-vulnerabilities',
{
Expand Down Expand Up @@ -65,7 +68,7 @@ const Vulnerabilities = () => {
creator: {
label: 'Creators',
width: '12%',
isSortable: true,
isSortable: isRuntimeSort,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Feedbacks: FunctionComponent<CasesProps> = () => {
openExports,
numberOfElements,
} = viewStorage;
const isRuntimeSort = helper?.isRuntimeFieldEnable();
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const dataColumns = {
name: {
label: 'Name',
Expand All @@ -85,12 +85,12 @@ const Feedbacks: FunctionComponent<CasesProps> = () => {
createdBy: {
label: 'Author',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
creator: {
label: 'Creators',
width: '12%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
objectLabel: {
label: 'Labels',
Expand All @@ -110,7 +110,7 @@ const Feedbacks: FunctionComponent<CasesProps> = () => {
objectMarking: {
label: 'Marking',
width: '8%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
};
const queryRef = useQueryLoading<FeedbacksLinesPaginationQuery>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const Incidents: FunctionComponent<CasesProps> = () => {
openExports,
numberOfElements,
} = viewStorage;
const isRuntimeSort = helper?.isRuntimeFieldEnable();
const isRuntimeSort = helper?.isRuntimeFieldEnable() ?? false;
const dataColumns = {
name: {
label: 'Name',
Expand All @@ -93,12 +93,12 @@ const Incidents: FunctionComponent<CasesProps> = () => {
createdBy: {
label: 'Author',
width: '11%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
creator: {
label: 'Creators',
width: '11%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
objectLabel: {
label: 'Labels',
Expand All @@ -118,7 +118,7 @@ const Incidents: FunctionComponent<CasesProps> = () => {
objectMarking: {
label: 'Marking',
width: '8%',
isSortable: isRuntimeSort ?? false,
isSortable: isRuntimeSort,
},
};
const queryRef = useQueryLoading<IncidentsLinesCasesPaginationQuery>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,11 @@ class ContainerAddStixCoreObjects extends Component {
confidence={confidence}
defaultCreatedBy={defaultCreatedBy}
defaultMarkingDefinitions={defaultMarkingDefinitions}
stixCoreObjectTypes={targetStixCoreObjectTypes && targetStixCoreObjectTypes.length > 0 ? targetStixCoreObjectTypes : []}
stixCoreObjectTypes={
targetStixCoreObjectTypes && targetStixCoreObjectTypes.length > 0
? targetStixCoreObjectTypes
: []
}
speeddial={true}
open={openCreateEntity}
handleClose={this.handleCloseCreateEntity.bind(this)}
Expand All @@ -277,7 +281,11 @@ class ContainerAddStixCoreObjects extends Component {

renderEntityCreation(paginationOptions) {
const { targetStixCoreObjectTypes } = this.props;
if (targetStixCoreObjectTypes && ContainerAddStixCoreObjects.isTypeDomainObject(targetStixCoreObjectTypes)
if (
targetStixCoreObjectTypes
&& ContainerAddStixCoreObjects.isTypeDomainObject(
targetStixCoreObjectTypes,
)
&& !ContainerAddStixCoreObjects.isTypeObservable(targetStixCoreObjectTypes)
) {
return this.renderDomainObjectCreation(paginationOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,18 @@ export const containerHeaderObjectsQuery = graphql`
name
}
... on Note {
attribute_abstract
content
attribute_abstract
content
}
... on Opinion {
opinion
opinion
}
... on Report {
name
published
name
published
}
... on Grouping {
name
name
}
... on Individual {
name
Expand Down Expand Up @@ -271,25 +271,25 @@ export const containerHeaderObjectsQuery = graphql`
observableName: name
}
... on Label {
value
color
value
color
}
... on MarkingDefinition {
definition
x_opencti_color
definition
x_opencti_color
}
... on KillChainPhase {
kill_chain_name
phase_name
kill_chain_name
phase_name
}
... on ExternalReference {
url
source_name
url
source_name
}
... on BasicRelationship {
id
entity_type
parent_types
id
entity_type
parent_types
}
... on BasicRelationship {
id
Expand Down
Loading

0 comments on commit c079add

Please sign in to comment.