Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 34 additions & 11 deletions frontend/src/Author/Delete/DeleteAuthorModalContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,20 @@ class DeleteAuthorModalContent extends Component {
const {
authorName,
path,
audiobookFolder,
ebookFolder,
statistics,
onModalClose
} = this.props;

// An author can have a separate audiobook and ebook folder (plus the legacy single path). Deleting
// with "delete files" removes all of them, so list every distinct one instead of only `path`.
// The API exposes the format folders as audiobookFolder / ebookFolder (AuthorResource) - not
// audiobookPath / ebookPath, which are null on the resource.
const paths = [path, audiobookFolder, ebookFolder]
.filter((folder) => !!folder && folder.trim() !== '')
.filter((folder, index, all) => all.indexOf(folder) === index);

const {
bookFileCount,
sizeOnDisk
Expand All @@ -93,14 +103,21 @@ class DeleteAuthorModalContent extends Component {
</ModalHeader>

<ModalBody>
<div className={styles.pathContainer}>
<Icon
className={styles.pathIcon}
name={icons.FOLDER}
/>

{path}
</div>
{
paths.map((folder) => (
<div
key={folder}
className={styles.pathContainer}
>
<Icon
className={styles.pathIcon}
name={icons.FOLDER}
/>

{folder}
</div>
))
}

<FormGroup>
<FormLabel>{deleteFilesLabel}</FormLabel>
Expand Down Expand Up @@ -149,9 +166,13 @@ class DeleteAuthorModalContent extends Component {
{
deleteFiles &&
<div className={styles.deleteFilesMessage}>
<div>
{translate('TheAuthorFolderAndAllOfItsContentWillBeDeleted', [path])}
</div>
{
paths.map((folder) => (
<div key={folder}>
{translate('TheAuthorFolderAndAllOfItsContentWillBeDeleted', [folder])}
</div>
))
}

{
!!bookFileCount &&
Expand Down Expand Up @@ -182,6 +203,8 @@ class DeleteAuthorModalContent extends Component {
DeleteAuthorModalContent.propTypes = {
authorName: PropTypes.string.isRequired,
path: PropTypes.string.isRequired,
audiobookFolder: PropTypes.string,
ebookFolder: PropTypes.string,
statistics: PropTypes.object.isRequired,
onDeletePress: PropTypes.func.isRequired,
onModalClose: PropTypes.func.isRequired
Expand Down