Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend/frontend] enable custom overview layout for most entities (#6724) #8010

Merged
merged 33 commits into from
Aug 21, 2024

Conversation

labo-flg
Copy link
Member

@labo-flg labo-flg commented Aug 9, 2024

Proposed changes

Replicate what was done in #7969 to most entities, namely:

  • All Analyses
  • All Cases
  • Events
    • incidents
    • observed data
    • sightings ⇒ Not in scope of this PR (heavy refactoring required)
  • All Threats
  • All Observations ⇒ Not in scope of this PR
  • All Arsenal
  • All Techniques
  • Entities ⇒ Not in scope of this PR
  • Locations ⇒ Not in scope of this PR

Code changes are simple:

  • frontend: switch the static grid to a dynamix grid using result from hook useOverviewLayoutCustomization(entityType)
  • backend: declare overview_layout_customization for all types of entities, enabling customization in settings

Note if there was no backend module defined for a specific entity type, I created a module folder + bootstrapped a module file that just handles the default overview layout registration.

There is also some code refactoring frontend side (JSX to TSX, class to functional component) so I can use the hook.

Related issues

Checklist

  • I consider the submitted work as finished
  • I tested the code for its functionality
  • I wrote test cases for the relevant uses case (coverage and e2e)
  • I added/update the relevant documentation (either on github or on notion)
  • Where necessary I refactored code to improve the overall quality

@labo-flg labo-flg added the filigran team use to identify PR from the Filigran team label Aug 9, 2024
@labo-flg labo-flg self-assigned this Aug 9, 2024
Comment on lines 27 to 37
overviewLayoutCustomization: [
{ key: 'details', width: 6, label: 'Entity details' },
{ key: 'basicInformation', width: 6, label: 'Basic information' },
{ key: 'task', width: 6, label: 'Tasks' },
{ key: 'originOfTheCase', width: 6, label: 'Origin of the case' },
{ key: 'observables', width: 6, label: 'Observables' },
{ key: 'otherEntities', width: 6, label: 'Other entities' },
{ key: 'externalReferences', width: 6, label: 'External references' },
{ key: 'mostRecentHistory', width: 6, label: 'Most recent history' },
{ key: 'notes', width: 12, label: 'Notes about this entity' },
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how you declare the default layout when there is a module backend side.

Comment on lines 1 to 21
/**
* Placeholder for a report Module Definition
*/

import type { OverviewLayoutCustomization } from '../entitySetting/entitySetting-types';
import { registerEntityOverviewLayoutCustomization } from '../../schema/overviewLayoutCustomization-register';
import { ENTITY_TYPE_CONTAINER_REPORT } from '../../schema/stixDomainObject';

const reportDefaultOverviewLayout: OverviewLayoutCustomization[] = [
{ key: 'details', width: 6, label: 'Entity details' },
{ key: 'basicInformation', width: 6, label: 'Basic information' },
{ key: 'externalReferences', width: 6, label: 'External references' },
{ key: 'mostRecentHistory', width: 6, label: 'Most recent history' },
{ key: 'notes', width: 12, label: 'Notes about this entity' },
];

// Register only the default layout
registerEntityOverviewLayoutCustomization(
ENTITY_TYPE_CONTAINER_REPORT,
reportDefaultOverviewLayout,
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reports, no backend module is coded yet ; still old architecture.

I chose to bootstrap a module file, only declaring the default layout.
We can start from there if/when we move reports to the module architecture.

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.03%. Comparing base (e0fcc48) to head (6a65012).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8010      +/-   ##
==========================================
+ Coverage   65.84%   66.03%   +0.18%     
==========================================
  Files         584      597      +13     
  Lines       59315    59628     +313     
  Branches     6068     6072       +4     
==========================================
+ Hits        39056    39373     +317     
+ Misses      20259    20255       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@labo-flg labo-flg force-pushed the issue/6724-chunk-4 branch 4 times, most recently from 33c1ea3 to 59fe183 Compare August 14, 2024 08:36
@labo-flg labo-flg marked this pull request as ready for review August 14, 2024 08:51
@labo-flg labo-flg changed the title [backend/frontend] enable custom overview layout for all entities (#6724) [backend/frontend] enable custom overview layout for most entities (#6724) Aug 14, 2024
@labo-flg labo-flg force-pushed the issue/6724-chunk-4 branch 2 times, most recently from 8421b3f to 6282e30 Compare August 20, 2024 14:11
@labo-flg labo-flg merged commit e3fe53a into master Aug 21, 2024
5 checks passed
@labo-flg labo-flg deleted the issue/6724-chunk-4 branch August 21, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
filigran team use to identify PR from the Filigran team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants