Ensure that content on the DDL comparison panel should get refreshed on selecting the object using the up and down arrow keys. #5747

This commit is contained in:
Akshay Joshi
2023-02-14 17:14:42 +05:30
parent 5303a36ff4
commit d8c5bc4320
2 changed files with 44 additions and 31 deletions

View File

@@ -661,38 +661,49 @@ export function ResultGridComponent({ gridData, allRowIds, filterParams, selecte
}, [filterParams]);
const eventBus = useContext(SchemaDiffEventsContext);
const rowSelectionTimeoutRef = useRef();
const rowSelection = (row) => {
if (row.ddlData != undefined && row.status != FILTER_NAME.IDENTICAL) {
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_CHANGE_RESULT_SQL, row.ddlData);
} else if (row.status == FILTER_NAME.IDENTICAL) {
let url_params = {
'trans_id': transId,
'source_sid': sourceData.sid,
'source_did': sourceData.did,
'source_scid': row.source_scid,
'target_sid': targetData.sid,
'target_did': targetData.did,
'target_scid': row.target_scid,
'comp_status': row.status,
'source_oid': row.source_oid,
'target_oid': row.target_oid,
'node_type': row.itemType,
};
let baseUrl = url_for('schema_diff.ddl_compare', url_params);
schemaDiffToolContext.api.get(baseUrl).then((res) => {
row.ddlData = {
'SQLdiff': res.data.diff_ddl,
'sourceSQL': res.data.source_ddl,
'targetSQL': res.data.target_ddl
};
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_CHANGE_RESULT_SQL, row.ddlData);
}).catch((err) => {
Notifier.alert(err.message);
});
const rowSelection = (rowIdx) => {
if (rowSelectionTimeoutRef.current) {
clearTimeout(rowSelectionTimeoutRef.current);
rowSelectionTimeoutRef.current = null;
}
rowSelectionTimeoutRef.current = setTimeout(()=> {
rowSelectionTimeoutRef.current = null;
const row = rows[rowIdx];
if (row.ddlData != undefined && row.status != FILTER_NAME.IDENTICAL) {
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_CHANGE_RESULT_SQL, row.ddlData);
} else if (row.status == FILTER_NAME.IDENTICAL) {
let url_params = {
'trans_id': transId,
'source_sid': sourceData.sid,
'source_did': sourceData.did,
'source_scid': row.source_scid,
'target_sid': targetData.sid,
'target_did': targetData.did,
'target_scid': row.target_scid,
'comp_status': row.status,
'source_oid': row.source_oid,
'target_oid': row.target_oid,
'node_type': row.itemType,
};
let baseUrl = url_for('schema_diff.ddl_compare', url_params);
schemaDiffToolContext.api.get(baseUrl).then((res) => {
row.ddlData = {
'SQLdiff': res.data.diff_ddl,
'sourceSQL': res.data.source_ddl,
'targetSQL': res.data.target_ddl
};
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_CHANGE_RESULT_SQL, row.ddlData);
}).catch((err) => {
Notifier.alert(err.message);
});
} else {
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_CHANGE_RESULT_SQL, {});
}
}, 250);
};
function rowKeyGetter(row) {
@@ -714,7 +725,7 @@ export function ResultGridComponent({ gridData, allRowIds, filterParams, selecte
}}
headerRowHeight={28}
rowHeight={28}
onRowClick={rowSelection}
onItemSelect={rowSelection}
enableCellSelect={false}
rowKeyGetter={rowKeyGetter}
direction={'vertical-lr'}