-
Notifications
You must be signed in to change notification settings - Fork 405
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
dbeaver/dbeaver-vscode#83 refactor: data grid #3265
base: devel
Are you sure you want to change the base?
Conversation
width, | ||
minWidth: 24, | ||
editable: row => getCellEditable?.(row.idx, i) ?? false, | ||
maxWidth: 900, // TODO: there is a bug with auto-resize if this value is too high or not set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please create a ticket for that if you didn't
const width = getHeaderWidth?.(i) ?? 'max-content'; | ||
return { | ||
key: getColumnKey?.(i) ?? String(i), | ||
name: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why all columns has equal name? it previously was like this:
name: getHeaderText(i),
function getCell(rowIdx: number, colIdx: number) { | ||
switch (colIdx) { | ||
case 0: | ||
return trace![rowIdx]?.name ?? ''; | ||
case 1: | ||
return trace![rowIdx]?.value ?? ''; | ||
case 2: | ||
return trace![rowIdx]?.description ?? ''; | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
function getHeaderText(colIdx: number) { | ||
switch (colIdx) { | ||
case 0: | ||
return translate('ui_name'); | ||
case 1: | ||
return translate('ui_value'); | ||
case 2: | ||
return translate('ui_description'); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
return ( | ||
<div className={s(styles, { container: true })}> | ||
<DataGrid | ||
rows={state.trace} | ||
rowKeyGetter={ | ||
// @ts-ignore | ||
row => row.name | ||
} | ||
columns={COLUMNS} | ||
rowHeight={30} | ||
/> | ||
<DataGrid getCell={getCell} getColumnCount={() => 3} getHeaderText={getHeaderText} getRowHeight={() => 30} getRowCount={() => trace.length} /> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no magic numbers please
we should add eslint rule for that
export const TransactionLogTable = observer<Props>(function TransactionLogTable({ log }) { | ||
const styles = useS(classes); | ||
const translate = useTranslate(); | ||
|
||
function getCell(rowIdx: number, colIdx: number) { | ||
switch (colIdx) { | ||
case 0: | ||
return <TimeCell row={log[rowIdx]!} />; | ||
case 1: | ||
return log![rowIdx]?.type ?? ''; | ||
case 2: | ||
return <QueryCell row={log[rowIdx]!} />; | ||
case 3: | ||
return String(log![rowIdx]?.durationMs ?? ''); | ||
case 4: | ||
return String(log![rowIdx]?.rows ?? ''); | ||
case 5: | ||
return log![rowIdx]?.result ?? ''; | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
function getHeaderText(colIdx: number) { | ||
switch (colIdx) { | ||
case 0: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_time'); | ||
case 1: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_type'); | ||
case 2: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_text'); | ||
case 3: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_duration'); | ||
case 4: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_rows'); | ||
case 5: | ||
return translate('plugin_datasource_transaction_manager_logs_table_column_result'); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
function getHeaderWidth(colIdx: number) { | ||
switch (colIdx) { | ||
case 2: | ||
return QUERY_COLUMN_WIDTH; | ||
default: | ||
return 'auto'; | ||
} | ||
} | ||
|
||
return ( | ||
<div className={s(styles, { container: true })}> | ||
<DataGrid | ||
rows={props.log} | ||
rowKeyGetter={ | ||
// @ts-ignore | ||
row => row.id | ||
} | ||
columns={COLUMNS} | ||
rowHeight={30} | ||
getCell={getCell} | ||
getHeaderWidth={getHeaderWidth} | ||
getColumnCount={() => 6} | ||
getHeaderText={getHeaderText} | ||
getRowHeight={() => 30} | ||
getRowCount={() => log.length} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
<div ref={mouse.reference} className={s(styles, { container: true })} onDoubleClick={openNode} onContextMenu={contextMenuOpenHandler}> | ||
<div className={s(styles, { box: true })}> | ||
<div className={s(styles, { objectIconBox: true })}> | ||
{node?.icon && <StaticImage icon={node.icon} className={s(styles, { objectIcon: true })} />} | ||
</div> | ||
<Link className={s(styles, { value: true })} title={value} inline onClick={openNode}> | ||
{value} | ||
</Link> | ||
{!menuEmpty && ( | ||
<div className={s(styles, { menuBox: true })}> | ||
<Loader suspense small fullSize> | ||
<ContextMenu | ||
contextMenuPosition={contextMenuPosition} | ||
menu={menu} | ||
placement="auto-end" | ||
hidden={menuEmpty} | ||
modal | ||
disclosure | ||
onVisibleSwitch={switchState} | ||
> | ||
<Icon className={s(styles, { menuIcon: true })} name="snack" viewBox="0 0 16 10" /> | ||
</ContextMenu> | ||
</Loader> | ||
</div> | ||
)} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use <Container>
wherever it is possible
if (colIdx === -1) { | ||
return <SelectorFormatter object={objects[rowIdx]!} tableState={tableState} />; | ||
} | ||
|
||
if (colIdx === 0) { | ||
return <ObjectMenuCell object={objects[rowIdx]!} />; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not clear what -1 and 0 stands for
No description provided.