From 345cfd7c60ac50ac915efdbc59465c4c392faf34 Mon Sep 17 00:00:00 2001 From: Khushboo Vashi Date: Tue, 24 May 2022 11:34:23 +0530 Subject: [PATCH] Ensure that unwanted APIs should not be getting called for BigAnimal. Fixes #7368 Updated the BigAnimal icon. --- docs/en_US/release_notes_6_10.rst | 1 + .../misc/cloud/static/js/CloudWizard.jsx | 9 ++- web/pgadmin/misc/cloud/static/js/biganimal.js | 59 +++++++++++-------- .../misc/cloud/static/js/cloud_components.jsx | 3 +- web/pgadmin/static/img/biganimal.svg | 1 + .../static/js/components/ExternalIcon.jsx | 4 ++ 6 files changed, 47 insertions(+), 30 deletions(-) create mode 100644 web/pgadmin/static/img/biganimal.svg diff --git a/docs/en_US/release_notes_6_10.rst b/docs/en_US/release_notes_6_10.rst index 9035a5daa..30b88e6d9 100644 --- a/docs/en_US/release_notes_6_10.rst +++ b/docs/en_US/release_notes_6_10.rst @@ -21,6 +21,7 @@ Bug fixes ********* | `Issue #7002 `_ - Added the ability to detect and warn users about bidirectional Unicode characters. + | `Issue #7368 `_ - Ensure that unwanted APIs should not be getting called for BigAnimal. | `Issue #7372 `_ - Tell Docker to always pull the latest base images when building containers. | `Issue #7373 `_ - Fixed an issue with geometry window zoom mouse scroll not working. | `Issue #7376 `_ - Fixed an issue where a popup for unsaved changes appears when clicking on the open file button for a blank query editor. diff --git a/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx b/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx index cc4b7daad..7c191b95d 100644 --- a/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx +++ b/web/pgadmin/misc/cloud/static/js/CloudWizard.jsx @@ -25,6 +25,8 @@ import {AwsCredentials, AwsInstanceDetails, AwsDatabaseDetails, validateCloudSte validateCloudStep2, validateCloudStep3} from './aws'; import {BigAnimalInstance, BigAnimalDatabase, validateBigAnimal, validateBigAnimalStep2, validateBigAnimalStep3} from './biganimal'; +import { isEmptyString } from 'sources/validators'; +import { AWSIcon, BigAnimalIcon } from '../../../../static/js/components/ExternalIcon'; const useStyles = makeStyles(() => ({ @@ -72,6 +74,8 @@ export default function CloudWizard({ nodeInfo, nodeData }) { const [bigAnimalInstanceData, setBigAnimalInstanceData] = React.useState({}); const [bigAnimalDatabaseData, setBigAnimalDatabaseData] = React.useState({}); + + const axiosApi = getApiInstance(); const [verificationURI, setVerificationURI] = React.useState(''); @@ -194,6 +198,7 @@ export default function CloudWizard({ nodeInfo, nodeData }) { reject(); }); } else if(activeStep == 0 && cloudProvider == 'biganimal') { + if (!isEmptyString(verificationURI)) { resolve(); return; } setErrMsg([MESSAGE_TYPE.INFO, 'Getting EDB BigAnimal verification URL...']); validateBigAnimal() .then((res) => { @@ -272,7 +277,7 @@ export default function CloudWizard({ nodeInfo, nodeData }) { }, {label: 'EDB BigAnimal', value: 'biganimal', icon: }]} > @@ -287,7 +292,7 @@ export default function CloudWizard({ nodeInfo, nodeData }) {
{gettext('By clicking the below button, you will be redirected to the EDB BigAnimal authentication page in a new tab.')}
} - {cloudProvider == 'biganimal' && + {cloudProvider == 'biganimal' && {gettext('Click here to authenticate yourself to EDB BigAnimal')} } {cloudProvider == 'biganimal' && diff --git a/web/pgadmin/misc/cloud/static/js/biganimal.js b/web/pgadmin/misc/cloud/static/js/biganimal.js index 85d41e90a..39c60eae7 100644 --- a/web/pgadmin/misc/cloud/static/js/biganimal.js +++ b/web/pgadmin/misc/cloud/static/js/biganimal.js @@ -17,7 +17,6 @@ import getApiInstance from '../../../../static/js/api_instance'; import { isEmptyString } from 'sources/validators'; import PropTypes from 'prop-types'; - const axiosApi = getApiInstance(); // BigAnimal Instance @@ -33,30 +32,39 @@ export function BigAnimalInstance(props) { return url_for('biganimal.regions'); } }), - instance_types: (region_id)=>getNodeAjaxOptions('biganimal_instance_types', pgAdmin.Browser.Nodes['server'], - props.nodeInfo, props.nodeData, { - useCache:false, - cacheNode: 'server', - customGenerateUrl: ()=>{ - return url_for('biganimal.instance_types', {'region_id': region_id || 0}); - } - }), - volume_types: (region_id)=>getNodeAjaxOptions('biganimal_volume_types', pgAdmin.Browser.Nodes['server'], - props.nodeInfo, props.nodeData, { - useCache:false, - cacheNode: 'server', - customGenerateUrl: ()=>{ - return url_for('biganimal.volume_types', {'region_id': region_id || 0}); - } - }), - volume_properties: (region_id, volume_type)=>getNodeAjaxOptions('biganimal_volume_properties', pgAdmin.Browser.Nodes['server'], - props.nodeInfo, props.nodeData, { - useCache:false, - cacheNode: 'server', - customGenerateUrl: ()=>{ - return url_for('biganimal.volume_properties', {'region_id': region_id || 0, 'volume_type': volume_type || ''}); - } - }), + instance_types: (region_id)=>{ + if (isEmptyString(region_id)) return []; + return getNodeAjaxOptions('biganimal_instance_types', pgAdmin.Browser.Nodes['server'], + props.nodeInfo, props.nodeData, { + useCache:false, + cacheNode: 'server', + customGenerateUrl: ()=>{ + return url_for('biganimal.instance_types', {'region_id': region_id || 0}); + } + }); + }, + volume_types: (region_id)=>{ + if (isEmptyString(region_id)) return []; + return getNodeAjaxOptions('biganimal_volume_types', pgAdmin.Browser.Nodes['server'], + props.nodeInfo, props.nodeData, { + useCache:false, + cacheNode: 'server', + customGenerateUrl: ()=>{ + return url_for('biganimal.volume_types', {'region_id': region_id || 0}); + } + }); + }, + volume_properties: (region_id, volume_type)=>{ + if (isEmptyString(region_id) || isEmptyString(volume_type)) return []; + return getNodeAjaxOptions('biganimal_volume_properties', pgAdmin.Browser.Nodes['server'], + props.nodeInfo, props.nodeData, { + useCache:false, + cacheNode: 'server', + customGenerateUrl: ()=>{ + return url_for('biganimal.volume_properties', {'region_id': region_id || 0, 'volume_type': volume_type || ''}); + } + }); + }, }, { nodeInfo: props.nodeInfo, nodeData: props.nodeData, @@ -146,7 +154,6 @@ export function validateBigAnimal() { }); } - function createData(name, value) { return { name, value }; } diff --git a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx index 8b80ee2b8..742c402b7 100644 --- a/web/pgadmin/misc/cloud/static/js/cloud_components.jsx +++ b/web/pgadmin/misc/cloud/static/js/cloud_components.jsx @@ -12,7 +12,6 @@ import { ToggleButton, ToggleButtonGroup } from '@material-ui/lab'; import CheckRoundedIcon from '@material-ui/icons/CheckRounded'; import { DefaultButton, PrimaryButton } from '../../../../static/js/components/Buttons'; import { makeStyles } from '@material-ui/core/styles'; -import { AWSIcon } from '../../../../static/js/components/ExternalIcon'; import PropTypes from 'prop-types'; import { getAWSSummary } from './aws'; import { getBigAnimalSummary } from './biganimal'; @@ -49,7 +48,7 @@ export function ToggleButtons(props) { (props.options||[]).map((option)=>{ return (   - {option.value == 'rds' ? : ''}  {option.label} + {option.icon}  {option.label} ); }) } diff --git a/web/pgadmin/static/img/biganimal.svg b/web/pgadmin/static/img/biganimal.svg new file mode 100644 index 000000000..832a8a8cb --- /dev/null +++ b/web/pgadmin/static/img/biganimal.svg @@ -0,0 +1 @@ + diff --git a/web/pgadmin/static/js/components/ExternalIcon.jsx b/web/pgadmin/static/js/components/ExternalIcon.jsx index 0edd5eac3..13e986201 100644 --- a/web/pgadmin/static/js/components/ExternalIcon.jsx +++ b/web/pgadmin/static/js/components/ExternalIcon.jsx @@ -15,6 +15,7 @@ import PropTypes from 'prop-types'; import Expand from '../../img/fonticon/open_in_full.svg?svgr'; import Collapse from '../../img/fonticon/close_fullscreen.svg?svgr'; import AWS from '../../img/aws.svg?svgr'; +import BigAnimal from '../../img/biganimal.svg?svgr'; export default function ExternalIcon({Icon, ...props}) { return ; @@ -68,3 +69,6 @@ MinimizeDialogIcon.propTypes = {style: PropTypes.object}; export const AWSIcon = ({style})=>; AWSIcon.propTypes = {style: PropTypes.object}; + +export const BigAnimalIcon = ({style})=>; +BigAnimalIcon.propTypes = {style: PropTypes.object};