From ce8cafe9321e84f8b46ff248ef8dfef08e8b4c23 Mon Sep 17 00:00:00 2001 From: Ray Lee Date: Mon, 3 Oct 2022 13:46:17 -0400 Subject: [PATCH] Add list filtering to lane editor. (#50) * Add filter select to available lists on lane editor. * Update tests. * Add tests. * Remove extra whitespace. * Add share icon to lists that are not owned. * Consolidate duplicate list info rendering code. --- src/components/LaneCustomListsEditor.tsx | 81 ++++++++--- src/components/LaneEditor.tsx | 28 ++++ .../__tests__/LaneCustomListsEditor-test.tsx | 136 ++++++++++++++++-- src/components/__tests__/LaneEditor-test.tsx | 41 +++++- src/stylesheets/lane_editor.scss | 15 +- 5 files changed, 273 insertions(+), 28 deletions(-) diff --git a/src/components/LaneCustomListsEditor.tsx b/src/components/LaneCustomListsEditor.tsx index 659a62e34..e7d06da0c 100644 --- a/src/components/LaneCustomListsEditor.tsx +++ b/src/components/LaneCustomListsEditor.tsx @@ -2,14 +2,19 @@ import * as React from "react"; import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; import { CustomListData } from "../interfaces"; import AddIcon from "./icons/AddIcon"; +import ShareIcon from "./icons/ShareIcon"; import TrashIcon from "./icons/TrashIcon"; import GrabIcon from "./icons/GrabIcon"; +import EditableInput from "./EditableInput"; import { Button } from "library-simplified-reusable-components"; export interface LaneCustomListsEditorProps extends React.Props { allCustomLists: CustomListData[]; customListIds: number[]; + filter?: string; + filteredCustomLists?: CustomListData[]; + changeFilter?: (value: string) => void; onUpdate?: (customListIds: number[]) => void; } @@ -22,6 +27,11 @@ export default class LaneCustomListsEditor extends React.Component< LaneCustomListsEditorProps, LaneCustomListsEditorState > { + static defaultProps = { + filter: "owned", + filteredCustomLists: [], + }; + constructor(props) { super(props); this.state = { @@ -32,6 +42,56 @@ export default class LaneCustomListsEditor extends React.Component< this.onDragEnd = this.onDragEnd.bind(this); } + renderFilterSelect(): JSX.Element { + const filters = [ + ["All", ""], + ["Owned", "owned"], + ["Subscribed", "shared-in"], + ]; + + return ( +
+ Select filter type + + + {filters.map(([label, value]) => ( + + ))} + +
+ ); + } + + renderListInfo(list): JSX.Element { + return ( + <> + +
+
+ {!list.is_owner && ( + + )} + {list.name} +
+
Items in list: {list.entry_count}
+
ID-{list.id}
+
+ + ); + } + render(): JSX.Element { return (

Available Lists ({this.listsNotInLane().length})

+ {this.renderFilterSelect()}
- -
-
{list.name}
-
- Items in list: {list.entry_count} -
-
ID-{list.id}
-
+ {this.renderListInfo(list)}