appsmithorg / appsmithorg/appsmith

[Epic] Reusable Queries & JS (Code Packages)

Ouverte
#1,911 54 commentaires 37 réactions 3 personnes assignées Réclamée par @infinitetrooper Voir sur GitHub
Epic JS module Packages & Git Pod Packages Pod Packages Product Query module
Langage dominant
TypeScript
Étoiles
40.9k
Forks
4.8k
Merge moyen
1 j 22 h
PR mergées (30 j)
45

Description

## Problem

Today, all actions (API, DB Query, JS functions) created within Appsmith are page-scoped. This means that they are only accessible from within the page and not across pages within the same application. Often, this confuses users. They expect actions to be global to the entire application. This is because in normal coding practices, that is what they expect.

In order to resolve this, we need to create a way for users to create actions that are accessible across pages and are scoped within the application instead of the page.

## Why were Actions page-scoped in the first place?

During dynamic binding, we want to give users a consistent experience. If they are able to bind `Input.text` in the UI canvas they should also be able to bind `Input.text` in the API pane. If we treat Actions as pure functions, that would mean the action requires variables to be passed into it. This breaks the users mental model of how Appsmith works.

Unfortunately, a side-effect of this is that if the user has bound `Input1.text` in the API, they can't re-use this API with other inputs. This leads to:

- Lot of repetition of actions. To the user, it feels like they are violating the best practices of DRY.
- Increases the cost of maintaining actions as the user now needs to modify the same action in multiple places.

## Goals:

1. Giving the user a consistent discoverable way of binding across the entire product. If I can bind `Input1.text` in one place, I should be able to logically bind `Input1.text` in another place.
2. Allow users to re-use actions with different inputs. The user should be able to invoke an action from multiple pages in the same application.
3. Users must be able to grok the concept of binding without needing to resort to documentation.

### Potential Solutions:

1. Have a section called "Global Actions". The user can then create Actions local to the page while also moving them to a global place. The global actions will have variables of the nature "x, y". These actions can now only be invoked via JS that sets the x & y values before calling `Api1.run()`.

2. Any other thoughts here ... ?

## Success criteria

A user should be able to define an Action once in the entire application and then re-use it in multiple places with different input parameters.

## RACI
| ------------- | ------------- |
| Responsible | @arunvjn @Rishabh-Rathod |
| Accountable | @arunvjn |
| Consulted | @Nikhil-Nandagopal, @mohanarpit @ajinkyakulkarni |
| Informed | @parth-appsmith |

Front logo [Front conversations](https://app.frontapp.com/open/top_56ej0)

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.