apache / apache/airflow

Support multiple buttons from `operator_extra_links`

Open
#28,870 16 comments 0 reactions 0 assignees View on GitHub
area:core kind:feature
Dominant language
Python
Stars
46.9k
Forks
17.8k
Avg merge
2d 10h
Merged PRs (30d)
483

Description

### Description

UPDATE (@potiuk): Seems that better idea is to add support for dynamic collections of links to the operator rather than extend link to support multiple of those.

`BaseOperatorLink` should support returning multiple links:

```python
class ButtonLink:
def __init__(self, name: str, link: str) -> None:
self.name = name
self.link = link

class BaseOperatorLink(metadataclass=ABCMeta):
...
@abstractmethod
def get_links(self, operator: BaseOperator, dttm: datetime) -> List[ButtonLink]:
pass
```

### Use case/motivation

My company has implemented a "MultiExternalTaskSensor" that allows a single task to wait for multiple other tasks to complete.

`ExternalTaskSensor` automatically supports `operator_extra_links` to provide a link to the upstream DAG page, but this is impossible to do with `Multi...` since there's an arbitrary number of buttons that need to show up based on the number of tasks that are being waited on.

Another benefit of allowing this would be that the buttons could support dynamic names, which would allow information about the task (like it's state) to present in the button text.

This would add an additional challenge while the button data was loading, since the name might not be known. At this point, there could either be a default name fallback or a simple loading spinner while we wait for all button names to return.

There would need to be changes to the `/extra_links` API and `dag.js`, but it seems feasible.

It could be implement along the lines of:
```python
class ButtonLink:

def __init__(self, name: str, link: str) -> None:
self.name = name
self.link = link

class BaseOperatorLink(metaclass=ABCMeta):
...

@abstractmethod
def get_links(self, operator: BaseOperator, dttm: datetime) -> List[ButtonLink]:
pass
```

### Related issues

_No response_

### Are you willing to submit a PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Contributor guide

Open the contributing guide

Research direction

Start by reviewing BaseOperatorLink and the existing /extra_links API, then inspect dag.js to understand how operator links are loaded and rendered. The work is complete when the API and UI support multiple dynamically named links, including a defined loading or fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, python
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.