Skip to content

feat: Add row number to data browser #2737

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

Open
wants to merge 14 commits into
base: alpha
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion src/components/BrowserRow/BrowserRow.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class BrowserRow extends Component {
row,
rowValue,
rowWidth,
headerWidth,
selection,
selectRow,
setCopyableValue,
Expand Down Expand Up @@ -70,7 +71,8 @@ export default class BrowserRow extends Component {
requiredCols = ['authData'];
}
return (
<div className={styles.tableRow} style={{ minWidth: rowWidth }} onMouseOver={() => onMouseOverRow(obj.id)}>
<div className={styles.tableRow} style={{ width: rowWidth }} onMouseOver={() => onMouseOverRow(obj.id)}>
<span className={styles.rowNumber} style={{width: headerWidth}}>{row + 1}</span>
<span
className={styles.checkCell}
onMouseUp={onMouseUpRowCheckBox}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export default class DataBrowserHeaderBar extends React.Component {
isDataLoaded,
setSelectedObjectId,
setCurrent,
headerWidth
} = this.props;
const elements = [
<div key="check" className={[styles.wrap, styles.check].join(' ')}>
<div key="check" className={[styles.wrap, styles.check].join(' ')} style={{ paddingLeft: headerWidth, width: headerWidth + 30 }}>
{readonly ? null : (
<input type="checkbox" checked={selected} onChange={e => selectAll(e.target.checked)} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
vertical-align: top;
text-align: center;
width: 30px;
background: rgb(114, 111, 133)
background: rgb(114, 111, 133);
padding-left: 30px;
}

.handle {
Expand Down
1 change: 1 addition & 0 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -2124,6 +2124,7 @@ class Browser extends DashboardView {
errorAggregatedData={this.state.errorAggregatedData}
appName={this.props.params.appId}
limit={this.state.limit}
skip={this.state.skip}
/>
<BrowserFooter
skip={this.state.skip}
Expand Down
10 changes: 10 additions & 0 deletions src/dashboard/Data/Browser/Browser.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ body:global(.expanded) {
text-align: center;
}

.rowNumber {
display: inline-block;
height: 30px;
line-height: 31px;
vertical-align: top;
border-right: 1px solid #e3e3ea;
text-align: center;
border-bottom: 1px solid #e3e3ea;
}

.addRow {
height: 30px;
padding: 8px;
Expand Down
19 changes: 15 additions & 4 deletions src/dashboard/Data/Browser/BrowserTable.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default class BrowserTable extends React.Component {
this.tableRef = React.createRef();
this.handleResize = this.handleResize.bind(this);
this.updateMaxWidth = this.updateMaxWidth.bind(this);
this.headerWidth = 34;
}

componentWillReceiveProps(props) {
Expand Down Expand Up @@ -124,7 +125,13 @@ export default class BrowserTable extends React.Component {
const rowWidth = this.props.order.reduce(
(rowWidth, { visible, width }) => (visible ? rowWidth + width : rowWidth),
this.props.onAddRow ? 210 : 0
);
) + 30;

this.headerWidth = Math.max(
30,
Math.floor(Math.log10(this.props.data.length + this.props.skip)) * 10
) + 4;

let editCloneRows;
if (this.props.editCloneRows) {
editCloneRows = (
Expand Down Expand Up @@ -156,9 +163,10 @@ export default class BrowserTable extends React.Component {
onFilterChange={this.props.onFilterChange}
order={this.props.order}
readOnlyFields={READ_ONLY}
row={index}
row={index + this.props.skip}
rowValue={this.props.data[index]}
rowWidth={rowWidth}
headerWidth={this.headerWidth}
selection={this.props.selection}
selectRow={this.props.selectRow}
setCurrent={this.props.setCurrent}
Expand Down Expand Up @@ -240,6 +248,7 @@ export default class BrowserTable extends React.Component {
readOnlyFields={READ_ONLY}
row={-1}
rowWidth={rowWidth}
headerWidth={this.headerWidth}
selection={this.props.selection}
selectRow={this.props.selectRow}
setCurrent={this.props.setCurrent}
Expand Down Expand Up @@ -329,9 +338,10 @@ export default class BrowserTable extends React.Component {
callCloudFunction={this.props.callCloudFunction}
order={this.props.order}
readOnlyFields={READ_ONLY}
row={i}
row={i + this.props.skip}
rowValue={this.props.data[i]}
rowWidth={rowWidth}
headerWidth={this.headerWidth}
selection={this.props.selection}
selectRow={this.props.selectRow}
setCurrent={this.props.setCurrent}
Expand Down Expand Up @@ -540,7 +550,7 @@ export default class BrowserTable extends React.Component {
id="browser-table"
style={{
right: rightValue,
'overflow-x': this.props.isResizing ? 'hidden' : 'auto',
overflowX: this.props.isResizing ? 'hidden' : 'auto',
}}
>
<DataBrowserHeaderBar
Expand All @@ -563,6 +573,7 @@ export default class BrowserTable extends React.Component {
isDataLoaded={!!this.props.data}
setSelectedObjectId={this.props.setSelectedObjectId}
setCurrent={this.props.setCurrent}
headerWidth={this.headerWidth}
/>
{table}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/dashboard/Data/Browser/BrowserToolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ const BrowserToolbar = ({
}
onClick={() => onExecuteScriptRows(selection)}
/>
<div/>
</BrowserMenu>
<div className={styles.toolbarSeparator} />
{menu}
Expand Down
Loading