-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: update item card and item table, factor out buttons, delete…
… items
- Loading branch information
Showing
22 changed files
with
432 additions
and
208 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { useTranslation } from 'react-i18next'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import PropTypes from 'prop-types'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import DeleteIcon from '@material-ui/icons/Delete'; | ||
import { deleteItems } from '../../actions/item'; | ||
import { ITEM_DELETE_BUTTON_CLASS } from '../../config/selectors'; | ||
|
||
const DeleteButton = ({ itemIds, dispatchDeleteItems, color }) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Tooltip title={t('Delete')}> | ||
<IconButton | ||
color={color} | ||
className={ITEM_DELETE_BUTTON_CLASS} | ||
aria-label="delete" | ||
onClick={() => dispatchDeleteItems(itemIds)} | ||
> | ||
<DeleteIcon /> | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
DeleteButton.propTypes = { | ||
itemIds: PropTypes.string.isRequired, | ||
dispatchDeleteItems: PropTypes.func.isRequired, | ||
color: PropTypes.string, | ||
}; | ||
|
||
DeleteButton.defaultProps = { | ||
color: '', | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
dispatchDeleteItems: deleteItems, | ||
}; | ||
|
||
const ConnectedComponent = connect(null, mapDispatchToProps)(DeleteButton); | ||
|
||
export default ConnectedComponent; |
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,42 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import EditIcon from '@material-ui/icons/Edit'; | ||
import { useTranslation } from 'react-i18next'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import { ITEM_MENU_EDIT_BUTTON_CLASS } from '../../config/selectors'; | ||
import { setEditModalSettings } from '../../actions/layout'; | ||
|
||
const Item = ({ itemId, dispatchSetEditModalSettings }) => { | ||
const { t } = useTranslation(); | ||
|
||
const handleEdit = () => { | ||
dispatchSetEditModalSettings({ open: true, itemId }); | ||
}; | ||
|
||
return ( | ||
<Tooltip title={t('Edit')}> | ||
<IconButton | ||
aria-label="edit" | ||
className={ITEM_MENU_EDIT_BUTTON_CLASS} | ||
onClick={handleEdit} | ||
> | ||
<EditIcon fontSize="small" /> | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
Item.propTypes = { | ||
itemId: PropTypes.string.isRequired, | ||
dispatchSetEditModalSettings: PropTypes.func.isRequired, | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
dispatchSetEditModalSettings: setEditModalSettings, | ||
}; | ||
|
||
const ConnectedComponent = connect(null, mapDispatchToProps)(Item); | ||
|
||
export default ConnectedComponent; |
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,42 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
import PropTypes from 'prop-types'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import ShareIcon from '@material-ui/icons/Share'; | ||
import { useTranslation } from 'react-i18next'; | ||
import Tooltip from '@material-ui/core/Tooltip'; | ||
import { ITEM_MENU_SHARE_BUTTON_CLASS } from '../../config/selectors'; | ||
import { setShareModalSettings } from '../../actions/layout'; | ||
|
||
const Item = ({ itemId, dispatchSetShareModalSettings }) => { | ||
const { t } = useTranslation(); | ||
|
||
const handleShare = () => { | ||
dispatchSetShareModalSettings({ open: true, itemId }); | ||
}; | ||
|
||
return ( | ||
<Tooltip title={t('Share')}> | ||
<IconButton | ||
aria-label="share" | ||
className={ITEM_MENU_SHARE_BUTTON_CLASS} | ||
onClick={handleShare} | ||
> | ||
<ShareIcon fontSize="small" /> | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
Item.propTypes = { | ||
itemId: PropTypes.string.isRequired, | ||
dispatchSetShareModalSettings: PropTypes.func.isRequired, | ||
}; | ||
|
||
const mapDispatchToProps = { | ||
dispatchSetShareModalSettings: setShareModalSettings, | ||
}; | ||
|
||
const ConnectedComponent = connect(null, mapDispatchToProps)(Item); | ||
|
||
export default ConnectedComponent; |
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,21 @@ | ||
import React from 'react'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ITEMS_GRID_NO_ITEM_ID } from '../../config/selectors'; | ||
|
||
const EmptyItem = () => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<Typography | ||
id={ITEMS_GRID_NO_ITEM_ID} | ||
variant="subtitle1" | ||
align="center" | ||
display="block" | ||
> | ||
{t('This item is empty.')} | ||
</Typography> | ||
); | ||
}; | ||
|
||
export default EmptyItem; |
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
Oops, something went wrong.