Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: condense item header options into a single menu #568

Merged
merged 23 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3b70f94
feat: initial functionality - not complete
jenniferarnesen Feb 14, 2020
9129548
feat: new header component
jenniferarnesen Feb 17, 2020
22cb332
feat: item header features
jenniferarnesen Feb 19, 2020
efbf12f
feat: adding more features, yay
jenniferarnesen Feb 19, 2020
7819058
fix: add submenu
jenniferarnesen Feb 20, 2020
94e35d4
fix: in progress
jenniferarnesen Feb 23, 2020
8e3b1c3
fix: in progress
jenniferarnesen Feb 24, 2020
ac85bca
fix: in progress
jenniferarnesen Feb 24, 2020
3e134ec
fix: fix tests
jenniferarnesen Feb 24, 2020
3f32af8
fix: in progress
jenniferarnesen Feb 24, 2020
42cf579
fix: remove Interpretations button
jenniferarnesen Feb 24, 2020
62e31a2
fix: mostly complete
jenniferarnesen Feb 24, 2020
4ee342a
fix: tweaks
jenniferarnesen Feb 24, 2020
6b7ba3f
fix: tweak
jenniferarnesen Feb 24, 2020
ee4473f
fix: translation improvements and fixes
jenniferarnesen Feb 25, 2020
98a53f6
fix: interpolation issue
jenniferarnesen Feb 25, 2020
fe19470
Merge branch 'master' into feat/new-item-header-backup
jenniferarnesen Feb 25, 2020
5541bb9
fix: unfinished test file
jenniferarnesen Feb 25, 2020
8f491ef
Merge branch 'feat/new-item-header-backup' of github.com:dhis2/dashbo…
jenniferarnesen Feb 25, 2020
2d154ea
fix: remove duplicated function
jenniferarnesen Feb 25, 2020
b805135
fix: restore snapshot test for ItemHeaderButtons
jenniferarnesen Feb 25, 2020
698903a
Merge branch 'master' into feat/new-item-header-backup
jenniferarnesen Feb 26, 2020
fb65019
Merge branch 'master' into feat/new-item-header-backup
jenniferarnesen Feb 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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} />
jenniferarnesen marked this conversation as resolved.
Show resolved Hide resolved
</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', {
jenniferarnesen marked this conversation as resolved.
Show resolved Hide resolved
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