From d1a325c4139205eee0f962f80da08a4dc094172d Mon Sep 17 00:00:00 2001 From: sylenien Date: Tue, 27 Sep 2022 14:35:15 +0200 Subject: [PATCH] feat(ui): add notes list to default page --- .../SessionListContainer.tsx | 5 +- .../components/Notes/NoteItem.tsx | 46 +++++++++++ .../components/Notes/NoteList.tsx | 78 +++++++++++++++++++ .../components/Notes/index.ts | 1 + .../SessionHeader/SessionHeader.tsx | 44 +++++++---- 5 files changed, 158 insertions(+), 16 deletions(-) create mode 100644 frontend/app/components/shared/SessionListContainer/components/Notes/NoteItem.tsx create mode 100644 frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx create mode 100644 frontend/app/components/shared/SessionListContainer/components/Notes/index.ts diff --git a/frontend/app/components/shared/SessionListContainer/SessionListContainer.tsx b/frontend/app/components/shared/SessionListContainer/SessionListContainer.tsx index 0b8bc35c6..41a033088 100644 --- a/frontend/app/components/shared/SessionListContainer/SessionListContainer.tsx +++ b/frontend/app/components/shared/SessionListContainer/SessionListContainer.tsx @@ -1,13 +1,16 @@ import React from 'react'; import SessionList from './components/SessionList'; import SessionHeader from './components/SessionHeader'; +import NotesList from './components/Notes/NoteList'; function SessionListContainer() { return (
- + {/* */} + +
); } diff --git a/frontend/app/components/shared/SessionListContainer/components/Notes/NoteItem.tsx b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteItem.tsx new file mode 100644 index 000000000..e05cfac10 --- /dev/null +++ b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteItem.tsx @@ -0,0 +1,46 @@ +import React from 'react' +import { Icon } from 'UI' +import PlayLink from 'Shared/SessionItem/PlayLink' + +enum Tags { + QUERY, + ISSUE, + TASK, + OTHER +} + +interface Props { + author: string + date: string + tag: Tags + isPrivate: boolean + description: string + sessionId: string +} + +function NoteItem(props: Props) { + + return ( +
+
+
{props.description}
+
+
{props.tag}
+
+ By + {props.author}, {props.date} + {props.isPrivate ? null : ( + <> + Team + + )} +
+
+
+
+
+
+ ) +} + +export default NoteItem diff --git a/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx new file mode 100644 index 000000000..7695c968c --- /dev/null +++ b/frontend/app/components/shared/SessionListContainer/components/Notes/NoteList.tsx @@ -0,0 +1,78 @@ +import React from 'react'; +import { NoContent, Pagination, Icon } from 'UI'; +import { sliceListPerPage } from 'App/utils'; +import NoteItem from './NoteItem'; + +//{ siteId }: { siteId: string } +function NotesList() { + const list = [ + { + author: 'nikita@openreplay.com', + date: 'Today, 12.00PM', + tag: 1, + isPrivate: true, + description: 'Testing private note stuff bla bla bla', + sessionId: '123123123', + id: 2, + }, + { + author: 'sasha@openreplay.com', + date: 'Tomorrow, 12.00PM', + tag: 0, + isPrivate: false, + description: 'Not Testing team note stuff bla bla bla', + sessionId: '123123123', + id: 1, + }, + ]; + + const store = { + page: 1, + pageSize: 10, + // @ts-ignore + updateKey: (a, b) => 1, + }; + + return ( + + +
No notes yet
+
+ } + > +
+ {sliceListPerPage(list, store.page - 1, store.pageSize).map((note) => ( + + + + ))} +
+ +
+
+ Showing {Math.min(list.length, store.pageSize)} out + of {list.length} notes +
+ store.updateKey('page', page)} + limit={store.pageSize} + debounceRequest={100} + /> +
+ + ); +} + +export default NotesList; diff --git a/frontend/app/components/shared/SessionListContainer/components/Notes/index.ts b/frontend/app/components/shared/SessionListContainer/components/Notes/index.ts new file mode 100644 index 000000000..49327f792 --- /dev/null +++ b/frontend/app/components/shared/SessionListContainer/components/Notes/index.ts @@ -0,0 +1 @@ +export { default } from './NoteList' diff --git a/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx b/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx index e991c8c31..b22500419 100644 --- a/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx +++ b/frontend/app/components/shared/SessionListContainer/components/SessionHeader/SessionHeader.tsx @@ -10,10 +10,22 @@ import cn from 'classnames'; import { setActiveTab } from 'Duck/search'; import SessionSettingButton from '../SessionSettingButton'; +// @ts-ignore +const Tab = ({ addBorder, onClick, children }) => ( +
+ {children} +
+) + interface Props { listCount: number; filter: any; - isBookmark: any; + activeTab: string; isEnterprise: boolean; applyFilter: (filter: any) => void; setActiveTab: (tab: any) => void; @@ -21,7 +33,7 @@ interface Props { function SessionHeader(props: Props) { const { filter: { startDate, endDate, rangeValue }, - isBookmark, + activeTab, isEnterprise, } = props; @@ -35,27 +47,29 @@ function SessionHeader(props: Props) { return (
-
-
+ props.setActiveTab({ type: 'all' })} + addBorder={activeTab === 'all'} > SESSIONS -
-
+ props.setActiveTab({ type: 'bookmark' })} + addBorder={activeTab === 'bookmark'} > {`${isEnterprise ? 'VAULT' : 'BOOKMARKS'}`} -
+ + props.setActiveTab({ type: 'notes' })} + > + NOTES +
- {!isBookmark &&
+ {activeTab === 'all' &&
@@ -71,7 +85,7 @@ export default connect( (state: any) => ({ filter: state.getIn(['search', 'instance']), listCount: numberWithCommas(state.getIn(['sessions', 'total'])), - isBookmark: state.getIn(['search', 'activeTab', 'type']) === 'bookmark', + activeTab: state.getIn(['search', 'activeTab', 'type']), isEnterprise: state.getIn(['user', 'account', 'edition']) === 'ee', }), { applyFilter, setActiveTab }