guan404ming commented on code in PR #51146:
URL: https://github.com/apache/airflow/pull/51146#discussion_r2157637990


##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -95,40 +94,72 @@ const parseLogs = ({
     return { data, warning };
   }
 
-  // TODO: Add support for nested groups
-
-  parsedLines = parsedLines.map((line) => {
-    const text = innerText(line);
-
-    if (text.includes("::group::") && !startGroup) {
-      startGroup = true;
-      groupName = text.split("::group::")[1] as string;
-    } else if (text.includes("::endgroup::")) {
-      startGroup = false;
-      const group = (
-        <details key={groupName} open={open} style={{ width: "100%" }}>
-          <summary data-testid={`summary-${groupName}`}>
-            <chakra.span color="fg.info" cursor="pointer">
-              {groupName}
-            </chakra.span>
-          </summary>
-          {groupLines}
-        </details>
-      );
-
-      groupLines = [];
-
-      return group;
-    }
+  parsedLines = (() => {
+    type Group = { level: number; lines: Array<JSX.Element | "">; name: string 
};
+    const groupStack: Array<Group> = [];
+    const result: Array<JSX.Element | ""> = [];
+
+    parsedLines.forEach((line) => {
+      const text = innerText(line);
+
+      if (text.includes("::group::")) {
+        const groupName = text.split("::group::")[1] as string;
+
+        groupStack.push({ level: groupStack.length, lines: [], name: groupName 
});
+
+        return;
+      }
 
-    if (startGroup) {
-      groupLines.push(line);
+      if (text.includes("::endgroup::")) {
+        const finishedGroup = groupStack.pop();
+
+        if (finishedGroup) {
+          const groupElement = (
+            <Box key={finishedGroup.name} mb={2} pl={finishedGroup.level * 2}>
+              <details open={open} style={{ width: "100%" }}>

Review Comment:
   ```suggestion
                 <chakra.details open={open} w="100%">
   ```
   
   to use [chakra factory](https://chakra-ui.com/docs/styling/chakra-factory) 
could preserve consistency and get better support for RTL lang



##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -95,40 +94,72 @@ const parseLogs = ({
     return { data, warning };
   }
 
-  // TODO: Add support for nested groups
-
-  parsedLines = parsedLines.map((line) => {
-    const text = innerText(line);
-
-    if (text.includes("::group::") && !startGroup) {
-      startGroup = true;
-      groupName = text.split("::group::")[1] as string;
-    } else if (text.includes("::endgroup::")) {
-      startGroup = false;
-      const group = (
-        <details key={groupName} open={open} style={{ width: "100%" }}>
-          <summary data-testid={`summary-${groupName}`}>
-            <chakra.span color="fg.info" cursor="pointer">
-              {groupName}
-            </chakra.span>
-          </summary>
-          {groupLines}
-        </details>
-      );
-
-      groupLines = [];
-
-      return group;
-    }
+  parsedLines = (() => {
+    type Group = { level: number; lines: Array<JSX.Element | "">; name: string 
};
+    const groupStack: Array<Group> = [];
+    const result: Array<JSX.Element | ""> = [];
+
+    parsedLines.forEach((line) => {
+      const text = innerText(line);
+
+      if (text.includes("::group::")) {
+        const groupName = text.split("::group::")[1] as string;
+
+        groupStack.push({ level: groupStack.length, lines: [], name: groupName 
});
+
+        return;
+      }
 
-    if (startGroup) {
-      groupLines.push(line);
+      if (text.includes("::endgroup::")) {
+        const finishedGroup = groupStack.pop();
+
+        if (finishedGroup) {
+          const groupElement = (
+            <Box key={finishedGroup.name} mb={2} pl={finishedGroup.level * 2}>
+              <details open={open} style={{ width: "100%" }}>
+                <summary data-testid={`summary-${finishedGroup.name}`}>

Review Comment:
   ```suggestion
                   <chakra.summary 
data-testid={`summary-${finishedGroup.name}`}>
   ```
   same as above



-- 
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]

Reply via email to