PromucFlow_constructor/app/client/src/PluginActionEditor
Ankita Kinger 5e89aa056e
chore: Opening response pane by default on query creation and for page load queries (#37245)
## Description

Opening response pane by default on query creation and for page load
queries

Fixes [#37216](https://github.com/appsmithorg/appsmith/issues/37216)

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11723600626>
> Commit: 98db89cea1891e15fa5881503fa34a26d42cfd76
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11723600626&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 07 Nov 2024 13:48:18 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
- Enhanced the `PluginActionResponse` component for improved
functionality and dynamic response handling.
- Introduced a new state variable to manage response tab visibility on
initial load.
- Added logic to automatically open the response and schema tabs based
on action responses.

- **Bug Fixes**
- Improved control flow and error handling for displaying responses
based on action success.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Ankita Kinger <ankitakinger@Ankitas-MacBook-Pro.local>
2024-11-08 11:10:49 +05:30
..
components chore: Opening response pane by default on query creation and for page load queries (#37245) 2024-11-08 11:10:49 +05:30
constants chore: Moving action settings from editor form to toolbar (#36894) 2024-10-18 11:18:08 +05:30
hooks chore: refactor query duplication flow (#36915) 2024-10-24 14:01:00 +05:30
store fix: API Body format focus retention (#37150) 2024-11-01 11:24:49 +05:30
transformers chore: Migrate sub components into Plugin Action Editor (#36844) 2024-10-16 18:29:10 +05:30
index.ts chore: Docs in Plugin Action Toolbar (#36881) 2024-10-16 09:22:46 +05:30
PluginActionContext.tsx chore: Updating some states related to action execution (#36801) 2024-10-11 10:50:20 +05:30
PluginActionEditor.tsx chore: Migrate sub components into Plugin Action Editor (#36844) 2024-10-16 18:29:10 +05:30
readme.md chore: Migrate sub components into Plugin Action Editor (#36844) 2024-10-16 18:29:10 +05:30

Plugin Action Editor

Appsmith allows its users to connect their UI to various different data sources e.g. API end points or SQL Query Databases. These data sources are configured using "Plugins" that define various details about the configuration and execution. Each data source is a specific connection and users can have multiple "Actions" built on top of these data sources.

Actions are implementations that can store and retrieve data from the data source.

The Plugin Action Editor is a module that exposes the UX that is used by the users to implement details about these actions, its settings and test them in edit mode.

Contents

This module is divided into 3 major composable sections.

  • Toolbar: A row for the tools on top of the Action. Comes with Settings, Run Buttons and an overflow menu CTA to add further management items like copy or delete. Allows to add more items in it
  • Form: A preset form based defined by the Plugin config.
  • Response: A tabbed bottom view to show the Response and other debugging tools

One can use these 3 sections to define their compose different experiences.

Plugin Action Context

All the sections and its children are connected via the "Plugin Action Context" that allows for easy data passing.

The Wrapper "PluginActionEditor" will pass this context down. This includes:

  • Action
  • Action Response
  • Plugin
  • Datasource
  • Form Configs
  • Setting Configs

UI Store

The UI state is managed via redux, and it is exposed out as well for use

How to use

Below we illustrate how by using a Composable structure to create the Action Editor

const AppPluginActionEditor = () => {
  // Define the actionId that needs to be configured via the editor.
  // In the example we fetch it from the route
  const actionId = getActionIDFromRoute();
  return (
    /** Plugin Action Editor is our wrapper composable fragment.
     * This will fetch the action and other related info
     * from state and pass it down to its children via "context".
     * This will ensure all children have the same way to access the action
     * i.e. via context. Hence, this component is only responsible for
     * abstracting the
     * action state management
    */
    <PluginActionEditor actionID={actionID}>
      <PluginActionToolbar />
      <PluginActionForm />
      <PluginActionResponse />
    </PluginActionEditor>
  )
}

It is completely possible to mix and match these components, and compose them further to build other experiences with them. For example if you need to just have the Response view without the form you can do the following

const PluginActionResponseView = () => {
  // Define the actionId that needs to be configured via the editor.
  // In the example we fetch it from the route
  const actionId = getActionIDFromRoute();
  return (
    <PluginActionEditor actionID={actionID}>
      <PluginActionResponse />
    </PluginActionEditor>
  )
}

Update Guide

  1. Update an existing functionality to be reflected in all variations
    • Functionality updates should be done at the point of definition itself.
    • Prefer having separate files for each functionality if it has a lot of logic or can be extended in EE
  2. Add new functionality for all variations
    • Add the functionality close to the usage point.
    • Avoid configuration of functionality via props since it is used for all.
  3. Add an EE variation to a functionality.
    • Avoid adding any EE logic for this functionality as much as possible
    • Ideally it should be exposed as a prop that can be updated in the EE usage point
    • In case it needs to be done in place, make sure the functionality is its own file so that only that functionality needs extension.
  4. Create a specific variance for a certain use case not applicable for all
    • Avoid adding the logic inside the module instead override via composition
    • If it affects any feature in the module, expose via prop