Skip to content

Commit bab51ac

Browse files
committed
fix folder name
1 parent a4f40c4 commit bab51ac

File tree

4 files changed

+212
-0
lines changed

4 files changed

+212
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react'
2+
import { instance, mock } from 'ts-mockito'
3+
import { render } from 'uiSrc/utils/test-utils'
4+
import StreamDataView, { Props } from './StreamDataView'
5+
6+
const mockedProps = mock<Props>()
7+
8+
describe('StreamDataView', () => {
9+
it('should render', () => {
10+
expect(render(<StreamDataView {...instance(mockedProps)} />)).toBeTruthy()
11+
})
12+
})
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import React, { useState } from 'react'
2+
import { useDispatch, useSelector } from 'react-redux'
3+
import { isNull } from 'lodash'
4+
import cx from 'classnames'
5+
6+
import {
7+
fetchStreamEntries,
8+
streamDataSelector,
9+
streamSelector,
10+
} from 'uiSrc/slices/browser/stream'
11+
import VirtualTable from 'uiSrc/components/virtual-table/VirtualTable'
12+
import { ITableColumn } from 'uiSrc/components/virtual-table/interfaces'
13+
import { selectedKeyDataSelector } from 'uiSrc/slices/browser/keys'
14+
import { SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
15+
import { SortOrder } from 'uiSrc/constants'
16+
import { StreamEntryDto } from 'apiSrc/modules/browser/dto/stream.dto'
17+
18+
import styles from './styles.module.scss'
19+
20+
const headerHeight = 60
21+
const rowHeight = 54
22+
const actionsWidth = 54
23+
const minColumnWidth = 190
24+
const noItemsMessageInEmptyStream = 'There are no Entries in the Stream.'
25+
const noItemsMessageInRange = 'No results found.'
26+
27+
interface IStreamEntry extends StreamEntryDto {
28+
editing: boolean
29+
}
30+
31+
export interface Props {
32+
data: IStreamEntry[]
33+
columns: ITableColumn[]
34+
onEditEntry: (entryId:string, editing: boolean) => void
35+
onClosePopover: () => void
36+
loadMoreItems: () => void
37+
isFooterOpen?: boolean
38+
}
39+
40+
const StreamDataView = (props: Props) => {
41+
const { data: entries = [], columns = [], onClosePopover, loadMoreItems, isFooterOpen } = props
42+
const dispatch = useDispatch()
43+
44+
const { loading } = useSelector(streamSelector)
45+
const {
46+
total,
47+
firstEntry,
48+
lastEntry,
49+
} = useSelector(streamDataSelector)
50+
const { name: key } = useSelector(selectedKeyDataSelector) ?? { name: '' }
51+
52+
const [sortedColumnName, setSortedColumnName] = useState<string>('id')
53+
const [sortedColumnOrder, setSortedColumnOrder] = useState<SortOrder>(SortOrder.DESC)
54+
55+
const onChangeSorting = (column: any, order: SortOrder) => {
56+
setSortedColumnName(column)
57+
setSortedColumnOrder(order)
58+
59+
dispatch(fetchStreamEntries(key, SCAN_COUNT_DEFAULT, order, false))
60+
}
61+
62+
return (
63+
<>
64+
65+
<div
66+
className={cx(
67+
'key-details-table',
68+
'stream-details-table',
69+
styles.container,
70+
{ footerOpened: isFooterOpen }
71+
)}
72+
data-test-id="stream-entries-container"
73+
>
74+
{/* <div className={styles.columnManager}>
75+
<EuiButtonIcon iconType="boxesVertical" aria-label="manage columns" />
76+
</div> */}
77+
<VirtualTable
78+
hideProgress
79+
selectable={false}
80+
keyName={key}
81+
headerHeight={entries?.length ? headerHeight : 0}
82+
rowHeight={rowHeight}
83+
columns={columns}
84+
footerHeight={0}
85+
loadMoreItems={loadMoreItems}
86+
loading={loading}
87+
items={entries}
88+
totalItemsCount={total}
89+
onWheel={onClosePopover}
90+
onChangeSorting={onChangeSorting}
91+
noItemsMessage={isNull(firstEntry) && isNull(lastEntry) ? noItemsMessageInEmptyStream : noItemsMessageInRange}
92+
tableWidth={columns.length * minColumnWidth - actionsWidth}
93+
sortedColumn={entries?.length ? {
94+
column: sortedColumnName,
95+
order: sortedColumnOrder,
96+
} : undefined}
97+
/>
98+
</div>
99+
</>
100+
)
101+
}
102+
103+
export default StreamDataView
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import StreamDataView from './StreamDataView'
2+
3+
export default StreamDataView
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.container {
2+
display: flex;
3+
flex: 1;
4+
width: 100%;
5+
padding-top: 3px;
6+
background-color: var(--euiColorEmptyShade);
7+
8+
:global {
9+
.ReactVirtualized__Grid__innerScrollContainer {
10+
.ReactVirtualized__Table__rowColumn {
11+
border-right: 1px solid var(--tableDarkestBorderColor) !important;
12+
13+
&:last-of-type,
14+
&:nth-last-of-type(2) {
15+
border-right: none !important;
16+
}
17+
}
18+
19+
.ReactVirtualized__Table__row {
20+
border-bottom: 1px solid var(--tableDarkestBorderColor) !important;
21+
&:last-of-type {
22+
border-bottom: none !important;
23+
}
24+
}
25+
26+
& > div:hover {
27+
background: var(--euiColorLightestShade);
28+
29+
.value-table-actions {
30+
background-color: var(--euiColorLightestShade) !important;
31+
}
32+
33+
.streamEntry {
34+
color: var(--inputTextColor) !important;
35+
}
36+
37+
.streamEntryId {
38+
color: var(--euiTextSubduedColor) !important;
39+
}
40+
}
41+
}
42+
43+
.ReactVirtualized__Table__headerRow {
44+
border: none !important;
45+
}
46+
47+
.ReactVirtualized__Table__Grid {
48+
border: 1px solid var(--tableDarkestBorderColor) !important;
49+
}
50+
}
51+
52+
.cellHeader {
53+
border: none !important;
54+
}
55+
}
56+
57+
:global(.streamEntry) {
58+
color: var(--euiTextSubduedColor) !important;
59+
white-space: normal;
60+
max-width: 100%;
61+
word-break: break-all;
62+
}
63+
64+
:global(.streamEntryId) {
65+
color: var(--euiColorMediumShade) !important;
66+
display: flex;
67+
}
68+
69+
:global(.stream-entry-actions) {
70+
margin-left: -5px;
71+
}
72+
73+
.actions,
74+
.actionsHeader {
75+
width: 54px;
76+
}
77+
78+
.actions {
79+
:global(.value-table-actions) {
80+
background-color: var(--euiColorEmptyShade) !important;
81+
}
82+
}
83+
84+
.columnManager {
85+
z-index: 11;
86+
position: absolute;
87+
right: 18px;
88+
margin-top: 20px;
89+
width: 40px;
90+
button {
91+
width: 40px;
92+
background-color: var(--euiColorEmptyShade) !important;
93+
}
94+
}

0 commit comments

Comments
 (0)