Skip to content

Commit 38d9302

Browse files
committed
reorganize
1 parent ea600f8 commit 38d9302

File tree

2 files changed

+33
-41
lines changed

2 files changed

+33
-41
lines changed

static/app/components/stream/supergroupCheckbox.tsx

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
1-
import {useCallback, useMemo} from 'react';
1+
import {useCallback} from 'react';
22
import styled from '@emotion/styled';
33

44
import {Checkbox} from '@sentry/scraps/checkbox';
55

66
import {t} from 'sentry/locale';
7-
import {
8-
useOptionalIssueSelectionActions,
9-
useOptionalIssueSelectionSummary,
10-
} from 'sentry/views/issueList/issueSelectionContext';
7+
import {useOptionalIssueSelectionActions} from 'sentry/views/issueList/issueSelectionContext';
118

129
interface SupergroupCheckboxProps {
1310
matchedGroupIds: string[];
11+
selectedCount: number;
1412
}
1513

16-
export function SupergroupCheckbox({matchedGroupIds}: SupergroupCheckboxProps) {
17-
const summary = useOptionalIssueSelectionSummary();
14+
export function SupergroupCheckbox({
15+
matchedGroupIds,
16+
selectedCount,
17+
}: SupergroupCheckboxProps) {
1818
const actions = useOptionalIssueSelectionActions();
1919

20-
const checkedState = useMemo(() => {
21-
if (!summary || matchedGroupIds.length === 0) {
22-
return false;
23-
}
24-
let selectedCount = 0;
25-
for (const id of matchedGroupIds) {
26-
if (summary.records.get(id)) {
27-
selectedCount++;
28-
}
29-
}
30-
if (selectedCount === 0) {
31-
return false;
32-
}
33-
if (selectedCount === matchedGroupIds.length) {
34-
return true;
35-
}
36-
return 'indeterminate' as const;
37-
}, [summary, matchedGroupIds]);
20+
const checkedState =
21+
selectedCount === 0
22+
? false
23+
: selectedCount === matchedGroupIds.length
24+
? true
25+
: ('indeterminate' as const);
3826

3927
const handleChange = useCallback(
4028
(evt: React.MouseEvent) => {
@@ -45,7 +33,7 @@ export function SupergroupCheckbox({matchedGroupIds}: SupergroupCheckboxProps) {
4533
[actions, matchedGroupIds, checkedState]
4634
);
4735

48-
if (!summary || !actions) {
36+
if (!actions) {
4937
return null;
5038
}
5139

static/app/components/stream/supergroupRow.tsx

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,6 @@ export function SupergroupRow({
3838
memberList,
3939
}: SupergroupRowProps) {
4040
const matchedCount = matchedGroupIds.length;
41-
const summary = useOptionalIssueSelectionSummary();
42-
const selectedCount = useMemo(() => {
43-
if (!summary) {
44-
return 0;
45-
}
46-
let count = 0;
47-
for (const id of matchedGroupIds) {
48-
if (summary.records.get(id)) {
49-
count++;
50-
}
51-
}
52-
return count;
53-
}, [summary, matchedGroupIds]);
5441
const {openDrawer, isDrawerOpen} = useDrawer();
5542
const [isActive, setIsActive] = useState(false);
5643
const handleClick = () => {
@@ -71,14 +58,31 @@ export function SupergroupRow({
7158
);
7259
};
7360

61+
const summary = useOptionalIssueSelectionSummary();
62+
const selectedCount = useMemo(() => {
63+
if (!summary) {
64+
return 0;
65+
}
66+
let count = 0;
67+
for (const id of matchedGroupIds) {
68+
if (summary.records.get(id)) {
69+
count++;
70+
}
71+
}
72+
return count;
73+
}, [summary, matchedGroupIds]);
74+
7475
const highlighted = isActive && isDrawerOpen;
7576

7677
return (
7778
<Wrapper onClick={handleClick} highlighted={highlighted}>
7879
<InteractionStateLayer />
7980
<IconArea>
8081
<AccentIcon size="md" />
81-
<SupergroupCheckbox matchedGroupIds={matchedGroupIds} />
82+
<SupergroupCheckbox
83+
matchedGroupIds={matchedGroupIds}
84+
selectedCount={selectedCount}
85+
/>
8286
</IconArea>
8387
<Summary>
8488
{supergroup.error_type ? (
@@ -99,7 +103,7 @@ export function SupergroupRow({
99103
{matchedCount > 0 ? (
100104
<Text
101105
size="sm"
102-
variant={selectedCount > 0 ? 'default' : 'muted'}
106+
variant={selectedCount > 0 ? 'primary' : 'muted'}
103107
bold={selectedCount > 0}
104108
>
105109
{selectedCount > 0

0 commit comments

Comments
 (0)