Skip to content

Commit

Permalink
Keep confirmDeleteDag inline html (#15836)
Browse files Browse the repository at this point in the history
Tests and delete functionality rely on `confirmDeleteDag` to be inside the html. It is simpler just to have it inline instead of refactoring all dependent tests to make it work in an external js file.
  • Loading branch information
bbovenzi authored May 14, 2021
1 parent 51e54cb commit 634c12d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
14 changes: 1 addition & 13 deletions airflow/www/static/js/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

/* global document, window, $, confirm, postAsForm, confirm */
/* global document, window, $, */

import getMetaValue from './meta_value';

Expand Down Expand Up @@ -216,18 +216,6 @@ export function callModalDag(dag) {
});
}

// eslint-disable-next-line no-unused-vars
function confirmDeleteDag(link, id) {
// eslint-disable-next-line no-alert, no-restricted-globals
if (confirm(`Are you sure you want to delete '${id}' now?\n\
This option will delete ALL metadata, DAG runs, etc.\n\
EXCEPT Log.\n\
This cannot be undone.`)) {
postAsForm(link.href, {});
}
return false;
}

// Task Instance Modal actions
$('form[data-action]').on('submit', function submit(e) {
e.preventDefault();
Expand Down
14 changes: 1 addition & 13 deletions airflow/www/static/js/dags.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

/* global document, window, $, d3, STATE_COLOR, postAsForm, isoDateToTimeEl, confirm */
/* global document, window, $, d3, STATE_COLOR, isoDateToTimeEl, */

import getMetaValue from './meta_value';

Expand Down Expand Up @@ -81,18 +81,6 @@ $('#page_size').on('change', function onPageSizeChange() {
window.location = `${DAGS_INDEX}?page_size=${pSize}`;
});

// eslint-disable-next-line no-unused-vars
function confirmDeleteDag(link, dagId) {
// eslint-disable-next-line no-alert, no-restricted-globals
if (confirm(`Are you sure you want to delete '${dagId}' now?\n\
This option will delete ALL metadata, DAG runs, etc.\n\
EXCEPT Log.\n\
This cannot be undone.`)) {
postAsForm(link.href, {});
}
return false;
}

const encodedDagIds = new URLSearchParams();

$.each($('[id^=toggle]'), function toggleId() {
Expand Down
12 changes: 12 additions & 0 deletions airflow/www/templates/airflow/dag.html
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,16 @@ <h4 class="modal-title" id="dagModalLabel">
{% block tail %}
{{ super() }}
<script src="{{ url_for_asset('dag.js') }}"></script>
<script>
// Tests rely on confirmDeleteDag to be in the html
function confirmDeleteDag(link, id) {
if (confirm(`Are you sure you want to delete '${id}' now?\n\
This option will delete ALL metadata, DAG runs, etc.\n\
EXCEPT Log.\n\
This cannot be undone.`)) {
postAsForm(link.href, {});
}
return false;
}
</script>
{% endblock %}
10 changes: 10 additions & 0 deletions airflow/www/templates/airflow/dags.html
Original file line number Diff line number Diff line change
Expand Up @@ -277,5 +277,15 @@ <h2>{{ page_title }}</h2>
<script src="{{ url_for_asset('dags.js') }}"></script>
<script>
const STATE_COLOR = {{ state_color|tojson }};
// Tests rely on confirmDeleteDag to be in the html
function confirmDeleteDag(link, dagId) {
if (confirm(`Are you sure you want to delete '${dagId}' now?\n\
This option will delete ALL metadata, DAG runs, etc.\n\
EXCEPT Log.\n\
This cannot be undone.`)) {
postAsForm(link.href, {});
}
return false;
}
</script>
{% endblock %}

0 comments on commit 634c12d

Please sign in to comment.