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

feat(archive): Fix virtualized table cannot scroll #1146

Merged
merged 2 commits into from
Jan 8, 2020
Merged
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
85 changes: 46 additions & 39 deletions src/lib/viewers/archive/ArchiveExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import elementsMessages from 'box-elements-messages'; // eslint-disable-line
import intlLocaleData from 'react-intl-locale-data'; // eslint-disable-line
import Internationalize from 'box-ui-elements/es/elements/common/Internationalize';
import fuzzySearch from 'box-ui-elements/es/utils/fuzzySearch';
import VirtualizedTable from 'box-ui-elements/es/features/virtualized-table';
import { AutoSizer, Column, SortDirection } from 'react-virtualized';
import {
itemNameCellRenderer,
readableTimeCellRenderer,
sizeCellRenderer,
sortableColumnHeaderRenderer,
} from 'box-ui-elements/es/features/virtualized-table-renderers';
import VirtualizedTable from 'box-ui-elements/es/features/virtualized-table';
import { addLocaleData } from 'react-intl';
import { Column, SortDirection } from 'react-virtualized/dist/es/Table/index';
import Breadcrumbs from './Breadcrumbs';
import SearchBar from './SearchBar';
import { TABLE_COLUMNS, VIEWS } from './constants';
Expand Down Expand Up @@ -189,43 +189,50 @@ class ArchiveExplorer extends React.Component {
<div className="bp-ArchiveExplorer" data-resin-feature="archive">
<SearchBar onSearch={this.handleSearch} searchQuery={searchQuery} />
<Breadcrumbs fullPath={fullPath} onClick={this.handleBreadcrumbClick} view={view} />
<VirtualizedTable
rowData={itemList}
rowGetter={this.getRowData(itemList)}
sort={this.handleSort}
sortBy={sortBy}
sortDirection={sortDirection}
>
{intl => [
<Column
key={KEY_NAME}
cellRenderer={itemNameCellRenderer(intl, this.handleItemClick)}
dataKey={KEY_NAME}
flexGrow={3}
headerRenderer={sortableColumnHeaderRenderer}
label={__('filename')}
width={1}
/>,
<Column
key={KEY_MODIFIED_AT}
cellRenderer={readableTimeCellRenderer}
dataKey={KEY_MODIFIED_AT}
flexGrow={2}
headerRenderer={sortableColumnHeaderRenderer}
label={__('last_modified_date')}
width={1}
/>,
<Column
key={KEY_SIZE}
cellRenderer={sizeCellRenderer()}
dataKey={KEY_SIZE}
flexGrow={1}
headerRenderer={sortableColumnHeaderRenderer}
label={__('size')}
width={1}
/>,
]}
</VirtualizedTable>
<div className="bp-ArchiveExplorer-table">
<AutoSizer disableWidth>
{({ height }) => (
<VirtualizedTable
height={height}
rowData={itemList}
rowGetter={this.getRowData(itemList)}
sort={this.handleSort}
sortBy={sortBy}
sortDirection={sortDirection}
>
{intl => [
<Column
key={KEY_NAME}
cellRenderer={itemNameCellRenderer(intl, this.handleItemClick)}
dataKey={KEY_NAME}
flexGrow={3}
headerRenderer={sortableColumnHeaderRenderer}
label={__('filename')}
width={1}
/>,
<Column
key={KEY_MODIFIED_AT}
cellRenderer={readableTimeCellRenderer}
dataKey={KEY_MODIFIED_AT}
flexGrow={2}
headerRenderer={sortableColumnHeaderRenderer}
label={__('last_modified_date')}
width={1}
/>,
<Column
key={KEY_SIZE}
cellRenderer={sizeCellRenderer()}
dataKey={KEY_SIZE}
flexGrow={1}
headerRenderer={sortableColumnHeaderRenderer}
label={__('size')}
width={1}
/>,
]}
</VirtualizedTable>
)}
</AutoSizer>
</div>
</div>
</Internationalize>
);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/viewers/archive/ArchiveExplorer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
width: 100%;
height: 100%;
}

.bp-ArchiveExplorer-table {
height: 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('lib/viewers/archive/ArchiveExplorer', () => {
expect(component.find('SearchBar').length).to.equal(1);
expect(component.find('Breadcrumbs').length).to.equal(1);
expect(component.find('Internationalize').length).to.equal(1);
expect(component.find('InjectIntl(VirtualizedTable)').length).to.equal(1);
});
});

Expand Down