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

dbeaver/dbeaver-vscode#83 refactor: data grid #3265

Open
wants to merge 12 commits into
base: devel
Choose a base branch
from
Open

Conversation

Wroud
Copy link
Member

@Wroud Wroud commented Feb 13, 2025

No description provided.

@Wroud Wroud self-assigned this Feb 13, 2025
sergeyteleshev
sergeyteleshev previously approved these changes Feb 14, 2025
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
Copy link
Contributor

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: '',
Copy link
Contributor

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),

Comment on lines +35 to 64
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>
Copy link
Contributor

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

Comment on lines +24 to 84
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}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines +73 to +98
<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>
Copy link
Contributor

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

Comment on lines +71 to +77
if (colIdx === -1) {
return <SelectorFormatter object={objects[rowIdx]!} tableState={tableState} />;
}

if (colIdx === 0) {
return <ObjectMenuCell object={objects[rowIdx]!} />;
}
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants