Skip to content

Commit

Permalink
feat: condense item header options into a single menu (#568)
Browse files Browse the repository at this point in the history
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
jenniferarnesen authored Feb 26, 2020
1 parent afa9f73 commit 993981b
Show file tree
Hide file tree
Showing 27 changed files with 714 additions and 727 deletions.
36 changes: 27 additions & 9 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2020-02-12T20:02:08.021Z\n"
"PO-Revision-Date: 2020-02-12T20:02:08.021Z\n"
"POT-Creation-Date: 2020-02-25T15:24:49.055Z\n"
"PO-Revision-Date: 2020-02-25T15:24:49.055Z\n"

msgid "Dashboard"
msgstr ""
Expand Down Expand Up @@ -64,12 +64,18 @@ msgstr[1] ""
msgid "Remove"
msgstr ""

msgid "Delete item"
msgstr ""

msgid "Messages"
msgstr ""

msgid "See all messages"
msgstr ""

msgid "Item type \"{{type}}\" not supported"
msgstr ""

msgid "Spacer"
msgstr ""

Expand All @@ -88,6 +94,24 @@ msgstr ""
msgid "No data to display"
msgstr ""

msgid "Hide interpretations and details"
msgstr ""

msgid "Show interpretations and details"
msgstr ""

msgid "View as Chart"
msgstr ""

msgid "View as Table"
msgstr ""

msgid "View as Map"
msgstr ""

msgid "Open in {{appName}} app"
msgstr ""

msgid "Confirm"
msgstr ""

Expand Down Expand Up @@ -130,7 +154,7 @@ msgstr ""
msgid "Visualizations"
msgstr ""

msgid "Visualizer"
msgid "Pivot tables"
msgstr ""

msgid "Pivot tables"
Expand All @@ -145,15 +169,9 @@ msgstr ""
msgid "Event reports"
msgstr ""

msgid "Event Reports"
msgstr ""

msgid "Event charts"
msgstr ""

msgid "Event Visualizer"
msgstr ""

msgid "Apps"
msgstr ""

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@dhis2/d2-ui-translation-dialog": "^6.0.1",
"@dhis2/data-visualizer-plugin": "^34.3.3",
"@dhis2/prop-types": "^1.2.1",
"@dhis2/ui-core": "^4.9.1",
"@dhis2/ui-core": "^4.11.0",
"@dhis2/ui-widgets": "^2.0.5",
"@material-ui/core": "^3.9.2",
"@material-ui/icons": "^3.0.2",
Expand Down
78 changes: 41 additions & 37 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import i18n from '@dhis2/d2-i18n';
import { HeaderBar } from '@dhis2/ui-widgets';
import { CssVariables } from '@dhis2/ui-core';

import { EDIT, VIEW, NEW } from './Dashboard/dashboardModes';
import { acReceivedUser } from '../actions/user';
Expand All @@ -30,44 +31,47 @@ export class App extends Component {

render() {
return (
<div className="app-wrapper">
<div className="dashboard-header-bar">
<HeaderBar appName={i18n.t('Dashboard')} />
<>
<CssVariables colors spacers />
<div className="app-wrapper">
<div className="dashboard-header-bar">
<HeaderBar appName={i18n.t('Dashboard')} />
</div>
<Router>
<Switch>
<Route
exact
path="/"
render={props => (
<Dashboard {...props} mode={VIEW} />
)}
/>
<Route
exact
path="/new"
render={props => (
<Dashboard {...props} mode={NEW} />
)}
/>
<Route
exact
path="/:dashboardId"
render={props => (
<Dashboard {...props} mode={VIEW} />
)}
/>
<Route
exact
path="/:dashboardId/edit"
render={props => (
<Dashboard {...props} mode={EDIT} />
)}
/>
</Switch>
</Router>
<SnackbarMessage />
</div>
<Router>
<Switch>
<Route
exact
path="/"
render={props => (
<Dashboard {...props} mode={VIEW} />
)}
/>
<Route
exact
path="/new"
render={props => (
<Dashboard {...props} mode={NEW} />
)}
/>
<Route
exact
path="/:dashboardId"
render={props => (
<Dashboard {...props} mode={VIEW} />
)}
/>
<Route
exact
path="/:dashboardId/edit"
render={props => (
<Dashboard {...props} mode={EDIT} />
)}
/>
</Switch>
</Router>
<SnackbarMessage />
</div>
</>
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Item/AppItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const AppItem = ({ item, itemFilters }, context) => {

return appDetails && appDetails.name && appDetails.launchUrl ? (
<Fragment>
<ItemHeader title={appDetails.name} />
<ItemHeader title={appDetails.name} itemId={item.id} />
<Line />
<iframe
title={appDetails.name}
Expand Down
24 changes: 24 additions & 0 deletions src/components/Item/DeleteItemButton.js
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;
55 changes: 43 additions & 12 deletions src/components/Item/ItemHeader.js
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);
27 changes: 0 additions & 27 deletions src/components/Item/ItemHeaderButton.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Item/ListItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ListItem = (props, context) => {

return (
<Fragment>
<ItemHeader title={getItemTitle(item)} />
<ItemHeader title={getItemTitle(item)} itemId={item.id} />
<Line />
<div className="dashboard-item-content">
<ul className={classes.list}>
Expand Down
6 changes: 5 additions & 1 deletion src/components/Item/MessagesItem/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ class MessagesItem extends Component {
render() {
return (
<Fragment>
<ItemHeader title={i18n.t('Messages')} />
<ItemHeader
title={i18n.t('Messages')}
itemId={this.props.item.id}
/>
<Line />
{this.props.messages.length > 0 && (
<div className="dashboard-item-content">
Expand All @@ -127,6 +130,7 @@ class MessagesItem extends Component {

MessagesItem.propTypes = {
editMode: PropTypes.bool,
item: PropTypes.object,
messages: PropTypes.array,
};

Expand Down
8 changes: 7 additions & 1 deletion src/components/Item/NotSupportedItem/Item.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import i18n from '@dhis2/d2-i18n';
import ItemHeader from '../ItemHeader';
import NotInterestedIcon from '@material-ui/icons/NotInterested';

const NotSupportedItem = props => (
<Fragment>
<ItemHeader title={`Item type not supported: ${props.item.type}`} />
<ItemHeader
title={i18n.t('Item type "{{type}}" not supported', {
type: props.item.type,
})}
itemId={props.item.id}
/>
<div
style={{
display: 'flex',
Expand Down
9 changes: 7 additions & 2 deletions src/components/Item/SpacerItem/Item.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import i18n from '@dhis2/d2-i18n';

import { colors } from '@dhis2/ui-core';
Expand All @@ -11,10 +12,10 @@ const style = {
color: colors.grey600,
};

const SpacerItem = () => {
const SpacerItem = props => {
return (
<Fragment>
<ItemHeader title={i18n.t('Spacer')} />
<ItemHeader title={i18n.t('Spacer')} itemId={props.item.id} />
<p style={style}>
{i18n.t(
'Use a spacer to create empty vertical space between other dashboard items.'
Expand All @@ -24,4 +25,8 @@ const SpacerItem = () => {
);
};

SpacerItem.propTypes = {
item: PropTypes.object,
};

export default SpacerItem;
Loading

0 comments on commit 993981b

Please sign in to comment.