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 11 commits into
base: alpha
Choose a base branch
from
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 @@ -2103,6 +2103,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
14 changes: 14 additions & 0 deletions src/dashboard/Data/Browser/Browser.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ 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;
position: sticky;
left: 0;
z-index: 1;
border-bottom: 1px solid #e3e3ea;
background: white;
}

.addRow {
height: 30px;
padding: 8px;
Expand Down
21 changes: 16 additions & 5 deletions src/dashboard/Data/Browser/BrowserTable.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
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 @@ -121,10 +122,16 @@
let editor = null;
let table = <div ref={this.tableRef} />;
if (this.props.data) {
const rowWidth = this.props.order.reduce(
let rowWidth = this.props.order.reduce(

Check failure on line 125 in src/dashboard/Data/Browser/BrowserTable.react.js

View workflow job for this annotation

GitHub Actions / Lint

'rowWidth' is never reassigned. Use 'const' instead
(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 @@
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 @@
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 @@
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 @@
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 @@
isDataLoaded={!this.props.isLoading}
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