appsmithorg / appsmith

Platform to build admin panels, internal tools, and dashboards. Integrates with 25+ databases and any API.
https://www.appsmith.com
Apache License 2.0
34.03k stars 3.67k forks source link

[Epic] Reusable Queries & JS (Code Packages) #1911

Open mohanarpit opened 3 years ago

mohanarpit commented 3 years ago

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:

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

Nikhil-Nandagopal commented 7 months ago

@macasas I fully agree with that thought process and as I mentioned we do plan to introduce some form of reusability that will enable the community to implement DRY in their apps before they upgrade. We're just starting with releasing it for business first. You can read about this here with our thoughts on it. These thoughts will evolve over time as we learn about the usage of this feature and we extend support to the community. https://community.appsmith.com/content/blog/boosting-productivity-reusability

I just want to leave you all with the final thoughts that

pedro-santos-rodrigues commented 6 months ago

Appsmith Reusability Beta launch 🚀

I'd like to share that Appsmith Reusability Beta is already available for the self-hosted business and enterprise users as announced in this blog post.

You should be using v1.17 or later.

We're launching this Beta program so that we can continuously improve the experience of this functionality while still working on it based on your feedback and usage. If you want to share your thoughts, feedback, questions, or what didn't quite work for you, you just need to choose a 30 min slot that suits well in your agenda using the following link:

Book 30min slot to provide feedback about Appsmith Reusability Beta

Thank you.

image