From 111a1ef88407d8adaae00adfe28be25ed986a55b Mon Sep 17 00:00:00 2001 From: freddytuxworth Date: Thu, 18 Jun 2020 13:46:47 +0100 Subject: [PATCH] Add button to remove conference from recents list Fixes #313, #283, #322, #127, #334 --- app/features/recent-list/actionTypes.js | 10 +++++++++ app/features/recent-list/actions.js | 19 ++++++++++++++++ .../recent-list/components/RecentList.js | 22 +++++++++++++++++++ app/features/recent-list/reducer.js | 22 +++++++++++++++++++ .../recent-list/styled/ConferenceCard.js | 6 +++-- 5 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 app/features/recent-list/actionTypes.js create mode 100644 app/features/recent-list/actions.js diff --git a/app/features/recent-list/actionTypes.js b/app/features/recent-list/actionTypes.js new file mode 100644 index 0000000..bab4c96 --- /dev/null +++ b/app/features/recent-list/actionTypes.js @@ -0,0 +1,10 @@ +/** + * The type of (redux) action that is dispatched when a conference is removed from the recents list. + * + * @type { +* type: CONFERENCE_REMOVED, +* conference: Object +* } +*/ +export const CONFERENCE_REMOVED = Symbol('CONFERENCE_REMOVED'); + diff --git a/app/features/recent-list/actions.js b/app/features/recent-list/actions.js new file mode 100644 index 0000000..7b4e7a1 --- /dev/null +++ b/app/features/recent-list/actions.js @@ -0,0 +1,19 @@ +// @flow + +import { CONFERENCE_REMOVED } from './actionTypes'; + +/** + * Notifies that conference is removed from recents list. + * + * @param {Object} conference - Conference Details. + * @returns {{ +* type: CONFERENCE_REMOVED, +* conference: Object +* }} +*/ +export function conferenceRemoved(conference: Object) { + return { + type: CONFERENCE_REMOVED, + conference + }; +} diff --git a/app/features/recent-list/components/RecentList.js b/app/features/recent-list/components/RecentList.js index 8135757..2518b93 100644 --- a/app/features/recent-list/components/RecentList.js +++ b/app/features/recent-list/components/RecentList.js @@ -6,6 +6,7 @@ import { connect } from 'react-redux'; import type { Dispatch } from 'redux'; import { push } from 'react-router-redux'; +import { conferenceRemoved } from '../actions'; import { ConferenceCard, ConferenceTitle, @@ -13,6 +14,8 @@ import { TruncatedText } from '../styled'; import type { RecentListItem } from '../types'; +import Button from '@atlaskit/button'; +import CrossIcon from '@atlaskit/icon/glyph/cross'; type Props = { @@ -58,6 +61,20 @@ class RecentList extends Component { return () => this.props.dispatch(push('/conference', conference)); } + /** + * Creates a handler for removing a conference from the recents list. + * + * @param {RecentListItem} conference - Conference Details. + * @returns {void} + */ + _onRemoveConference(conference: RecentListItem) { + return e => { + this.props.dispatch(conferenceRemoved(conference)); + e.stopPropagation(); + }; + } + + /** * Renders the conference card. * @@ -81,6 +98,11 @@ class RecentList extends Component { { this._renderDuration(conference) } +