Re: RM3694-If database is already connected and click on databasethen connect database should not displayed in Menu - Mailing list pgadmin-hackers

From Khushboo Vashi
Subject Re: RM3694-If database is already connected and click on databasethen connect database should not displayed in Menu
Date
Msg-id CAFOhELcayfLZQVM8CyNf59kkJ36sO07JOOH9fLYwAjBMG83_CA@mail.gmail.com
Whole thread Raw
In response to RM3694-If database is already connected and click on database thenconnect database should not displayed in Menu  (Satish V <satish.v@enterprisedb.com>)
Responses Re: RM3694-If database is already connected and click on databasethen connect database should not displayed in Menu  (Satish V <satish.v@enterprisedb.com>)
List pgadmin-hackers
Hi Satish,

As per the RM, the fix is supposed to be at the front-end but it seems difficult at the moment as on the selection of the database, we connect it and at the same time the context menu is being called.
As you have tried to fix at the backend, some of the review comments are below.

1.  If the database is already connected, no need to call conn.connect again.

info_already_connected = conn.connected()
status, errmsg = conn.connect()
2. If you want to raise an error at the client side, use the appropriate function or status (check file ajax.py) at the server side and send the appropriate response. 
Below code needs to be changed.
if(res.data.info_already_connected){
  Alertify.error(res.info);
} else {
  Alertify.success(res.info);
}
Thanks,
Khushboo


On Wed, Apr 29, 2020 at 8:20 PM Satish V <satish.v@enterprisedb.com> wrote:
Hi Hackers,

In the patch attached, we are gracefully informing the end user, using an alert message, that the database is already connected when they click "Connect Database..." after right clicking on a disconnected database. 

As this problem deals with racing conditions, it is highly complex to show the "Disconnect database" option in the menu upon right click. So we are alerting the end user with the information of "Database already connected".

Thanks,
Sathish V

pgadmin-hackers by date:

Previous
From: Dave Page
Date:
Subject: pgAdmin 4 commit: Another attempt at fixing the 'do we need the --embed
Next
From: Satish V
Date:
Subject: Re: RM3694-If database is already connected and click on databasethen connect database should not displayed in Menu