This is an automated email from the ASF dual-hosted git repository. kaxilnaik pushed a commit to branch v3-0-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit d8219acfb065924fc9567b7426c4285a57b3a007 Author: Pierre Jeambrun <[email protected]> AuthorDate: Thu Apr 17 23:27:48 2025 +0200 Rewrite custom view plugin docs (#49408) (cherry picked from commit 37bd0f0dad3078247c2db8c95a79614f98950dbd) --- airflow-core/docs/howto/custom-view-plugin.rst | 72 ++++++++++---------------- docs/spelling_wordlist.txt | 2 + 2 files changed, 30 insertions(+), 44 deletions(-) diff --git a/airflow-core/docs/howto/custom-view-plugin.rst b/airflow-core/docs/howto/custom-view-plugin.rst index e9a5b795e47..9f9dbf15f49 100644 --- a/airflow-core/docs/howto/custom-view-plugin.rst +++ b/airflow-core/docs/howto/custom-view-plugin.rst @@ -20,57 +20,41 @@ Customize view of Apache from Airflow web UI ============================================ Airflow has feature that allows to integrate a custom UI along with its -core UI using the Plugin manager +core UI using the Plugin manager. -This is an example plugin for Airflow that displays absolutely nothing. +Plugins integrate with the Airflow core RestAPI. In this plugin, +two object references are derived from the base class ``airflow.plugins_manager.AirflowPlugin``. +They are fastapi_apps and fastapi_root_middlewares. -In this plugin, two object references are derived from the base class -``airflow.plugins_manager.AirflowPlugin``. They are flask_blueprints and -appbuilder_views +Using fastapi_apps in Airflow plugin, the core RestAPI can be extended +to support extra endpoints to serve custom static file or any other json/application responses. +In this object reference, the list of dictionaries with FastAPI application and metadata information +like the name and the url prefix are passed on. -Using flask_blueprints in Airflow plugin, the core application can be extended -to support the customized application to view Empty Plugin. -In this object reference, the list of Blueprint object with the static template for -rendering the information. +Using fastapi_root_middlewares in Airflow plugin, allows to register custom middleware at the root of +the FastAPI application. This middleware can be used to add custom headers, logging, or any other +functionality to the entire FastAPI application, including core endpoints. +In this object reference, the list of dictionaries with Middleware factories object, +initialization parameters and some metadata information like the name are passed on. -Using appbuilder_views in Airflow plugin, a class that represents a concept is -added and presented with views and methods to implement it. -In this object reference, the list of dictionaries with FlaskAppBuilder BaseView object -and metadata information like name and category is passed on. +Information and code samples to register ``fastapi_apps`` and ``fastapi_root_middlewares`` are +available in :doc:`plugin </administration-and-deployment/plugins>`. +Support for Airflow 2 plugins +============================= -Custom view Registration ------------------------- +Airflow 2 plugins are still supported with some limitations. More information on such +plugins can be found in the Airflow 2 documentation. -A custom view with object reference to flask_appbuilder and Blueprint from flask -and be registered as a part of a :doc:`plugin </administration-and-deployment/plugins>`. +Adding Rest endpoints through the blueprints is still supported, those endpoints will +be integrated in the FastAPI application via the WSGI Middleware and accessible +under ``/pluginsv2``. -The following is a skeleton for us to implement a new custom view: +It is not possible to extend the core UI, for instance by extending the base template, nonetheless extra menu items +of the auth managers are added to the core UI security tab and their ``href`` are rendered in iframes. +This is how the fab provider integrates users, roles, actions, resources and permissions custom views in the Airflow 3 UI. -.. exampleinclude:: /empty_plugin/empty_plugin.py - :language: python - -``Plugins`` specified in the ``category`` key of ``appbuilder_views`` dictionary is -the name of the tab in the navigation bar of the Airflow UI. ``Empty Plugin`` -is the name of the link under the tab ``Plugins``, which will launch the plugin - -We need to add Blueprint for generating the part of the application -that needs to be rendered in Airflow web UI. We can define templates, static files -and this blueprint will be registered as part of the Airflow application when the -plugin gets loaded. - -The ``$AIRFLOW_HOME/plugins`` folder with custom view UI have the following folder structure. - -:: - - plugins - ├── empty_plugin.py - ├── templates - | └── empty_plugin - | ├── index.html - └── README.md - -The HTML files required to render the views built are added as part of the -Airflow plugin into ``$AIRFLOW_HOME/plugins/templates`` folder and defined in the -blueprint. +Airflow 3 plugins will be improved to allow UI customization for the entire react app, it is recommended +to upgrade your plugins to Airflow 3 plugins when possible. Until then for a temporary or custom needs +it is possible to use a Middleware to inject custom javascript or css to the core UI index request. diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index b2688e6f299..60a8d318992 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -845,6 +845,7 @@ idempotency IdP ie iframe +iframes IGM igm ignorable @@ -1108,6 +1109,7 @@ microservice microservices microsoft middleware +middlewares Midnights midnights milli
