2018-01-13 02:01:27 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import formatBytes from 'Utilities/Number/formatBytes';
|
2019-08-17 03:54:03 +00:00
|
|
|
import { icons, kinds } from 'Helpers/Props';
|
|
|
|
import Label from 'Components/Label';
|
2018-01-13 02:01:27 +00:00
|
|
|
import IconButton from 'Components/Link/IconButton';
|
|
|
|
import Link from 'Components/Link/Link';
|
|
|
|
import TableRow from 'Components/Table/TableRow';
|
|
|
|
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
2019-01-02 01:38:21 +00:00
|
|
|
import styles from './RootFolderRow.css';
|
2018-01-13 02:01:27 +00:00
|
|
|
|
2019-01-02 01:38:21 +00:00
|
|
|
function RootFolderRow(props) {
|
2018-01-13 02:01:27 +00:00
|
|
|
const {
|
|
|
|
id,
|
|
|
|
path,
|
|
|
|
freeSpace,
|
|
|
|
unmappedFolders,
|
|
|
|
onDeletePress
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
const unmappedFoldersCount = unmappedFolders.length || '-';
|
2019-08-17 03:54:03 +00:00
|
|
|
const isUnavailable = freeSpace == null;
|
2018-01-13 02:01:27 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<TableRow>
|
|
|
|
<TableRowCell>
|
2019-08-17 03:54:03 +00:00
|
|
|
{
|
|
|
|
isUnavailable ?
|
|
|
|
<div className={styles.unavailablePath}>
|
|
|
|
{path}
|
|
|
|
|
|
|
|
<Label
|
|
|
|
className={styles.unavailableLabel}
|
|
|
|
kind={kinds.DANGER}
|
|
|
|
>
|
|
|
|
Unavailable
|
|
|
|
</Label>
|
|
|
|
</div> :
|
|
|
|
|
|
|
|
<Link
|
|
|
|
className={styles.link}
|
|
|
|
to={`/add/import/${id}`}
|
|
|
|
>
|
|
|
|
{path}
|
|
|
|
</Link>
|
|
|
|
}
|
2018-01-13 02:01:27 +00:00
|
|
|
</TableRowCell>
|
|
|
|
|
|
|
|
<TableRowCell className={styles.freeSpace}>
|
2019-08-17 03:54:03 +00:00
|
|
|
{freeSpace ? formatBytes(freeSpace) : '-'}
|
2018-01-13 02:01:27 +00:00
|
|
|
</TableRowCell>
|
|
|
|
|
|
|
|
<TableRowCell className={styles.unmappedFolders}>
|
|
|
|
{unmappedFoldersCount}
|
|
|
|
</TableRowCell>
|
|
|
|
|
|
|
|
<TableRowCell className={styles.actions}>
|
|
|
|
<IconButton
|
|
|
|
title="Remove root folder"
|
|
|
|
name={icons.REMOVE}
|
|
|
|
onPress={onDeletePress}
|
|
|
|
/>
|
|
|
|
</TableRowCell>
|
|
|
|
</TableRow>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-01-02 01:38:21 +00:00
|
|
|
RootFolderRow.propTypes = {
|
2018-01-13 02:01:27 +00:00
|
|
|
id: PropTypes.number.isRequired,
|
|
|
|
path: PropTypes.string.isRequired,
|
2019-08-17 03:54:03 +00:00
|
|
|
freeSpace: PropTypes.number,
|
2018-01-13 02:01:27 +00:00
|
|
|
unmappedFolders: PropTypes.arrayOf(PropTypes.object).isRequired,
|
|
|
|
onDeletePress: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
2019-01-02 01:38:21 +00:00
|
|
|
RootFolderRow.defaultProps = {
|
2018-01-13 02:01:27 +00:00
|
|
|
unmappedFolders: []
|
|
|
|
};
|
|
|
|
|
2019-01-02 01:38:21 +00:00
|
|
|
export default RootFolderRow;
|