Skip to content

Commit 7cd9be5

Browse files
authored
Merge pull request #83 from pSpitzner/rc1_track_details
fixes #80
2 parents b17e003 + 25f962e commit 7cd9be5

File tree

3 files changed

+24
-34
lines changed

3 files changed

+24
-34
lines changed

frontend/src/components/import/candidates/candidateSelector.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,6 @@ function OverviewChanges({
865865
gridRow: "5",
866866
}}
867867
/>
868-
869868
<TrackChangesDetailItem
870869
kind="extra_tracks"
871870
sx={{
@@ -928,54 +927,55 @@ function TrackChangesDetailItem({
928927
}: {
929928
kind: string;
930929
} & BoxProps) {
931-
const { extra_tracks, extra_items, candidate } = useTrackDiffContext();
930+
const { extra_tracks, extra_items, candidate, nChanges, pairs } =
931+
useTrackDiffContext();
932932

933933
const [open, setOpen] = useState(false);
934934

935935
const icon = <PenaltyTypeIcon type={kind} />;
936936
let text = "Track Changes";
937-
let i: string;
937+
let dialogTitle: string | null = null;
938+
let pl: string;
938939
let color: string | undefined = undefined;
939940
let tooltip: string | undefined = undefined;
940941
let content: ReactNode | null = null;
942+
941943
switch (kind) {
942944
case "track_changes":
943-
content = <TrackChanges />;
944945
if (candidate.penalties.includes("tracks")) {
945946
// TODO: get number of changed tracks, but that is currently
946947
// deeply nested in the subcomponent...
947948
text = "Tracks changed";
949+
dialogTitle = `${nChanges} of ${pairs.length} tracks changed`;
948950
color = "diffs.changed";
949951
tooltip =
950952
"Shows which items (on disk) are mapped to tracks (from the candidate). Changes are highlighted in red and green.";
953+
content = <TrackChanges />;
951954
} else {
952955
text = "No severe track changes";
953956
}
954957
break;
955958
case "extra_items":
956-
content = <ExtraTracks />;
957-
if (candidate.penalties.includes("unmatched_tracks")) {
958-
i = "item" + (extra_items.length !== 1 ? "s" : "");
959-
text = `${extra_items.length} ${i} items on disk not part of the candidate`;
959+
if (candidate.penalties.includes("missing_tracks")) {
960+
pl = "track" + (extra_tracks.length !== 1 ? "s" : "");
961+
text = `${extra_tracks.length} ${pl} missing on disk`;
960962
color = "diffs.changed";
961963
tooltip =
962-
"Items that could not be matched to tracks, they will be ignored if this candidate is chosen.";
964+
"Tracks found online that could not be matched to tracks on disk (usually because they are missing).";
965+
content = <ExtraTracks />;
963966
} else {
964-
text = "All items found on disk";
965-
content = undefined;
967+
text = "All tracks online present on disk";
966968
}
967969
break;
968970
case "extra_tracks":
969-
content = <ExtraItems />;
970-
if (candidate.penalties.includes("missing_tracks")) {
971-
i = "track" + (extra_tracks.length !== 1 ? "s" : "");
972-
text = `${extra_tracks.length} ${i} missing on disk`;
971+
if (candidate.penalties.includes("unmatched_tracks")) {
972+
pl = "item" + (extra_items.length !== 1 ? "s" : "");
973+
text = `${extra_items.length} ${pl} tracks on disk not part of the candidate`;
973974
color = "diffs.changed";
974-
tooltip =
975-
"Tracks that could not be matched to any items on disk (usually because they are missing).";
975+
tooltip = "Tracks on disk that could not be matched to tracks online.";
976+
content = <ExtraItems />;
976977
} else {
977-
text = "All tracks found online";
978-
content = undefined;
978+
text = "All tracks on disk found online";
979979
}
980980
break;
981981
default:
@@ -1000,7 +1000,7 @@ function TrackChangesDetailItem({
10001000
onClose={() => {
10011001
setOpen(false);
10021002
}}
1003-
title={text}
1003+
title={dialogTitle || text}
10041004
title_icon={icon}
10051005
>
10061006
<DialogContent>{content}</DialogContent>

frontend/src/components/import/candidates/diff.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
SxProps,
1717
Theme,
1818
Tooltip,
19-
Typography,
2019
useMediaQuery,
2120
useTheme,
2221
} from "@mui/material";
@@ -275,9 +274,6 @@ export function ExtraTracks() {
275274
}
276275
return (
277276
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
278-
<Typography variant="body2" color="diffs.light" pb={0.5}>
279-
{extra_tracks.length} tracks of candidate not found on disk
280-
</Typography>
281277
<TrackChangesGrid
282278
sx={{
283279
color: theme.palette.diffs.light,
@@ -304,9 +300,6 @@ export function ExtraItems() {
304300
}
305301
return (
306302
<Box sx={{ display: "flex", flexDirection: "column", alignItems: "center" }}>
307-
<Typography variant="body2" color="diffs.light" pb={0.5}>
308-
{extra_items.length} items on disk not part of the candidate
309-
</Typography>
310303
<TrackChangesGrid
311304
sx={{
312305
color: theme.palette.diffs.light,
@@ -330,7 +323,7 @@ export function ExtraItems() {
330323
* has to be used inside a TrackDiffContextProvider
331324
*/
332325
export function TrackChanges() {
333-
const { pairs, nChanges, setNChanges } = useTrackDiffContext();
326+
const { pairs, setNChanges } = useTrackDiffContext();
334327

335328
// force major change layout for all rows
336329
const [titleChange, setTitleChange] = useState(false);
@@ -347,9 +340,6 @@ export function TrackChanges() {
347340
alignItems: "center",
348341
}}
349342
>
350-
<Typography variant="body2" color="diffs.light" pb={0.5}>
351-
{nChanges} of {pairs.length} tracks changed
352-
</Typography>
353343
{/*Changes grid*/}
354344
<TrackChangesGrid>
355345
{pairs.map(([item, track], i) => (

frontend/src/components/import/icons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ import { PenaltyTypeIcon } from "../common/icons";
88

99
const penaltyOrder = [
1010
"artist",
11-
"tracks",
1211
"album",
12+
"tracks",
13+
"unmatched_tracks",
14+
"missing_tracks",
1315
"year",
1416
"label",
1517
"media",
16-
"missing_tracks",
17-
"unmatched_tracks",
1818
"mediums",
1919
"country",
2020
];

0 commit comments

Comments
 (0)