bbovenzi commented on code in PR #37436:
URL: https://github.com/apache/airflow/pull/37436#discussion_r1496808744
##########
airflow/www/static/js/dags.js:
##########
@@ -126,16 +126,75 @@ $(".typeahead").typeahead({
success: callback,
});
},
+ matcher(item) {
+ const it = this.displayText(item);
+ const query = this.query.toLowerCase();
+ const queryValue = query.replace(/^([a-z]+:\s*)/i, "");
+
+ return it.toLowerCase().indexOf(queryValue) !== -1;
+ },
+ displayText(item) {
+ if (typeof item !== "undefined" && typeof item.name !== "undefined") {
+ if (item.type === "task") {
+ return `${item.type}: ${item.name} <i>in ${item.dag_id}</i>`;
+ }
+ return `${item.type}: ${item.name}`;
+ }
+ return item;
+ },
+ sorter(items) {
+ const beginswith = [];
+ const caseSensitive = [];
+ const caseInsensitive = [];
+ let item;
+ let { query } = this;
+ query = query.replace(/^([a-z]+:\s*)/i, "");
+
+ while (items.length) {
+ item = items.shift();
+ if (!item.name.toLowerCase().indexOf(query.toLowerCase())) {
+ beginswith.push(item);
+ } else if (item.name.indexOf(query) !== -1) {
+ caseSensitive.push(item);
+ } else {
+ caseInsensitive.push(item);
+ }
+ }
+
+ return beginswith.concat(caseSensitive, caseInsensitive);
+ },
+ highlighter(displayText, item) {
+ let { query } = this;
+ query = query.replace(/^([a-z]+:\s*)/i, "");
+
+ if (query === "") {
+ return displayText;
+ }
+
+ let { name } = item;
+ query = query.replace(/[()/.*+?[\]]/g, (mat) => `\\${mat}`);
+ const reg = new RegExp(query, "gi");
+ name = name.replace(name, name.replace(reg, "<strong>$&</strong>"));
+ return displayText.replace(item.name, name);
+ },
autoSelect: false,
afterSelect(value) {
const query = new URLSearchParams(window.location.search);
- query.set("search", value.name);
if (value.type === "owner") {
+ query.set("search", value.name);
window.location = `${DAGS_INDEX}?${query}`;
}
if (value.type === "dag") {
+ query.set("search", value.name);
window.location = `${gridUrl.replace("__DAG_ID__",
value.name)}?${query}`;
}
+ if (value.type === "task") {
+ query.set("search", value.dag_id);
Review Comment:
```suggestion
query.set("task_id", value.name);
```
Rebase and then changing the searh param will allow you to navigate directly
to the task in question
--
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]