-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MBS-12572: Convert cdtoc/info to React
first_track and last_track seemed completely useless, so I'm just removing them and using a map on track_details. Since they didn't seem to be used elsewhere either, this also removes the methods.
- Loading branch information
1 parent
f5041ba
commit 8d8ebff
Showing
7 changed files
with
116 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* @flow strict-local | ||
* Copyright (C) 2022 MetaBrainz Foundation | ||
* | ||
* This file is part of MusicBrainz, the open internet music database, | ||
* and is licensed under the GPL version 2, or (at your option) any | ||
* later version: http://www.gnu.org/licenses/gpl-2.0.txt | ||
*/ | ||
|
||
import * as React from 'react'; | ||
|
||
import formatTrackLength | ||
from '../static/scripts/common/utility/formatTrackLength.js'; | ||
|
||
type Props = { | ||
+cdToc: CDTocT, | ||
}; | ||
|
||
function calculateFullToc(cdtoc: CDTocT) { | ||
const trackOffsets = cdtoc.track_offset.join(' '); | ||
return `1 ${cdtoc.track_count} ${cdtoc.leadout_offset} ${trackOffsets}`; | ||
} | ||
|
||
const CDTocInfo = ({cdToc}: Props): React.Element<typeof React.Fragment> => ( | ||
<> | ||
<h2>{l('CD TOC details')}</h2> | ||
|
||
<table> | ||
<tr> | ||
<th>{l('Full TOC:')}</th> | ||
<td>{calculateFullToc(cdToc)}</td> | ||
</tr> | ||
|
||
<tr> | ||
<th>{l('Disc ID:')}</th> | ||
<td><code>{cdToc.discid}</code></td> | ||
</tr> | ||
<tr> | ||
<th>{l('FreeDB:')}</th> | ||
<td>{cdToc.freedb_id}</td> | ||
</tr> | ||
<tr> | ||
<th>{l('Total tracks:')}</th> | ||
<td>{cdToc.track_count}</td> | ||
</tr> | ||
<tr> | ||
<th>{l('Total length:')}</th> | ||
<td>{formatTrackLength(cdToc.length)}</td> | ||
</tr> | ||
<tr> | ||
<th>{l('Track details:')}</th> | ||
<td> | ||
<table> | ||
<tr> | ||
<th rowSpan="2">{l('Track')}</th> | ||
<th colSpan="2">{l('Start')}</th> | ||
<th colSpan="2">{l('Length')}</th> | ||
<th colSpan="2">{l('End')}</th> | ||
</tr> | ||
<tr> | ||
<th>{l('Time')}</th> | ||
<th>{l('Sectors')}</th> | ||
<th>{l('Time')}</th> | ||
<th>{l('Sectors')}</th> | ||
<th>{l('Time')}</th> | ||
<th>{l('Sectors')}</th> | ||
</tr> | ||
{cdToc.track_details.map((track, index) => ( | ||
<tr key={index}> | ||
<td>{index + 1}</td> | ||
<td>{formatTrackLength(track.start_time)}</td> | ||
<td>{track.start_sectors}</td> | ||
<td>{formatTrackLength(track.length_time)}</td> | ||
<td>{track.length_sectors}</td> | ||
<td>{formatTrackLength(track.end_time)}</td> | ||
<td>{track.end_sectors}</td> | ||
</tr> | ||
))} | ||
</table> | ||
</td> | ||
</tr> | ||
</table> | ||
</> | ||
); | ||
|
||
export default CDTocInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters