mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2024-11-24 09:40:21 -06:00
Fixed an issue where Generate Script button should be disabled if no objects are selected in the schema diff result. #7638
This commit is contained in:
parent
8578acd915
commit
721a5da895
@ -17,7 +17,7 @@ import { SchemaDiffEventsContext } from './SchemaDiffComponent';
|
|||||||
import { SCHEMA_DIFF_EVENT } from '../SchemaDiffConstants';
|
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 [selectedServer, setSelectedServer] = useState(selectedSid);
|
||||||
const [selectedDatabase, setSelectedDatabase] = useState(selectedDid);
|
const [selectedDatabase, setSelectedDatabase] = useState(selectedDid);
|
||||||
@ -35,7 +35,6 @@ export function InputComponent({ label, serverList, databaseList, schemaList, di
|
|||||||
setSelectedSchema(null);
|
setSelectedSchema(null);
|
||||||
setDisableSchemaSelection(true);
|
setDisableSchemaSelection(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_SERVER, { selectedOption, diff_type, serverList });
|
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);
|
setDisableSchemaSelection(true);
|
||||||
}
|
}
|
||||||
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_DATABASE, {selectedServer, selectedDB, diff_type, databaseList});
|
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_DATABASE, {selectedServer, selectedDB, diff_type, databaseList});
|
||||||
|
onServerSchemaChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeSchema = (selectedSC) => {
|
const changeSchema = (selectedSC) => {
|
||||||
setSelectedSchema(selectedSC);
|
setSelectedSchema(selectedSC);
|
||||||
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_SCHEMA, { selectedSC, diff_type });
|
eventBus.fireEvent(SCHEMA_DIFF_EVENT.TRIGGER_SELECT_SCHEMA, { selectedSC, diff_type });
|
||||||
|
onServerSchemaChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -125,4 +126,5 @@ InputComponent.propTypes = {
|
|||||||
selectedSid: PropTypes.number,
|
selectedSid: PropTypes.number,
|
||||||
selectedDid: PropTypes.number,
|
selectedDid: PropTypes.number,
|
||||||
selectedScid:PropTypes.number,
|
selectedScid:PropTypes.number,
|
||||||
|
onServerSchemaChange:PropTypes.func
|
||||||
};
|
};
|
||||||
|
@ -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 filterRef = useRef(null);
|
||||||
const compareRef = useRef(null);
|
const compareRef = useRef(null);
|
||||||
|
|
||||||
@ -149,6 +149,7 @@ export function SchemaDiffButtonComponent({ sourceData, targetData, selectedRowI
|
|||||||
targetSQL: null,
|
targetSQL: null,
|
||||||
SQLdiff: null,
|
SQLdiff: null,
|
||||||
});
|
});
|
||||||
|
onServerSchemaChange();
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateScript = () => {
|
const generateScript = () => {
|
||||||
@ -218,6 +219,7 @@ SchemaDiffButtonComponent.propTypes = {
|
|||||||
sourceData: PropTypes.object,
|
sourceData: PropTypes.object,
|
||||||
targetData: PropTypes.object,
|
targetData: PropTypes.object,
|
||||||
selectedRowIds: PropTypes.array,
|
selectedRowIds: PropTypes.array,
|
||||||
|
onServerSchemaChange:PropTypes.func,
|
||||||
rows: PropTypes.array,
|
rows: PropTypes.array,
|
||||||
compareParams: PropTypes.object,
|
compareParams: PropTypes.object,
|
||||||
filterParams: PropTypes.array
|
filterParams: PropTypes.array
|
||||||
|
@ -177,6 +177,10 @@ export function SchemaDiffCompare({ params }) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleServerSchemaChange = () => {
|
||||||
|
setSelectedRowIds([]);
|
||||||
|
};
|
||||||
|
|
||||||
function setSourceTargetSid(diff_type, selectedOption) {
|
function setSourceTargetSid(diff_type, selectedOption) {
|
||||||
if (diff_type == TYPE.SOURCE) {
|
if (diff_type == TYPE.SOURCE) {
|
||||||
setSelectedSourceSid(selectedOption);
|
setSelectedSourceSid(selectedOption);
|
||||||
@ -699,6 +703,7 @@ export function SchemaDiffCompare({ params }) {
|
|||||||
selectedDid={selectedSourceDid}
|
selectedDid={selectedSourceDid}
|
||||||
selectedScid={selectedSourceScid}
|
selectedScid={selectedSourceScid}
|
||||||
diff_type={TYPE.SOURCE}
|
diff_type={TYPE.SOURCE}
|
||||||
|
onServerSchemaChange={handleServerSchemaChange}
|
||||||
></InputComponent>
|
></InputComponent>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item lg={5} md={5} sm={2} xs={2} sx={{ display: 'flex',flexDirection: 'row-reverse',paddingRight: '0.3rem'}}>
|
<Grid item lg={5} md={5} sm={2} xs={2} sx={{ display: 'flex',flexDirection: 'row-reverse',paddingRight: '0.3rem'}}>
|
||||||
@ -722,6 +727,7 @@ export function SchemaDiffCompare({ params }) {
|
|||||||
selectedDid={selectedTargetDid}
|
selectedDid={selectedTargetDid}
|
||||||
selectedScid={selectedTargetScid}
|
selectedScid={selectedTargetScid}
|
||||||
diff_type={TYPE.TARGET}
|
diff_type={TYPE.TARGET}
|
||||||
|
onServerSchemaChange={handleServerSchemaChange}
|
||||||
></InputComponent>
|
></InputComponent>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@ -733,6 +739,7 @@ export function SchemaDiffCompare({ params }) {
|
|||||||
'scid': selectedSourceScid,
|
'scid': selectedSourceScid,
|
||||||
}}
|
}}
|
||||||
selectedRowIds={selectedRowIds}
|
selectedRowIds={selectedRowIds}
|
||||||
|
onServerSchemaChange={handleServerSchemaChange}
|
||||||
rows={apiResult}
|
rows={apiResult}
|
||||||
targetData={{
|
targetData={{
|
||||||
'sid': selectedTargetSid,
|
'sid': selectedTargetSid,
|
||||||
|
Loading…
Reference in New Issue
Block a user