1- import { ImportIcon } from "lucide-react" ;
1+ import { ImportIcon , LibraryIcon , UndoIcon } from "lucide-react" ;
22import {
33 Alert ,
44 AlertProps ,
@@ -8,13 +8,15 @@ import {
88 Card ,
99 Divider ,
1010 Skeleton ,
11+ Typography ,
12+ useTheme ,
1113} from "@mui/material" ;
1214import { useMutation , useQuery } from "@tanstack/react-query" ;
15+ import { Link } from "@tanstack/react-router" ;
1316
1417import { APIError } from "@/api/common" ;
1518import { albumImportedOptions } from "@/api/library" ;
1619import { enqueueMutationOptions , sessionQueryOptions } from "@/api/session" ;
17- import { BackButton } from "@/components/common/inputs/back" ;
1820import { humanizeBytes } from "@/components/common/units/bytes" ;
1921import { relativeTime } from "@/components/common/units/time" ;
2022import { useStatusSocket } from "@/components/common/websocket/status" ;
@@ -36,6 +38,7 @@ export function ImportedCard({
3638 folderHash : string ;
3739 folderPath : string ;
3840} ) {
41+ const theme = useTheme ( ) ;
3942 const { data : session } = useQuery (
4043 sessionQueryOptions ( {
4144 folderPath,
@@ -64,20 +67,26 @@ export function ImportedCard({
6467 title = "Imported into beets library"
6568 // FIXME: Timezones seem broken, at least for me it is 2 hours off
6669 subtitle = { "Imported " + relativeTime ( session . updated_at ) }
67- />
70+ >
71+ < Box sx = { { ml : "auto" , alignSelf : "flex-start" } } >
72+ { session . tasks . length > 1 && (
73+ < Typography variant = "caption" component = "div" textAlign = "right" >
74+ { session . tasks . length } tasks completed
75+ </ Typography >
76+ ) }
77+ </ Box >
78+ </ CardHeader >
6879 < Divider />
6980 < Box sx = { { display : "flex" , flexDirection : "column" , gap : 1 } } >
7081 { session . tasks . map ( ( task ) => (
7182 < ImportedTaskInfo key = { task . id } task = { task } />
7283 ) ) }
7384 </ Box >
7485 < Box display = "flex" gap = { 2 } >
75- < BackButton variant = "outlined" color = "secondary" size = "medium" />
7686 < Button
7787 variant = "outlined"
7888 color = "secondary"
7989 loading = { isPending }
80- sx = { { ml : "auto" } }
8190 onClick = { ( ) => {
8291 mutate ( {
8392 socket,
@@ -89,6 +98,7 @@ export function ImportedCard({
8998 delete_files : true ,
9099 } ) ;
91100 } }
101+ startIcon = { < UndoIcon size = { theme . iconSize . md } /> }
92102 >
93103 Undo Import
94104 </ Button >
@@ -100,11 +110,12 @@ export function ImportedCard({
100110// Shows some information on the imported album
101111// using the beets library
102112function ImportedTaskInfo ( { task } : { task : SerializedTaskState } ) {
113+ const theme = useTheme ( ) ;
103114 const {
104115 data : album ,
105116 error,
106117 isPending,
107- } = useQuery ( albumImportedOptions ( task . id , true , true ) ) ;
118+ } = useQuery ( albumImportedOptions ( task . id , true , false ) ) ;
108119
109120 const chosenCandidate = task . candidates . find (
110121 ( c ) => c . id === task . chosen_candidate_id
@@ -120,9 +131,9 @@ function ImportedTaskInfo({ task }: { task: SerializedTaskState }) {
120131 throw error ;
121132 }
122133
123- return (
124- < Box >
125- { isPending && (
134+ if ( isPending ) {
135+ return (
136+ < Box >
126137 < Skeleton
127138 variant = "rectangular"
128139 width = "100%"
@@ -131,9 +142,74 @@ function ImportedTaskInfo({ task }: { task: SerializedTaskState }) {
131142 borderRadius : 1 ,
132143 } }
133144 />
134- ) }
135- { task . duplicate_action }
136- { album && < AlbumInfo album = { album } /> }
145+ </ Box >
146+ ) ;
147+ }
148+
149+ return (
150+ < Box
151+ sx = { {
152+ display : "flex" ,
153+ gap : 1 ,
154+ width : "100%" ,
155+ } }
156+ >
157+ < Box
158+ sx = { {
159+ display : "flex" ,
160+ flexDirection : "row" ,
161+ flexGrow : 1 ,
162+ flexWrap : "wrap" ,
163+ columnGap : 1 ,
164+ label : {
165+ color : "text.secondary" ,
166+ } ,
167+ } }
168+ >
169+ < Typography variant = "h6" component = "div" sx = { { width : "100%" } } >
170+ { album . albumartist } - { album . name }
171+ </ Typography >
172+ < Box >
173+ < Typography variant = "body2" component = "label" >
174+ Source:
175+ </ Typography >
176+ < Typography variant = "body1" component = "div" ml = { 1 } >
177+ { task . toppath || task . paths . join ( ", " ) }
178+ </ Typography >
179+ </ Box >
180+ < Box >
181+ < Typography variant = "body2" component = "label" >
182+ Destination:
183+ </ Typography >
184+ < Typography variant = "body1" component = "div" ml = { 1 } >
185+ { album . items . at ( 0 ) ?. path . split ( "/" ) . slice ( 0 , - 1 ) . join ( "/" ) }
186+ </ Typography >
187+ </ Box >
188+ < Box >
189+ < Typography variant = "body2" component = "label" >
190+ Operation:
191+ </ Typography >
192+ < Typography variant = "body1" component = "div" ml = { 1 } >
193+ { /* TODO: Hardcoded for now, should be dynamic */ }
194+ COPY
195+ </ Typography >
196+ </ Box >
197+ </ Box >
198+ < Box sx = { { flexGrow : "0 1" , ml : "auto" , mt : "auto" } } >
199+ < Link
200+ to = "/library/album/$albumId"
201+ params = { { albumId : album . id } }
202+ style = { { textDecoration : "none" , height : "100%" } }
203+ >
204+ < Button
205+ variant = "contained"
206+ color = "secondary"
207+ startIcon = { < LibraryIcon size = { theme . iconSize . md } /> }
208+ >
209+ View Album
210+ </ Button >
211+ </ Link >
212+ </ Box >
137213 </ Box >
138214 ) ;
139215}
0 commit comments