-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: condense item header options into a single menu (#568)
All options in the dashboard item, for a visualization, are now moved to a single button with a dropdown menu. This includes the "View as" options for switching between Map, Table, Chart, as well as show/hideing the interpretations and open the Vis in the corresponding app. This commit also fixes wrapping issues when for the item title when the item is narrow.
- Loading branch information
1 parent
afa9f73
commit 993981b
Showing
27 changed files
with
714 additions
and
727 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,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import i18n from '@dhis2/d2-i18n'; | ||
import DeleteIcon from '@material-ui/icons/Delete'; | ||
import { colors } from '@dhis2/ui-core'; | ||
|
||
import classes from './styles/DeleteItemButton.module.css'; | ||
|
||
const DeleteItemButton = ({ onClick }) => ( | ||
<button | ||
type="button" | ||
className={classes.deleteItemButton} | ||
onClick={onClick} | ||
title={i18n.t(`Delete item`)} | ||
> | ||
<DeleteIcon style={{ fill: colors.red500 }} /> | ||
</button> | ||
); | ||
|
||
DeleteItemButton.propTypes = { | ||
onClick: PropTypes.func, | ||
}; | ||
|
||
export default DeleteItemButton; |
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 |
---|---|---|
@@ -1,28 +1,59 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
|
||
export const HEADER_HEIGHT = 45; | ||
import { sGetIsEditing } from '../../reducers/editDashboard'; | ||
import { acRemoveDashboardItem } from '../../actions/editDashboard'; | ||
import DeleteItemButton from './DeleteItemButton'; | ||
|
||
import classes from './styles/ItemHeader.module.css'; | ||
|
||
const ItemHeader = props => { | ||
const { title, actionButtons, editMode } = props; | ||
const { | ||
title, | ||
editMode, | ||
actionButtons, | ||
itemId, | ||
acRemoveDashboardItem, | ||
} = props; | ||
|
||
const handleDeleteItem = () => acRemoveDashboardItem(itemId); | ||
|
||
return ( | ||
<div className="dashboard-item-header"> | ||
<div | ||
className="dashboard-item-header-title" | ||
style={{ userSelect: editMode ? 'none' : 'text' }} | ||
> | ||
{title} | ||
</div> | ||
{actionButtons} | ||
<div className={classes.itemHeaderWrap}> | ||
<p className={classes.itemTitle}>{title}</p> | ||
{editMode ? ( | ||
<div className={classes.itemActionsWrap}> | ||
<DeleteItemButton onClick={handleDeleteItem} /> | ||
</div> | ||
) : ( | ||
actionButtons && ( | ||
<div className={classes.itemActionsWrap}> | ||
{actionButtons} | ||
</div> | ||
) | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
ItemHeader.propTypes = { | ||
acRemoveDashboardItem: PropTypes.func, | ||
actionButtons: PropTypes.node, | ||
editMode: PropTypes.bool, | ||
title: PropTypes.oneOfType([PropTypes.object, PropTypes.string]), | ||
itemId: PropTypes.string, | ||
title: PropTypes.string, | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
editMode: sGetIsEditing(state), | ||
}); | ||
|
||
const mapDispatchToProps = { | ||
acRemoveDashboardItem, | ||
}; | ||
|
||
export default ItemHeader; | ||
export default connect( | ||
mapStateToProps, | ||
mapDispatchToProps | ||
)(ItemHeader); |
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
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.