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: [DHIS2-17874] Replace the SnackBar MenuList MenuItem Grow and remaining Icons #3766

Closed
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f93d1fa
feat: temp
henrikmv Aug 20, 2024
d6db29d
feat: temp
henrikmv Aug 28, 2024
c46d485
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Aug 28, 2024
ef953ca
feat: temp
henrikmv Aug 30, 2024
97962e7
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-17874…
henrikmv Aug 30, 2024
27be0a4
fix: menuitem without label prop
henrikmv Aug 30, 2024
d933f78
fix: remove console log
henrikmv Aug 30, 2024
87410a7
feat: change to dropdown button
henrikmv Aug 30, 2024
a331b5a
fix: inline close button
henrikmv Aug 30, 2024
05d5926
fix: change mui icons
henrikmv Aug 30, 2024
e77613c
feat: remove create svg icon
henrikmv Sep 2, 2024
efbbd26
feat: simplify feedbackbar component
henrikmv Sep 2, 2024
ccd441d
fix: add missing data test prop
henrikmv Sep 2, 2024
7cb156d
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Sep 2, 2024
faea6d4
fix: missing data test prop
henrikmv Sep 2, 2024
f4f6e7a
fix: delete unused files
henrikmv Sep 2, 2024
2aecaac
fix: toggle popper is not a function
henrikmv Sep 2, 2024
bef445a
fix: close popper when menu item click
henrikmv Sep 3, 2024
7901562
fix: self opening item for filter on click
henrikmv Sep 3, 2024
1f16eb0
fix: missing filter functionality
henrikmv Sep 4, 2024
25c8912
fix: max height on flyout menu
henrikmv Sep 4, 2024
2bea51b
fix: after review changes
henrikmv Sep 7, 2024
4c09ce2
Merge remote-tracking branch 'origin/master' into hv/feat/DHIS2-17874…
henrikmv Sep 7, 2024
18585df
fix: lint
henrikmv Sep 7, 2024
2fe25c8
fix: temp
henrikmv Sep 7, 2024
d10215a
feat; remove paper
henrikmv Sep 7, 2024
f1e80b7
feat: remove itembuttons
henrikmv Sep 7, 2024
35d58b2
feat: remove popover
henrikmv Sep 7, 2024
7513d11
feat: remove menuitem
henrikmv Sep 8, 2024
d7ae629
feat: remove menuitem
henrikmv Sep 8, 2024
a443e78
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
eddf061
feat: remove paper
henrikmv Sep 8, 2024
e20a652
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
637a154
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
35deb2d
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
eb59e0f
feat; remove paper
henrikmv Sep 7, 2024
6572823
feat: remove menuitem
henrikmv Sep 8, 2024
63b23e9
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
bd68457
feat; remove paper
henrikmv Sep 7, 2024
09823a5
feat: remove menuitem
henrikmv Sep 8, 2024
5697088
Merge branch 'hv/feat/DHIS2-17874_ReplaceSnackBarMenuListGrowIcons' o…
henrikmv Sep 8, 2024
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
13 changes: 2 additions & 11 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: 2024-08-10T10:42:21.141Z\n"
"PO-Revision-Date: 2024-08-10T10:42:21.141Z\n"
"POT-Creation-Date: 2024-09-02T13:49:55.522Z\n"
"PO-Revision-Date: 2024-09-02T13:49:55.522Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -598,15 +598,6 @@ msgstr "Program doesn't exist"
msgid "Selected program is invalid for selected organisation unit"
msgstr "Selected program is invalid for selected organisation unit"

msgid "Online"
msgstr "Online"

msgid "Offline"
msgstr "Offline"

msgid "Syncing"
msgstr "Syncing"

msgid "Add note"
msgstr "Add note"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @flow
import * as React from 'react';
import SnackBar from '@material-ui/core/Snackbar';
import React, { useState, type Node } from 'react';
import { withStyles } from '@material-ui/core/styles';
import { IconButton } from 'capture-ui';
import { IconCross24, Button, Modal, ModalTitle, ModalContent, ModalActions } from '@dhis2/ui';
import { Button, Modal, ModalTitle, ModalContent, ModalActions, AlertStack, AlertBar } from '@dhis2/ui';
import i18n from '@dhis2/d2-i18n';
import isDefined from 'd2-utilizr/lib/isDefined';

const styles = () => ({
closeButton: {
Expand All @@ -17,110 +14,49 @@ const styles = () => ({
});

type Feedback = {
message: string | { title: string, content: string},
action?: ?React.Node,
displayType?: ?string,
message: string | { title: string, content: string },
action?: Node,
displayType?: 'alert' | 'dialog',
};

type Props = {
feedback: Feedback,
onClose: () => void,
classes: Object,
};

class Index extends React.Component<Props> {
static defaultProps = {
feedback: {},
};

constructor(props: Props) {
super(props);
this.handleClose = this.handleClose.bind(this);
}
static CLICKAWAY_KEY = 'clickaway';
const FeedbackBarComponentPlain = ({ feedback = {}, onClose }: Props) => {
const [hide, setHide] = useState(false);
const { message, displayType } = feedback;
const isAlertBarOpen = typeof message === 'string' && !displayType;
const isDialogOpen = typeof message === 'object' && displayType === 'dialog';

static ANCHOR_ORIGIN = {
vertical: 'bottom',
horizontal: 'center',
const handleClose = () => {
setHide(true);
onClose();
};

handleClose = (event?: ?Object, reason?: ?string) => {
if (reason !== Index.CLICKAWAY_KEY) {
this.props.onClose();
}
}

getAction() {
const { feedback, classes } = this.props;

return (
<>
{
(() => {
if (!feedback.action) {
return null;
}

return (
<span
className={classes.actionContainer}
>
{feedback.action}
</span>
);
})()
}
<IconButton
className={classes.closeButton}
onClick={this.handleClose}
>
<IconCross24 />
</IconButton>
</>
);
}

render() {
const { feedback } = this.props;
const { message, displayType } = feedback;
const isSnackBarOpen = isDefined(message) && !displayType;
const isDialogOpen = isDefined(message) && displayType === 'dialog';
return (
<React.Fragment>
<SnackBar
open={isSnackBarOpen}
anchorOrigin={Index.ANCHOR_ORIGIN}
autoHideDuration={5000}
onClose={this.handleClose}
// $FlowFixMe[incompatible-type] automated comment
message={<span>{message}</span>}
action={this.getAction()}
/>
{isDialogOpen && (
<Modal
hide={!isDialogOpen}
>
<ModalTitle>
{
// $FlowFixMe[prop-missing] automated comment
isDialogOpen ? message && message.title : ''}
</ModalTitle>
<ModalContent>
{
// $FlowFixMe[prop-missing] automated comment
isDialogOpen ? message && message.content : ''}
</ModalContent>
<ModalActions>
<Button onClick={this.handleClose} primary>
{i18n.t('Close')}
</Button>
</ModalActions>
</Modal>
return (
<>
<AlertStack>
{isAlertBarOpen && (
<AlertBar duration={5000}>
{message}
</AlertBar>
)}
</React.Fragment>
);
}
}
Index.displayName = 'FeedbackBar';
</AlertStack>
{isDialogOpen && (
<Modal hide={hide}>
henrikmv marked this conversation as resolved.
Show resolved Hide resolved
<ModalTitle>{message.title || ''}</ModalTitle>
<ModalContent>{message.content || ''}</ModalContent>
<ModalActions>
<Button onClick={handleClose} primary>
{i18n.t('Close')}
</Button>
</ModalActions>
</Modal>
)}
</>
);
};

export const FeedbackBarComponent = withStyles(styles)(Index);
export const FeedbackBarComponent = withStyles(styles)(FeedbackBarComponentPlain);
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
// @flow
import * as React from 'react';
import { withStyles } from '@material-ui/core/styles';
import createSvgIcon from '@material-ui/icons/utils/createSvgIcon';
import { Tooltip, Button } from '@dhis2/ui';
import { Tooltip, Button, spacers } from '@dhis2/ui';
import i18n from '@dhis2/d2-i18n';
import classNames from 'classnames';

const ClearIcon = createSvgIcon(
<React.Fragment>
const ClearIcon = ({ className, ...props }) => (
<svg
className={className}
{...props}
viewBox="0 0 24 24"
width={24}
height={24}
>
<path d="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z" />
</React.Fragment>,
'CloseCircle',
</svg>
);

const getStyles = (theme: Theme) => ({
Expand All @@ -22,6 +26,7 @@ const getStyles = (theme: Theme) => ({
},
clearIcon: {
color: theme.palette.text.secondary,
marginTop: spacers.dp4,
henrikmv marked this conversation as resolved.
Show resolved Hide resolved
'&:hover': {
color: theme.palette.text.primary,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
import React, { Component } from 'react';
import { withStyles } from '@material-ui/core/styles';
import Popover from '@material-ui/core/Popover';
import { IconChevronDown16, IconChevronUp16, Button } from '@dhis2/ui';
import { Button } from '@dhis2/ui';
import { ConditionalTooltip } from 'capture-core/components/Tooltips/ConditionalTooltip';
import { ChevronDown, ChevronUp } from 'capture-ui/Icons';
import { ActiveFilterButton } from './ActiveFilterButton.component';
import { FilterSelectorContents } from '../Contents';
import type { UpdateFilter, ClearFilter, RemoveFilter } from '../../types';
import type { FilterData, Options } from '../../../FiltersForTypes';

const getStyles = (theme: Theme) => ({
icon: {
fontSize: theme.typography.pxToRem(20),
paddingLeft: theme.typography.pxToRem(5),
paddingLeft: theme.typography.pxToRem(12),
display: 'flex',
alignItems: 'center',
},
inactiveFilterButton: {
backgroundColor: '#f5f5f5',
Expand Down Expand Up @@ -142,11 +144,11 @@ class FilterButtonMainPlain extends Component<Props, State> {

const arrowIconElement = selectorVisible ? (
<span className={classes.icon}>
<IconChevronUp16 />
<ChevronUp />
</span>
) : (
<span className={classes.icon}>
<IconChevronDown16 />
<ChevronDown />
</span>
);

Expand Down Expand Up @@ -178,7 +180,7 @@ class FilterButtonMainPlain extends Component<Props, State> {
>
{title}
<span className={classes.icon}>
{selectorVisible ? <IconChevronUp16 /> : <IconChevronDown16 />}
{selectorVisible ? <ChevronUp /> : <ChevronDown />}
</span>
</Button>
</ConditionalTooltip>
Expand Down
Loading
Loading