(cherry picked from commit 3ddc6ac6de5c27a9aab915672321c8818dc5da48) Closes #10630pull/10650/head
parent
9ab3e6bab7
commit
3b9bd696fb
@ -0,0 +1,5 @@
|
||||
.actions {
|
||||
composes: cell from '~Components/Table/Cells/TableRowCell.css';
|
||||
|
||||
width: 70px;
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
// This file is automatically generated.
|
||||
// Please do not change this file!
|
||||
interface CssExports {
|
||||
'actions': string;
|
||||
}
|
||||
export const cssExports: CssExports;
|
||||
export default cssExports;
|
@ -0,0 +1,48 @@
|
||||
import React, { SyntheticEvent, useCallback } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import IconButton from 'Components/Link/IconButton';
|
||||
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
||||
import TableRowButton from 'Components/Table/TableRowButton';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import { removeFavoriteFolder } from 'Store/Actions/interactiveImportActions';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import styles from './FavoriteFolderRow.css';
|
||||
|
||||
interface FavoriteFolderRowProps {
|
||||
folder: string;
|
||||
onPress: (folder: string) => unknown;
|
||||
}
|
||||
|
||||
function FavoriteFolderRow({ folder, onPress }: FavoriteFolderRowProps) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handlePress = useCallback(() => {
|
||||
onPress(folder);
|
||||
}, [folder, onPress]);
|
||||
|
||||
const handleRemoveFavoritePress = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
dispatch(removeFavoriteFolder({ folder }));
|
||||
},
|
||||
[folder, dispatch]
|
||||
);
|
||||
|
||||
return (
|
||||
<TableRowButton onPress={handlePress}>
|
||||
<TableRowCell>{folder}</TableRowCell>
|
||||
|
||||
<TableRowCell className={styles.actions}>
|
||||
<IconButton
|
||||
title={translate('FavoriteFolderRemove')}
|
||||
kind="danger"
|
||||
name={icons.HEART}
|
||||
onPress={handleRemoveFavoritePress}
|
||||
/>
|
||||
</TableRowCell>
|
||||
</TableRowButton>
|
||||
);
|
||||
}
|
||||
|
||||
export default FavoriteFolderRow;
|
@ -1,6 +0,0 @@
|
||||
interface RecentFolder {
|
||||
folder: string;
|
||||
lastUsed: string;
|
||||
}
|
||||
|
||||
export default RecentFolder;
|
@ -1,5 +1,5 @@
|
||||
.actions {
|
||||
composes: cell from '~Components/Table/Cells/TableRowCell.css';
|
||||
|
||||
width: 40px;
|
||||
width: 70px;
|
||||
}
|
||||
|
@ -1,65 +0,0 @@
|
||||
import PropTypes from 'prop-types';
|
||||
import React, { Component } from 'react';
|
||||
import IconButton from 'Components/Link/IconButton';
|
||||
import RelativeDateCell from 'Components/Table/Cells/RelativeDateCell';
|
||||
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
||||
import TableRowButton from 'Components/Table/TableRowButton';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import styles from './RecentFolderRow.css';
|
||||
|
||||
class RecentFolderRow extends Component {
|
||||
|
||||
//
|
||||
// Listeners
|
||||
|
||||
onPress = () => {
|
||||
this.props.onPress(this.props.folder);
|
||||
};
|
||||
|
||||
onRemovePress = (event) => {
|
||||
event.stopPropagation();
|
||||
|
||||
const {
|
||||
folder,
|
||||
onRemoveRecentFolderPress
|
||||
} = this.props;
|
||||
|
||||
onRemoveRecentFolderPress(folder);
|
||||
};
|
||||
|
||||
//
|
||||
// Render
|
||||
|
||||
render() {
|
||||
const {
|
||||
folder,
|
||||
lastUsed
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<TableRowButton onPress={this.onPress}>
|
||||
<TableRowCell>{folder}</TableRowCell>
|
||||
|
||||
<RelativeDateCell date={lastUsed} />
|
||||
|
||||
<TableRowCell className={styles.actions}>
|
||||
<IconButton
|
||||
title={translate('Remove')}
|
||||
name={icons.REMOVE}
|
||||
onPress={this.onRemovePress}
|
||||
/>
|
||||
</TableRowCell>
|
||||
</TableRowButton>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RecentFolderRow.propTypes = {
|
||||
folder: PropTypes.string.isRequired,
|
||||
lastUsed: PropTypes.string.isRequired,
|
||||
onPress: PropTypes.func.isRequired,
|
||||
onRemoveRecentFolderPress: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
export default RecentFolderRow;
|
@ -0,0 +1,85 @@
|
||||
import React, { SyntheticEvent, useCallback } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import IconButton from 'Components/Link/IconButton';
|
||||
import RelativeDateCell from 'Components/Table/Cells/RelativeDateCell';
|
||||
import TableRowCell from 'Components/Table/Cells/TableRowCell';
|
||||
import TableRowButton from 'Components/Table/TableRowButton';
|
||||
import { icons } from 'Helpers/Props';
|
||||
import {
|
||||
addFavoriteFolder,
|
||||
removeFavoriteFolder,
|
||||
removeRecentFolder,
|
||||
} from 'Store/Actions/interactiveImportActions';
|
||||
import translate from 'Utilities/String/translate';
|
||||
import styles from './RecentFolderRow.css';
|
||||
|
||||
interface RecentFolderRowProps {
|
||||
folder: string;
|
||||
lastUsed: string;
|
||||
isFavorite: boolean;
|
||||
onPress: (folder: string) => unknown;
|
||||
}
|
||||
|
||||
function RecentFolderRow({
|
||||
folder,
|
||||
lastUsed,
|
||||
isFavorite,
|
||||
onPress,
|
||||
}: RecentFolderRowProps) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handlePress = useCallback(() => {
|
||||
onPress(folder);
|
||||
}, [folder, onPress]);
|
||||
|
||||
const handleFavoritePress = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
if (isFavorite) {
|
||||
dispatch(removeFavoriteFolder({ folder }));
|
||||
} else {
|
||||
dispatch(addFavoriteFolder({ folder }));
|
||||
}
|
||||
},
|
||||
[folder, isFavorite, dispatch]
|
||||
);
|
||||
|
||||
const handleRemovePress = useCallback(
|
||||
(e: SyntheticEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
dispatch(removeRecentFolder({ folder }));
|
||||
},
|
||||
[folder, dispatch]
|
||||
);
|
||||
|
||||
return (
|
||||
<TableRowButton onPress={handlePress}>
|
||||
<TableRowCell>{folder}</TableRowCell>
|
||||
|
||||
<RelativeDateCell date={lastUsed} />
|
||||
|
||||
<TableRowCell className={styles.actions}>
|
||||
<IconButton
|
||||
title={
|
||||
isFavorite
|
||||
? translate('FavoriteFolderRemove')
|
||||
: translate('FavoriteFolderAdd')
|
||||
}
|
||||
kind={isFavorite ? 'danger' : 'default'}
|
||||
name={isFavorite ? icons.HEART : icons.HEART_OUTLINE}
|
||||
onPress={handleFavoritePress}
|
||||
/>
|
||||
|
||||
<IconButton
|
||||
title={translate('Remove')}
|
||||
name={icons.REMOVE}
|
||||
onPress={handleRemovePress}
|
||||
/>
|
||||
</TableRowCell>
|
||||
</TableRowButton>
|
||||
);
|
||||
}
|
||||
|
||||
export default RecentFolderRow;
|
Loading…
Reference in new issue