Skip to content

Commit eb114b9

Browse files
authored
Merge pull request #399 from AppQuality/UN-414-row-item-pills
UN-414-row-item-pills
2 parents 1e31e9b + 907fbd7 commit eb114b9

File tree

4 files changed

+66
-55
lines changed

4 files changed

+66
-55
lines changed

src/features/bugsPage/bugsPageSlice.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const bugPageSlice = createSlice({
4646
};
4747
state.currentCampaign = cp_id;
4848
},
49-
selectBug: (state, action) => {
49+
selectBug: (state, action: { payload: { bug_id?: number } }) => {
5050
const { bug_id } = action.payload;
5151
if (!state.currentCampaign) return;
5252
if (!(state.currentCampaign in state.campaigns)) return;

src/pages/Bugs/BugsTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const BugsTable = ({ campaignId }: { campaignId: number }) => {
1717
columns={columns}
1818
data={data}
1919
selectedRow={currentBugId ? currentBugId.toString() : null}
20-
onRowClick={(bug_id) => dispatch(selectBug({ bug_id }))}
20+
onRowClick={(bug_id) => dispatch(selectBug({ bug_id: Number(bug_id) }))}
2121
isSticky
2222
isLoading={isLoading}
2323
loadingRowHeight="70px"

src/pages/Bugs/BugsTable/useTableData.tsx

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ import { ColumnDefinitionType } from 'src/common/components/Table';
55
import { theme } from 'src/app/theme';
66
import { Pipe } from 'src/common/components/Pipe';
77
import { useTranslation } from 'react-i18next';
8-
import { getSelectedFiltersIds } from 'src/features/bugsPage/bugsPageSlice';
8+
import {
9+
getSelectedBugId,
10+
getSelectedFiltersIds,
11+
} from 'src/features/bugsPage/bugsPageSlice';
912
import { useGetCampaignsByCidBugsQuery } from 'src/features/api';
1013
import { TableDatum } from './types';
1114
import { BugTitle } from './BugTitle';
1215

1316
export const useTableData = (campaignId: number) => {
1417
const { t } = useTranslation();
15-
18+
const currentBugId = getSelectedBugId();
1619
const filterBy = getSelectedFiltersIds();
1720

1821
const columns: ColumnDefinitionType<TableDatum, keyof TableDatum>[] = [
@@ -59,56 +62,64 @@ export const useTableData = (campaignId: number) => {
5962

6063
const mapBugsToTableData = useMemo<TableDatum[]>(() => {
6164
if (!bugs || !bugs.items) return [];
62-
return bugs.items.map((bug) => ({
63-
id: bug.id.toString(),
64-
bugId: (
65-
<span style={{ color: theme.palette.grey[700] }}>
66-
{bug.id.toString()}
67-
</span>
68-
),
69-
severity: (
70-
<SeverityPill
71-
severity={bug.severity.name.toLowerCase() as Severities}
72-
/>
73-
),
74-
title: (
75-
<div>
76-
<BugTitle isUnread={!bug.read}>{bug.title.compact}</BugTitle>
77-
{bug.title.context && (
78-
<Pill isBold={!bug.read}>{bug.title.context}</Pill>
79-
)}
80-
{bug.tags?.map((tag) => (
81-
<Pill isBold={!bug.read}>{tag.tag_name}</Pill>
82-
))}
83-
{bug.type.name && (
84-
<>
85-
<Pipe size="small" />
86-
<Pill isBold style={{ marginLeft: theme.space.xs }}>
87-
{bug.type.name}
88-
</Pill>
89-
</>
90-
)}
91-
{!bug.read && (
92-
<>
93-
<Pipe size="small" />
94-
<Pill
95-
isBold
96-
backgroundColor="transparent"
97-
color={theme.palette.blue[600]}
98-
>
99-
{t('__PAGE_BUGS_UNREAD_PILL', 'Unread')}
100-
</Pill>
101-
</>
102-
)}
103-
</div>
104-
),
105-
isHighlighted: !bug.read,
106-
created: bug.created,
107-
updated: bug.updated,
108-
borderColor:
109-
theme.colors.bySeverity[bug.severity.name.toLowerCase() as Severities],
110-
}));
111-
}, [bugs]);
65+
return bugs.items.map((bug) => {
66+
const isPillBold = (currentBugId && currentBugId === bug.id) || !bug.read;
67+
return {
68+
id: bug.id.toString(),
69+
bugId: (
70+
<span style={{ color: theme.palette.grey[700] }}>
71+
{bug.id.toString()}
72+
</span>
73+
),
74+
severity: (
75+
<SeverityPill
76+
severity={bug.severity.name.toLowerCase() as Severities}
77+
/>
78+
),
79+
title: (
80+
<div>
81+
<BugTitle isUnread={!bug.read}>{bug.title.compact}</BugTitle>
82+
{bug.title.context && (
83+
<Pill isBold={isPillBold}>{bug.title.context}</Pill>
84+
)}
85+
{bug.tags?.map((tag) => (
86+
<Pill isBold={isPillBold}>{tag.tag_name}</Pill>
87+
))}
88+
{bug.type.name && (
89+
<>
90+
<Pipe size="small" />
91+
<Pill
92+
isBold={isPillBold}
93+
style={{ marginLeft: theme.space.xs }}
94+
>
95+
{bug.type.name}
96+
</Pill>
97+
</>
98+
)}
99+
{!bug.read && (
100+
<>
101+
<Pipe size="small" />
102+
<Pill
103+
isBold
104+
backgroundColor="transparent"
105+
color={theme.palette.blue[600]}
106+
>
107+
{t('__PAGE_BUGS_UNREAD_PILL', 'Unread')}
108+
</Pill>
109+
</>
110+
)}
111+
</div>
112+
),
113+
isHighlighted: !bug.read,
114+
created: bug.created,
115+
updated: bug.updated,
116+
borderColor:
117+
theme.colors.bySeverity[
118+
bug.severity.name.toLowerCase() as Severities
119+
],
120+
};
121+
});
122+
}, [bugs, currentBugId]);
112123

113124
if (isLoading || isFetching || !bugs || !bugs.items)
114125
return { columns, data: [], isLoading: true };

src/pages/Bugs/Detail/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default ({
4343
onClick={() => {
4444
dispatch(
4545
selectBug({
46-
bug_id: null,
46+
bug_id: undefined,
4747
})
4848
);
4949
}}

0 commit comments

Comments
 (0)