Skip to content

Commit

Permalink
[api/frontend] Introduce custom attributes for report class and role …
Browse files Browse the repository at this point in the history
…played (#73 / #104)
  • Loading branch information
Samuel Hassine committed Jul 19, 2019
1 parent 3f538d1 commit e072fd0
Show file tree
Hide file tree
Showing 28 changed files with 1,802 additions and 622 deletions.
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"classnames": "^2.2.6",
"countdown": "^2.6.0",
"dagre": "^0.8.4",
"formik": "^1.5.7",
"formik": "^1.5.8",
"formik-material-ui": "^0.0.20",
"graphql": "^14.4.1",
"http-proxy-middleware": "^0.19.1",
Expand Down
16 changes: 2 additions & 14 deletions opencti-platform/opencti-front/src/private/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,9 @@ class Root extends Component {
/>
<BoundaryRoute
exact
path="/dashboard/reports/all"
component={Reports}
/>
<BoundaryRoute
exact
path="/dashboard/reports/internal"
render={routeProps => (
<Reports {...routeProps} reportClass="internal" />
)}
/>
<BoundaryRoute
exact
path="/dashboard/reports/external"
path="/dashboard/reports/:reportClass"
render={routeProps => (
<Reports {...routeProps} reportClass="external" />
<Reports {...routeProps} />
)}
/>
<BoundaryRoute
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class TopBar extends Component {
''
)}
{location.pathname === '/dashboard/reports'
|| location.pathname.match('/dashboard/reports/[a-z_]+$') ? (
|| location.pathname.match('/dashboard/reports/[a-zA-Z1-9_-]+$') ? (
<TopMenuReports />
) : (
''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { compose } from 'ramda';
import { withStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import inject18n from '../../../components/i18n';
import { QueryRenderer } from '../../../relay/environment';
import { attributesQuery } from '../settings/attributes/AttributesList';

const styles = theme => ({
button: {
Expand Down Expand Up @@ -38,42 +40,47 @@ class TopMenuReports extends Component {
>
{t('All reports')}
</Button>
<Button
component={Link}
to="/dashboard/reports/internal"
variant={
location.pathname === '/dashboard/reports/internal'
? 'contained'
: 'text'
}
size="small"
color={
location.pathname === '/dashboard/reports/internal'
? 'primary'
: 'inherit'
}
classes={{ root: classes.button }}
>
{t('Internal productions')}
</Button>
<Button
component={Link}
to="/dashboard/reports/external"
variant={
location.pathname === '/dashboard/reports/external'
? 'contained'
: 'text'
}
size="small"
color={
location.pathname === '/dashboard/reports/external'
? 'primary'
: 'inherit'
}
classes={{ root: classes.button }}
>
{t('External sources')}
</Button>
<QueryRenderer
query={attributesQuery}
variables={{ type: 'report_class' }}
render={({ props }) => {
if (props && props.attributes) {
const reportClassesEdges = props.attributes.edges;
return reportClassesEdges.map(reportClassEdge => (
<Button
component={Link}
to={`/dashboard/reports/${reportClassEdge.node.value.replace(
' ',
'_',
)}`}
variant={
location.pathname
=== `/dashboard/reports/${reportClassEdge.node.value.replace(
' ',
'_',
)}`
? 'contained'
: 'text'
}
size="small"
color={
location.pathname
=== `/dashboard/reports/${reportClassEdge.node.value.replace(
' ',
'_',
)}`
? 'primary'
: 'inherit'
}
classes={{ root: classes.button }}
>
{reportClassEdge.node.value}
</Button>
));
}
return <span>&nbsp;</span>;
}}
/>
<Button
component={Link}
to="/dashboard/reports/references"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ class TopMenuSettings extends Component {
>
{t('Kill chain phases')}
</Button>
<Button
component={Link}
to="/dashboard/settings/attributes"
variant={
location.pathname.includes('/dashboard/settings/attributes')
? 'contained'
: 'text'
}
size="small"
color={
location.pathname.includes('/dashboard/settings/attributes')
? 'primary'
: 'inherit'
}
classes={{ root: classes.button }}
>
{t('Custom attributes')}
</Button>
</div>
);
}
Expand Down

0 comments on commit e072fd0

Please sign in to comment.