bbovenzi commented on code in PR #38021:
URL: https://github.com/apache/airflow/pull/38021#discussion_r1520122999
##########
airflow/www/static/js/dag/details/taskInstance/Logs/utils.ts:
##########
@@ -103,10 +114,27 @@ export const parseLogs = (
const coloredLine = ansiUp.ansi_to_html(parsedLine);
// for lines with links, transform to hyperlinks
- const lineWithHyperlinks = coloredLine.replace(
- /((https?:\/\/|http:\/\/)[^\s]+)/g,
- '<a href="$1" target="_blank" style="color: blue; text-decoration:
underline;">$1</a>'
- );
+ const lineWithHyperlinks = coloredLine
+ .replace(
+ urlRegex,
+ '<a href="$1" target="_blank" style="color: blue; text-decoration:
underline;">$1</a>'
+ )
+ .replace(logGroupStart, (textLine) => {
+ const gName = textLine.substring(17);
+ const gId = gName.replace(/\W+/g, "_").toLowerCase();
+ if (unfoldedLogGroups.indexOf(gId) === -1) {
+ const unfold = `<span id="${gId}_unfold" style="${logGroupStyle}">
⯈ ${gName}</span>`;
+ const fold = `<span style="display:none;"><span id="${gId}_fold"
style="${logGroupStyle}"> ⯆ ${gName}</span>`;
+ return unfold + fold;
+ }
+ const unfold = `<span id="${gId}_unfold"
style="display:none;${logGroupStyle}"> ⯈ ${gName}</span>`;
+ const fold = `<span><span id="${gId}_fold" style="${logGroupStyle}">
⯆ ${gName}</span>`;
+ return unfold + fold;
Review Comment:
There is a lot of repeated code here. We're only changing `display:none;` So
let's just have something like:
```
const isFolded = unfoldedLogGroups.indexOf(gId) === -1;
const unfoldStyle = isFolded ? '' : 'display:none;'
const foldStyle = isFolded ? 'display:none;' : '';
```
--
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]