bbovenzi commented on code in PR #23487:
URL: https://github.com/apache/airflow/pull/23487#discussion_r865900354


##########
airflow/www/static/js/grid/ToggleGroups.jsx:
##########
@@ -0,0 +1,82 @@
+/*!
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* global localStorage, CustomEvent, document */
+
+import React, { useState } from 'react';
+import { Button } from '@chakra-ui/react';
+
+import { getMetaValue } from '../utils';
+
+const dagId = getMetaValue('dag_id');
+
+const getGroupIds = (groups) => {
+  const groupIds = [];
+  const checkTasks = (tasks) => tasks.forEach((task) => {
+    if (task.children) {
+      groupIds.push(task.label);
+      checkTasks(task.children);
+    }
+  });
+  checkTasks(groups);
+  return groupIds;
+};
+
+const ToggleGroups = ({ groups }) => {
+  const storageKey = `${dagId}-open-groups`;
+  const allGroupIds = getGroupIds(groups.children);
+  const openGroupIds = JSON.parse(localStorage.getItem(storageKey)) || [];
+
+  // Default to expand all if at least one group is closed
+  const [shouldExpand, setShouldExpand] = useState(allGroupIds.length > 
openGroupIds.length);

Review Comment:
   @argibbs  Right now, the default is to show "Expand all" if even one group 
is closed.
   
   We could also do 2 buttons, but icon-only to avoid cluttering up the screen:
   <img width="357" alt="Screen Shot 2022-05-05 at 9 21 45 AM" 
src="https://user-images.githubusercontent.com/4600967/166931982-70c32f0b-8083-4d0e-b54d-7062be47090b.png";>
   
   



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