Skip to content

Commit

Permalink
feat: add stakeholders filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed-Hacene committed Dec 17, 2024
1 parent ad48197 commit 2fc4387
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions frontend/src/lib/utils/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import SelectFilter from '$lib/components/Filters/SelectFilter.svelte';
import type { ComponentType } from 'svelte';
import { LOCALE_DISPLAY_MAP } from './constants';
import type { Row } from '@vincjo/datatables';
import { category, entity } from '$paraglide/messages';

interface ListViewFilterConfig {
component: ComponentType;
Expand Down Expand Up @@ -210,6 +211,24 @@ const PERTINENCE_FILTER: ListViewFilterConfig = {
alwaysDisplay: true
};

const ENTITY_FILTER: ListViewFilterConfig = {
component: SelectFilter,
getColumn: (row) => (row.entity.str),
extraProps: {
defaultOptionName: 'entity'
},
alwaysDisplay: true
};

const APPLIED_CONTROL_FILTER: ListViewFilterConfig = {
component: SelectFilter,
getColumn: (row) => (row.applied_controls?.length ? row.applied_controls.map((t) => t.str) : null),
extraProps: {
defaultOptionName: 'applied_control'
},
alwaysDisplay: true
};

const FRAMEWORK_FILTER: ListViewFilterConfig = {
component: SelectFilter,
getColumn: (row) => row.framework.ref_id,
Expand Down Expand Up @@ -657,8 +676,14 @@ export const listViewFields: ListViewFieldsConfig = {
}
},
stakeholders: {
head: ['entity', 'category', 'current_criticality', 'applied_controls', 'residual_criticality'],
body: ['entity', 'category', 'current_criticality', 'applied_controls', 'residual_criticality']
head: ['is_selected', 'entity', 'category', 'current_criticality', 'applied_controls', 'residual_criticality'],
body: ['is_selected', 'entity', 'category', 'current_criticality', 'applied_controls', 'residual_criticality'],
filters: {
is_selected: IS_SELECTED_FILTER,
entity: ENTITY_FILTER,
category: CATEGORY_FILTER,
applied_controls: APPLIED_CONTROL_FILTER
}
},
'strategic-scenarios': {
head: ['ref_id', 'name', 'description', 'ro_to_couple', 'attackPaths'],
Expand Down

0 comments on commit 2fc4387

Please sign in to comment.