bbovenzi commented on code in PR #75229:
URL: https://github.com/apache/airflow/pull/75229#discussion_r4340400003


##########
airflow-core/docs/howto/custom-action-plugin.rst:
##########
@@ -0,0 +1,337 @@
+ .. Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+ ..   http://www.apache.org/licenses/LICENSE-2.0
+
+ .. Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+
+Add your own actions to Dags, Dag Runs and Task Instances
+=========================================================
+
+Airflow renders a fixed set of actions for each entity — pause, trigger, 
clear, mark as,
+delete. ``AirflowPlugin.ui_actions`` lets you add your own beside them, 
everywhere Airflow already
+offers actions for that entity:
+
+* the trailing cell of its **table rows**,
+* its **card**, on lists that have a card view, and
+* the action row of its **header card** on the detail page.
+
+An action either opens a URL or mounts a React component of your own. Unlike
+``external_views`` and ``react_apps``, which each take over a whole tab, an 
action is a single
+button — the right size for "open the runbook for this Dag" or "show me this 
task's payload".
+
+Your first action
+-----------------
+
+Drop this in a file under your :doc:`plugins folder 
</administration-and-deployment/plugins>`:
+
+.. code-block:: python
+
+    from airflow.plugins_manager import AirflowPlugin
+
+
+    class RunbookPlugin(AirflowPlugin):
+        name = "runbook_plugin"
+
+        ui_actions = [
+            {
+                "action_type": "link",
+                "name": "Open runbook",
+                "destination": "dag",
+                "href": "https://runbooks.example.com/{DAG_ID}";,
+            }
+        ]
+
+Restart the API server. Every Dag now carries an "Open runbook" button — on 
each row and card
+of the Dags list, and in the header of each Dag's detail page — pointing at 
that Dag's
+runbook.
+
+Four keys are required: ``action_type``, ``name``, ``destination``, and the 
target the kind
+needs (``href`` for ``link``, ``bundle_url`` for ``react``). ``name`` is the 
button's tooltip
+and its accessible label, so write it as a label rather than an identifier.
+
+``destination`` picks the entity, and with it the surfaces the button appears 
on:
+
+.. list-table::
+   :header-rows: 1
+
+   * - ``destination``
+     - Appears on
+     - Template variables
+   * - ``dag``
+     - Dags list rows and cards, Dag detail header
+     - ``{DAG_ID}``
+   * - ``dag_run``
+     - Dag Runs rows, Dag Run detail header
+     - ``{DAG_ID}``, ``{RUN_ID}``
+   * - ``task_instance``
+     - Task Instances rows, Task Instance detail header
+     - ``{DAG_ID}``, ``{RUN_ID}``, ``{TASK_ID}``, ``{MAP_INDEX}``
+
+A variable with no value on the current page is left in the URL as-is rather 
than replaced
+with an empty string, so a half-resolved link fails visibly instead of quietly 
pointing
+somewhere else. Values are URL-encoded for you.
+
+Internal and external links
+---------------------------
+
+A link that matches an Airflow UI route navigates inside the app, with no page 
reload:
+
+.. code-block:: python
+
+    {
+        "action_type": "link",
+        "name": "Jump to runs",
+        "destination": "dag",
+        "href": "/dags/{DAG_ID}/runs",

Review Comment:
   getInternalRouteTo now resolves against document.baseURI to test relative 
and absolute paths. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to