From 721a5da895c09353ce86cb254b9d674d4cc35de3 Mon Sep 17 00:00:00 2001 From: Rohit Bhati Date: Tue, 9 Jul 2024 13:44:04 +0530 Subject: [PATCH] Fixed an issue where Generate Script button should be disabled if no objects are selected in the schema diff result. #7638 --- .../schema_diff/static/js/components/InputComponent.jsx | 6 ++++-- .../static/js/components/SchemaDiffButtonComponent.jsx | 4 +++- .../schema_diff/static/js/components/SchemaDiffCompare.jsx | 7 +++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx b/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx index bd2af5693..e67266397 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/InputComponent.jsx @@ -17,7 +17,7 @@ import { SchemaDiffEventsContext } from './SchemaDiffComponent'; import { SCHEMA_DIFF_EVENT } from '../SchemaDiffConstants'; -export function InputComponent({ label, serverList, databaseList, schemaList, diff_type, selectedSid = null, selectedDid=null, selectedScid=null }) { +export function InputComponent({ label, serverList, databaseList, schemaList, diff_type, selectedSid = null, selectedDid=null, selectedScid=null, onServerSchemaChange }) { const [selectedServer, setSelectedServer] = useState(selectedSid); const [selectedDatabase, setSelectedDatabase] = useState(selectedDid); @@ -35,7 +35,6 @@ export function InputComponent({ label, serverList, databaseList, schemaList, di setSelectedSchema(null); setDisableSchemaSelection(true); } - eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_SERVER, { selectedOption, diff_type, serverList }); }; @@ -48,11 +47,13 @@ export function InputComponent({ label, serverList, databaseList, schemaList, di setDisableSchemaSelection(true); } eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_DATABASE, {selectedServer, selectedDB, diff_type, databaseList}); + onServerSchemaChange(); }; const changeSchema = (selectedSC) => { setSelectedSchema(selectedSC); eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_SCHEMA, { selectedSC, diff_type }); + onServerSchemaChange(); }; return ( @@ -125,4 +126,5 @@ InputComponent.propTypes = { selectedSid: PropTypes.number, selectedDid: PropTypes.number, selectedScid:PropTypes.number, + onServerSchemaChange:PropTypes.func }; diff --git a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx index 28294112c..1c834167a 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffButtonComponent.jsx @@ -62,7 +62,7 @@ const Root = styled('div')(({theme}) => ({ }, })); -export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowIds, rows, compareParams, filterParams = [FILTER_NAME.DIFFERENT, FILTER_NAME.SOURCE_ONLY, FILTER_NAME.TARGET_ONLY] }) { +export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowIds, onServerSchemaChange, rows, compareParams, filterParams = [FILTER_NAME.DIFFERENT, FILTER_NAME.SOURCE_ONLY, FILTER_NAME.TARGET_ONLY] }) { const filterRef = useRef(null); const compareRef = useRef(null); @@ -149,6 +149,7 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI targetSQL: null, SQLdiff: null, }); + onServerSchemaChange(); }; const generateScript = () => { @@ -218,6 +219,7 @@ SchemaDiffButtonComponent.propTypes = { sourceData: PropTypes.object, targetData: PropTypes.object, selectedRowIds: PropTypes.array, + onServerSchemaChange:PropTypes.func, rows: PropTypes.array, compareParams: PropTypes.object, filterParams: PropTypes.array diff --git a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx index 6ab784e9a..26a4b3988 100644 --- a/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx +++ b/web/pgadmin/tools/schema_diff/static/js/components/SchemaDiffCompare.jsx @@ -177,6 +177,10 @@ export function SchemaDiffCompare({ params }) { } + const handleServerSchemaChange = () => { + setSelectedRowIds([]); + }; + function setSourceTargetSid(diff_type, selectedOption) { if (diff_type == TYPE.SOURCE) { setSelectedSourceSid(selectedOption); @@ -699,6 +703,7 @@ export function SchemaDiffCompare({ params }) { selectedDid={selectedSourceDid} selectedScid={selectedSourceScid} diff_type={TYPE.SOURCE} + onServerSchemaChange={handleServerSchemaChange} > @@ -722,6 +727,7 @@ export function SchemaDiffCompare({ params }) { selectedDid={selectedTargetDid} selectedScid={selectedTargetScid} diff_type={TYPE.TARGET} + onServerSchemaChange={handleServerSchemaChange} > @@ -733,6 +739,7 @@ export function SchemaDiffCompare({ params }) { 'scid': selectedSourceScid, }} selectedRowIds={selectedRowIds} + onServerSchemaChange={handleServerSchemaChange} rows={apiResult} targetData={{ 'sid': selectedTargetSid,