Skip to content

Commit da4ed1a

Browse files
authored
fix console browse rows bugs (hasura#1691)
1 parent 6ecc187 commit da4ed1a

File tree

4 files changed

+58
-49
lines changed

4 files changed

+58
-49
lines changed

console/cypress/integration/data/views/spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,14 @@ const checkOrder = order => {
312312
cy.wrap($el)
313313
.find('[role=gridcell]')
314314
.first()
315+
.next()
315316
.contains(2);
316317
}
317318
if (index === 2) {
318319
cy.wrap($el)
319320
.find('[role=gridcell]')
320321
.first()
322+
.next()
321323
.contains(userId);
322324
}
323325
});
@@ -327,12 +329,14 @@ const checkOrder = order => {
327329
cy.wrap($el)
328330
.find('[role=gridcell]')
329331
.first()
332+
.next()
330333
.contains(2);
331334
}
332335
if (index === 1) {
333336
cy.wrap($el)
334337
.find('[role=gridcell]')
335338
.first()
339+
.next()
336340
.contains(userId);
337341
}
338342
});

console/src/components/Services/Data/TableBrowseRows/ReactTableFix.css

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
.ReactTable .rt-tbody .rt-td {
5656
padding: 8px;
5757
border-right: 1px solid rgba(0,0,0,0.1);
58+
word-wrap: break-word;
5859
}
5960

6061
.ReactTable .rt-th .ellipsis,

console/src/components/Services/Data/TableBrowseRows/ViewRows.js

+52-48
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ const ViewRows = ({
8383
const getGridHeadings = (_columns, _relationships) => {
8484
const _gridHeadings = [];
8585

86-
if (!isView) {
87-
_gridHeadings.push({
88-
Header: '',
89-
accessor: 'actions',
90-
id: 'actions',
91-
});
92-
}
86+
_gridHeadings.push({
87+
Header: '',
88+
accessor: 'actions',
89+
id: 'actions',
90+
});
9391

9492
_columns.map(col => {
9593
const columnName = col.column_name;
@@ -291,26 +289,26 @@ const ViewRows = ({
291289
const getColCellContent = () => {
292290
const rowColumnValue = row[columnName];
293291

294-
const getCellValue = () => {
295-
let cellValue = '';
296-
297-
if (rowColumnValue === null) {
298-
cellValue = (<i>NULL</i>);
299-
} else if (rowColumnValue === undefined) {
300-
cellValue = 'NULL';
301-
} else if (col.data_type === 'json' || col.data_type === 'jsonb') {
302-
cellValue = JSON.stringify(rowColumnValue);
303-
} else {
304-
cellValue = rowColumnValue.toString();
305-
}
306-
307-
return cellValue;
308-
};
292+
let cellValue = '';
293+
let cellTitle = '';
294+
295+
if (rowColumnValue === null) {
296+
cellValue = (<i>NULL</i>);
297+
cellTitle = 'NULL';
298+
} else if (rowColumnValue === undefined) {
299+
cellValue = 'NULL';
300+
cellTitle = cellValue;
301+
} else if (col.data_type === 'json' || col.data_type === 'jsonb') {
302+
cellValue = JSON.stringify(rowColumnValue);
303+
cellTitle = cellValue;
304+
} else {
305+
cellValue = rowColumnValue.toString();
306+
cellTitle = cellValue;
307+
}
309308

310-
const cellValue = getCellValue();
311309

312310
return (
313-
<div className={isExpanded ? styles.tableCellExpanded : ''}>
311+
<div className={isExpanded ? styles.tableCellExpanded : ''} title={cellTitle}>
314312
{cellValue}
315313
</div>
316314
);
@@ -338,9 +336,9 @@ const ViewRows = ({
338336
);
339337
};
340338

341-
const isExpanded = curQuery.columns.find(c => c.name === rel.rel_name) !== undefined;
339+
const isRelExpanded = curQuery.columns.find(c => c.name === rel.rel_name) !== undefined;
342340

343-
if (isExpanded) {
341+
if (isRelExpanded) {
344342
const handleCloseClick = e => {
345343
e.preventDefault();
346344
dispatch(vCloseRel(curPath, rel.rel_name));
@@ -491,30 +489,36 @@ const ViewRows = ({
491489
// Render child only if data is available
492490
if (curRows[0][cq.name]) {
493491
const rel = tableSchema.relationships.find(r => r.rel_name === cq.name);
494-
let childRows = curRows[0][cq.name];
495-
if (rel.rel_type === 'object') {
496-
childRows = [childRows];
492+
493+
if (rel) {
494+
let childRows = curRows[0][cq.name];
495+
if (rel.rel_type === 'object') {
496+
childRows = [childRows];
497+
}
498+
// Find the name of this childTable using the rel
499+
return (
500+
<ViewRows
501+
key={i}
502+
curTableName={findTableFromRel(schemas, tableSchema, rel).table_name}
503+
currentSchema={currentSchema}
504+
curQuery={cq}
505+
curFilter={curFilter}
506+
curPath={[...curPath, rel.rel_name]}
507+
curRows={childRows}
508+
parentTableName={curTableName}
509+
activePath={activePath}
510+
ongoingRequest={ongoingRequest}
511+
lastError={lastError}
512+
lastSuccess={lastSuccess}
513+
schemas={schemas}
514+
curDepth={curDepth + 1}
515+
dispatch={dispatch}
516+
expandedRow={expandedRow}
517+
/>
518+
);
497519
}
498-
// Find the name of this childTable using the rel
499-
return (
500-
<ViewRows
501-
key={i}
502-
curTableName={findTableFromRel(schemas, tableSchema, rel).table_name}
503-
curQuery={cq}
504-
curFilter={curFilter}
505-
curPath={[...curPath, rel.rel_name]}
506-
curRows={childRows}
507-
parentTableName={curTableName}
508-
activePath={activePath}
509-
ongoingRequest={ongoingRequest}
510-
lastError={lastError}
511-
lastSuccess={lastSuccess}
512-
schemas={schemas}
513-
curDepth={curDepth + 1}
514-
dispatch={dispatch}
515-
/>
516-
);
517520
}
521+
518522
return null;
519523
});
520524

console/src/components/Services/Data/TableBrowseRows/foldableTable/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const defaultFoldButtonComponent = ({ header, collapsed, icon, onClick }) => {
2020
cursor: 'pointer',
2121
position: 'absolute',
2222
fontSize: '14px',
23-
top: 'calc(50% - 7px)',
23+
top: 'calc(50% - 8px)',
2424
left: '8px',
2525
padding: '5px',
2626
margin: '-5px -5px -5px -5px',

0 commit comments

Comments
 (0)