Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI changes for DAG Reparsing feature #39636

Merged
merged 10 commits into from
May 22, 2024
14 changes: 14 additions & 0 deletions airflow/www/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,17 @@ $(document).ready(() => {
// Global Tooltip selector
$(".js-tooltip").tooltip();
});

$(".reparse_dag").click((event) => {
event.preventDefault();
$.ajax({
url: event.currentTarget.attributes.href.value,
type: "PUT",
success: (response) => {
console.log(response);
utkarsharma2 marked this conversation as resolved.
Show resolved Hide resolved
},
error: (response) => {
console.log(response);
},
});
});
6 changes: 6 additions & 0 deletions airflow/www/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@ <h4 class="js-dataset-triggered" style="user-select: none;-moz-user-select: auto
onclick="return confirmDeleteDag(this, '{{ dag.safe_dag_id }}')">
<span class="material-icons text-danger" aria-hidden="true">delete_outline</span>
</a>
<a href="{{ url_for('/api/v1.airflow_api_connexion_endpoints_dag_parsing_reparse_dag_file', file_token=dag.file_token) }}"
title="Reparse&nbsp;DAG"
aria-label="Reparse DAG"
class="btn btn-default btn-icon-only{{ ' disabled' if not dag.can_edit }} reparse_dag">
<span class="material-icons">cached</span>
</a>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ <h2>{{ page_title }}</h2>
class="btn btn-sm btn-default btn-icon-only{{ ' disabled' if not dag.can_delete }}">
<span class="material-icons text-danger" aria-hidden="true">delete_outline</span>
</a>
<a href="{{ url_for('/api/v1.airflow_api_connexion_endpoints_dag_parsing_reparse_dag_file', file_token=dag.file_token) }}" title="Reparse&nbsp;DAG" aria-label="Reparse DAG"
class="btn btn-sm btn-default btn-icon-only{{ ' disabled' if not dag.can_edit }} reparse_dag">
<span class="material-icons">cached</span>
</a>
utkarsharma2 marked this conversation as resolved.
Show resolved Hide resolved
{% endif %}
</div>
</td>
Expand Down
5 changes: 5 additions & 0 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Response,
abort,
before_render_template,
current_app,
flash,
g,
has_request_context,
Expand All @@ -67,6 +68,7 @@
from flask_appbuilder.urltools import get_order_args, get_page_args, get_page_size_args
from flask_appbuilder.widgets import FormWidget
from flask_babel import lazy_gettext
from itsdangerous import URLSafeSerializer
from jinja2.utils import htmlsafe_json_dumps, pformat # type: ignore
from markupsafe import Markup, escape
from pendulum.datetime import DateTime
Expand Down Expand Up @@ -163,6 +165,7 @@
SENSITIVE_FIELD_PLACEHOLDER = "RATHER_LONG_SENSITIVE_FIELD_PLACEHOLDER"

logger = logging.getLogger(__name__)
url_serializer = URLSafeSerializer(current_app.config["SECRET_KEY"])


def sanitize_args(args: dict[str, Any]) -> dict[str, Any]:
Expand Down Expand Up @@ -937,6 +940,7 @@ def index(self):
dag.can_delete = get_auth_manager().is_authorized_dag(
method="DELETE", details=DagDetails(id=dag.dag_id), user=g.user
)
dag.file_token = url_serializer.dumps(dag.fileloc)

dagtags = session.execute(select(func.distinct(DagTag.name)).order_by(DagTag.name)).all()
tags = [
Expand Down Expand Up @@ -2846,6 +2850,7 @@ def grid(self, dag_id: str, session: Session = NEW_SESSION):
color_log_warning_keywords = conf.get("logging", "color_log_warning_keywords", fallback="")

dag = get_airflow_app().dag_bag.get_dag(dag_id, session=session)
dag.file_token = url_serializer.dumps(dag.fileloc)
dag_model = DagModel.get_dagmodel(dag_id, session=session)
if not dag:
flash(f'DAG "{dag_id}" seems to be missing from DagBag.', "error")
Expand Down
Loading