Subject: RM-2519: Show the trigger function under the trigger node.

From: Akshay Joshi <[email-masked]>
Date: Thu, 8 Oct 2020 20:12:47 +0530

Hi Dave/Team

I have started working on RM #2519 to show the trigger function under the
trigger node. I have made the changes to the code and the trigger function
is visible under the respective trigger node.

Changes made to achieve this:

   - If the trigger function is in the same schema then it works
   absolutely fine, the user can update the properties, view the SQL,
   Statistics, Dependencies, and Dependents.
   - If the trigger function is from the other schema then we need to
   change the schema id as we have a strict API route which adds the schema id
   where the trigger exists. Change has been done and it works.
   - For the trigger function from the other schema, I have added the
   schema-qualified name.
   - Remove the menu options and add a dummy menu "No menu is available for
   this object" when the user selects the trigger function under the trigger
   node. Have to do this because of the different API routes, as the object is
   not available and personally, I feel we should not show the context menu to
   create, delete, drop from there.

*Note:* To remove the menu option completely I have modified the *menu.js* and
check if the 'showMenu' function is defined. If it is defined then call
that function and based on the return value, will make the decision.

Please refer to the below screenshot for more clarity:

Thought/Suggestion?

-- 
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Sr. Software Architect*
*EDB Postgres <http://edbpostgres.com>*

*Mobile: +91 976-788-8246*

---

From: Dave Page <[email-masked]>
Date: Thu, 8 Oct 2020 15:52:27 +0100

Hi Akshay,

On Thu, Oct 8, 2020 at 3:43 PM Akshay Joshi <[email-masked]>
wrote:

>    - Remove the menu options and add a dummy menu "No menu is available
>    for this object" when the user selects the trigger function under the
>    trigger node. Have to do this because of the different API routes, as the
>    object is not available and personally, I feel we should not show the
>    context menu to create, delete, drop from there.
>

Yeah, we should not be able to create/drop there, as the trigger must have
the function anyway (you can't define a trigger without a function in PG,
nor can you drop a function that's being used by a trigger).

However, we should have a working Properties option I would say.

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EDB: http://www.enterprisedb.com

---

From: Akshay Joshi <[email-masked]>
Date: Thu, 8 Oct 2020 22:17:33 +0530

On Thu, 8 Oct, 2020, 20:22 Dave Page, <[email-masked]> wrote:

>> *Note:* To remove the menu option completely I have modified the
>> *menu.js* and check if the 'showMenu' function is defined. If it is
>> defined then call that function and based on the return value, will make
>> the decision.
>>

    Yes, it is working from properties tab. User can edit from there.

---

From: Akshay Joshi <[email-masked]>
Date: Fri, 9 Oct 2020 14:28:09 +0530

Hi Dave/Team

On Thu, Oct 8, 2020 at 10:17 PM Akshay Joshi <[email-masked]>
wrote:

>> On Thu, Oct 8, 2020 at 3:43 PM Akshay Joshi <
>> [email-masked]> wrote:
>>
>>> Hi Dave/Team
>>>
>>> I have started working on RM #2519 to show the trigger function under
>>> the trigger node. I have made the changes to the code and the trigger
>>> function is visible under the respective trigger node.
>>>
>> Yeah, we should not be able to create/drop there, as the trigger must
>> have the function anyway (you can't define a trigger without a function in
>> PG, nor can you drop a function that's being used by a trigger).
>>

        I have tested it today and it works perfectly fine if the trigger
function is in the same schema, but if we edit properties of the trigger
function from another schema eventually that object is updated properly,
but it is not visible under the trigger node. The user needs to refresh the
trigger node to make it visible again. I am checking it how we can fix this
but not found any solution yet.

---

From: Akshay Joshi <[email-masked]>
Date: Mon, 12 Oct 2020 11:59:01 +0530

Hi Dave/Team

On Fri, Oct 9, 2020 at 2:28 PM Akshay Joshi <[email-masked]>
wrote:

> Hi Dave/Team
>
> On Thu, Oct 8, 2020 at 10:17 PM Akshay Joshi <
>>>>    - Remove the menu options and add a dummy menu "No menu is
>>>>    available for this object" when the user selects the trigger function under
>>>>    the trigger node. Have to do this because of the different API routes, as
>>>>    the object is not available and personally, I feel we should not show the

    I tried a lot to fix the above-mentioned issue but due to our rigid
node structure, it's been difficult to update and show nodes from another
schema. One more example is if there are so many triggers that use the
common trigger function and we provide the update of the trigger function
from the properties tab then we will have to refresh all the triggers uses
that function.

   As we already disabled the context menu, I would suggest disabling the
"Edit" button on the properties tab to fix the above-mentioned issue.
According to the actual request, the user wants to see the trigger function
under the trigger node and see the SQL.

   If the above looks good I'll commit the code.

---

From: Dave Page <[email-masked]>
Date: Mon, 12 Oct 2020 09:58:04 +0100

>    If the above looks good I'll commit the code.

Hmm, yeah. How much work would it be to have a "Navigate to function"
context menu option that locates and selects the "real" function in the
treeview?

---

From: Akshay Joshi <[email-masked]>
Date: Mon, 12 Oct 2020 14:32:24 +0530

On Mon, Oct 12, 2020 at 2:28 PM Dave Page <[email-masked]> wrote:

>
>
> On Mon, Oct 12, 2020 at 7:29 AM Akshay Joshi <
>> On Fri, Oct 9, 2020 at 2:28 PM Akshay Joshi <
>>>>>>    - If the trigger function is from the other schema then we need
>>>>>>    to change the schema id as we have a strict API route which adds the schema
>>>>>>    id where the trigger exists. Change has been done and it works.
>>>>>>    - For the trigger function from the other schema, I have added
>>>>>>    the schema-qualified name.
>>>         I have tested it today and it works perfectly fine if the
>>> trigger function is in the same schema, but if we edit properties of the
>>> trigger function from another schema eventually that object is updated
>>> properly, but it is not visible under the trigger node. The user needs to
>>> refresh the trigger node to make it visible again. I am checking it how we
>>> can fix this but not found any solution yet.
>>>
>>

   I have committed the code with the "Edit" button disabled, will analyze
and create a new RM for that.

---

From: Aditya Toshniwal <[email-masked]>
Date: Mon, 12 Oct 2020 14:35:57 +0530

Hi,

On Mon, Oct 12, 2020 at 2:32 PM Akshay Joshi <[email-masked]>
wrote:

>>>>>>> I have started working on RM #2519 to show the trigger function
>>>>>>> under the trigger node. I have made the changes to the code and the trigger
>>>    As we already disabled the context menu, I would suggest disabling
>>> the "Edit" button on the properties tab to fix the above-mentioned issue.
You can refer search objects code, it does the same thing - locate the
object on tree.

-- 
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com>
"Don't Complain about Heat, Plant a TREE"

---

From: Akshay Joshi <[email-masked]>
Date: Mon, 12 Oct 2020 14:51:12 +0530

On Mon, Oct 12, 2020 at 2:36 PM Aditya Toshniwal <
[email-masked]> wrote:

> Hi,
>
> On Mon, Oct 12, 2020 at 2:32 PM Akshay Joshi <
>>>>>>>> *menu.js* and check if the 'showMenu' function is defined. If it
>>>>>>>> is defined then call that function and based on the return value, will make
>>>>>>>> the decision.
>>>>>>>>
>>>>>>> Yeah, we should not be able to create/drop there, as the trigger
>>>>>>> must have the function anyway (you can't define a trigger without a
>>>>>>> function in PG, nor can you drop a function that's being used by a trigger).
>>>>>>>
>>    I have committed the code with the "Edit" button disabled, will
>> analyze and create a new RM for that.
>>

   We need to check the feasibility as this option should be disabled for
the trigger function whose parent is not a trigger. Also, need to modify
the logic of the disabled menu completely. We will have to show only one
menu option "Navigate to function".