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

add reminders to mentionable notes #1187

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nodejs lts-gallium
nodejs 16.14.2
yarn 1.22.19
3 changes: 3 additions & 0 deletions src/components/Note/Note.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ export const NoteWithMentions = () => {
onChange={action('onChange')}
onDelete={action('onDelete')}
onEdit={action('onEdit')}
onSetReminder={action('onSetReminder')}
onDismissReminder={action('onDismissReminder')}
reminderExists={boolean('reminderExists')}
onSave={action('onSave')}
onUndelete={action('onUndelete')}
rows={number('rows', Note.defaultProps.rows)}
Expand Down
68 changes: 66 additions & 2 deletions src/components/Note/NoteHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import classnames from 'classnames';
import fecha from 'fecha';
import React, { FC } from 'react';
import React, { FC, useState } from 'react';
import Badge from '../Badge/Badge';
import Button from '../Button/Button';
import ButtonDropdown from '../Button/ButtonDropdown'
import DropdownItem from '../Dropdown/DropdownItem';
import DropdownMenu from '../Dropdown/DropdownMenu';
import DropdownToggle from '../Dropdown/DropdownToggle';
import CardHeader from '../Card/CardHeader';
import CardTitle from '../Card/CardTitle';
import { Note } from './Note.types';
Expand All @@ -20,15 +24,19 @@ type NoteHeaderProps = {
showTimezone?: boolean;
onDelete?: (note: Omit<Note, 'text'>) => void;
onEdit?: (note: Omit<Note, 'text'>) => void;
onSetReminder?: (note: Omit<Note, 'text'>, time: number) => void;
onDismissReminder?: (note: Omit<Note, 'text'>) => void;
reminderExists?: boolean;
};

const defaultProps = {
dateFormat: 'ddd MMM DD YYYY HH:mm:ss',
};

const NoteHeader: FC<NoteHeaderProps> = ({ dateFormat = defaultProps.dateFormat, ...props }) => {
const { note, onDelete, onEdit, showTimezone } = props;
const { note, onDelete, onEdit, showTimezone, onSetReminder, onDismissReminder, reminderExists } = props;
const { date, edited, from, title } = note;
const [isOpen, setIsOpen] = useState(false);

const headerClassNames = classnames(
'd-flex',
Expand Down Expand Up @@ -91,6 +99,62 @@ const NoteHeader: FC<NoteHeaderProps> = ({ dateFormat = defaultProps.dateFormat,
Delete
</Button>
) : null}
{ !reminderExists && onSetReminder ? (
<div className="ms-3">
<ButtonDropdown isOpen={isOpen} toggle={() => setIsOpen(!isOpen)}>
<DropdownToggle caret>Remind Me</DropdownToggle>
<DropdownMenu>
<DropdownItem
onClick={() => onSetReminder(
note,
new Date().setMinutes(
new Date().getMinutes() + 20
)
)}
>
In 20 minutes</DropdownItem>
<DropdownItem
onClick={() => onSetReminder(
note,
new Date().setMinutes(
new Date().getMinutes() + 60
)
)}
>
In 1 hour</DropdownItem>
<DropdownItem
onClick={() => onSetReminder(
note,
new Date().setMinutes(
new Date().getMinutes() + 1440
)
)}
>
Tomorrow
</DropdownItem>
<DropdownItem
onClick={() => onSetReminder(
note,
new Date().setMinutes(
new Date().getMinutes() + 10080
)
)}
>
Next Week
</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
) : null}
{ reminderExists && onDismissReminder ? (
<Button
color="secondary"
onClick={() => onDismissReminder(note)}
className="js-note-header__dismiss-reminder ms-3"
>
Dismiss
</Button>
) : null}
</div>
</CardHeader>
) : (
Expand Down
9 changes: 9 additions & 0 deletions src/components/Note/NoteMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type NoteMentionsProps = {
onDelete?: (note: Omit<NoteType, 'text'>) => void;
onEdit?: (note: Omit<NoteType, 'text'>) => void;
onSave?: (note: NoteType) => void;
onSetReminder?: (note: Omit<NoteType, 'text'>, time: number) => void;
onDismissReminder?: (note: Omit<NoteType, 'text'>) => void;
reminderExists?: boolean;
onUndelete?: (note: NoteType) => void;
rows?: number;
saving?: boolean;
Expand Down Expand Up @@ -59,6 +62,9 @@ const NoteMentions: FC<NoteMentionsProps> = ({
onDelete,
onEdit,
onSave,
onSetReminder,
onDismissReminder,
reminderExists,
onUndelete,
}) => {
const { deleted, editing, text } = note;
Expand Down Expand Up @@ -106,6 +112,9 @@ const NoteMentions: FC<NoteMentionsProps> = ({
showTimezone={showTimezone}
onDelete={onDelete}
onEdit={onEdit}
onSetReminder={onSetReminder}
onDismissReminder={onDismissReminder}
reminderExists={reminderExists}
/>
<CardBody>
<CardText style={{ whiteSpace: 'pre-wrap' }}>
Expand Down