• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DLR-SC / ESID / 16340435677

17 Jul 2025 08:42AM UTC coverage: 52.615% (-1.5%) from 54.09%
16340435677

push

github

web-flow
Merge pull request #416 from DLR-SC/feature/fix-filters

Fix Filters

473 of 607 branches covered (77.92%)

Branch coverage included in aggregate %.

0 of 153 new or added lines in 5 files covered. (0.0%)

194 existing lines in 7 files now uncovered.

4527 of 8896 relevant lines covered (50.89%)

10.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/components/ScenarioComponents/FilterComponents/GroupFilterCard.tsx
1
// SPDX-FileCopyrightText: 2024 German Aerospace Center (DLR)
2
// SPDX-License-Identifier: Apache-2.0
3

4
import Visibility from '@mui/icons-material/Visibility';
×
5
import VisibilityOffOutlined from '@mui/icons-material/VisibilityOffOutlined';
×
6
import DeleteForever from '@mui/icons-material/DeleteForever';
×
7
import {
×
8
  Card,
9
  CardActionArea,
10
  CardContent,
11
  Typography,
12
  Divider,
13
  CardActions,
14
  Checkbox,
15
  IconButton,
16
  useTheme,
17
} from '@mui/material';
18
import React, {Dispatch, useState} from 'react';
×
19
import ConfirmDialog from '../../shared/ConfirmDialog';
×
20
import {useTranslation} from 'react-i18next';
×
21
import {GroupFilter} from 'types/group';
22
import {Localization} from 'types/localization';
23

24
interface GroupFilterCardProps {
25
  /** The GroupFilter item to be displayed. */
26
  item: GroupFilter;
27

28
  /** A function that allows setting the groupFilter state so that if the user adds a filter, the new filter will be visible */
29
  toggleGroupFilter: Dispatch<GroupFilter>;
30

31
  /**
32
   * Dispatch function to handle deletion of a group filter.
33
   */
34
  deleteGroupFilter: Dispatch<string>;
35

36
  /** Whether the filter is selected or not. If it is selected, the detail view is displaying this filter's config. */
37
  selected: boolean;
38

39
  /**
40
   * Callback function that is called when the filter is selected or unselected.
41
   * @param groupFilter - Either this filter, if it was selected or null, if it was unselected.
42
   */
43
  selectFilterCallback: (groupFilter: GroupFilter | null) => void;
44

45
  /** An object containing localization information (translation & number formattation).*/
46
  localization?: Localization;
47
}
48

49
/**
50
 * GroupFilterCard component displays a card that represents a single filter for the group filter list. The card shows
51
 * the filter name, a toggle switch to turn on or off the filter, and a delete button to remove the filter.
52
 */
53
export default function GroupFilterCard({
×
54
  item,
×
55
  toggleGroupFilter,
×
56
  deleteGroupFilter,
×
57
  selected,
×
58
  selectFilterCallback,
×
59
  localization = {
×
60
    formatNumber: (value: number) => value.toString(),
×
61
    customLang: 'global',
×
62
    overrides: {},
×
63
  },
×
64
}: GroupFilterCardProps) {
×
65
  const [confirmDialogOpen, setConfirmDialogOpen] = useState(false);
×
66
  const {t: defaultT} = useTranslation();
×
67
  const {t: customT} = useTranslation(localization.customLang);
×
68
  const theme = useTheme();
×
69

70
  return (
×
71
    <Card
×
72
      variant='outlined'
×
73
      sx={{
×
74
        display: 'flex',
×
75
        flexDirection: 'row',
×
76
        alignItems: 'center',
×
77
      }}
×
78
    >
79
      <CardActionArea
×
80
        onClick={() => {
×
81
          selectFilterCallback(selected ? null : item);
×
82
        }}
×
83
      >
84
        <CardContent sx={{backgroundColor: selected ? theme.palette.info.main : theme.palette.background.paper}}>
×
85
          <Typography
×
86
            variant='body1'
×
87
            sx={{color: selected ? theme.palette.primary.contrastText : theme.palette.text.primary}}
×
88
          >
89
            {item.name}
×
90
          </Typography>
×
91
        </CardContent>
×
92
      </CardActionArea>
×
93
      <Divider orientation='vertical' variant='middle' flexItem />
×
94
      <CardActions>
×
95
        <Checkbox
×
96
          checkedIcon={<Visibility />}
×
97
          icon={<VisibilityOffOutlined color='disabled' />}
×
98
          checked={item.isVisible}
×
99
          onClick={() => {
×
NEW
100
            toggleGroupFilter({...item, isVisible: !item.isVisible});
×
101
          }}
×
102
        />
×
103
        <ConfirmDialog
×
104
          open={confirmDialogOpen}
×
105
          title={
×
106
            localization.overrides && localization.overrides['group-filters.confirm-deletion-title']
×
107
              ? customT(localization.overrides['group-filters.confirm-deletion-title'])
×
108
              : defaultT('group-filters.confirm-deletion-title')
×
109
          }
110
          text={
×
111
            localization.overrides && localization.overrides['group-filters.confirm-deletion-text']
×
112
              ? customT(localization.overrides['group-filters.confirm-deletion-text'], {
×
113
                  groupName: item.name,
×
114
                })
×
115
              : defaultT('group-filters.confirm-deletion-text', {groupName: item.name})
×
116
          }
117
          abortButtonText={
×
118
            localization.overrides && localization.overrides['group-filters.close']
×
119
              ? customT(localization.overrides['group-filters.close'])
×
120
              : defaultT('group-filters.close')
×
121
          }
122
          confirmButtonText={
×
123
            localization.overrides && localization.overrides['group-filters.discard']
×
124
              ? customT(localization.overrides['group-filters.discard'])
×
125
              : defaultT('group-filters.discard')
×
126
          }
127
          onAnswer={(answer) => {
×
128
            if (answer) {
×
129
              deleteGroupFilter(item.id);
×
130
            }
×
131
            setConfirmDialogOpen(false);
×
132
          }}
×
133
        />
×
134
        <IconButton onClick={() => setConfirmDialogOpen(true)}>
×
135
          <DeleteForever />
×
136
        </IconButton>
×
137
      </CardActions>
×
138
    </Card>
×
139
  );
140
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc