ryanahamilton commented on code in PR #42185:
URL: https://github.com/apache/airflow/pull/42185#discussion_r1755867921


##########
airflow/ui/src/app.tsx:
##########


Review Comment:
   Is there a rubric for capitalizing a tsx file or not?



##########
airflow/ui/src/layouts/NavButton.tsx:
##########
@@ -0,0 +1,48 @@
+/*!
+ * 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.
+ */
+
+import { ReactElement } from "react";
+import { Box, Button, ButtonProps, Text } from "@chakra-ui/react";
+import { Link as RouterLink } from "react-router-dom";
+
+type NavButtonProps = {
+  title?: string;
+  icon: ReactElement;
+  href?: string;
+  to?: string;
+} & ButtonProps;
+
+export const NavButton = ({ icon, title, to, ...rest }: NavButtonProps) => (
+  <Button
+    as={RouterLink}
+    to={to}
+    variant="ghost"
+    borderRadius="none"
+    height={16}
+    alignItems="center"
+    flexDir="column"
+    whiteSpace="wrap"
+    width={24}
+    transition="0.2s background-color ease-in-out"
+    {...rest}
+  >
+    <Box alignSelf="center">{icon}</Box>
+    <Text fontSize="xs">{title}</Text>

Review Comment:
   I don't think paragraph tags make sense semantically here.
   ```suggestion
       <Box fontSize="xs">{title}</Box>
   ```



##########
airflow/ui/src/app.tsx:
##########
@@ -17,19 +17,16 @@
  * under the License.
  */
 
-import { Box } from "@chakra-ui/react";
-import { DagsList } from "src/dagsList";
-import { Nav } from "src/nav";
+import { DagsList } from "src/pages/DagsList";
+import { Navigate, Route, Routes } from "react-router-dom";
+import { BaseLayout } from "./layouts/BaseLayout";
 
-export const App = () => {
-  return (
-    <div>
-      <Nav />
-      <Box p={3} ml={24}>
-        <DagsList />
-      </Box>
-    </div>
-  );
-};
-
-export const AppSimple = () => <div>Something</div>;
+// Note: When changing routes, make sure to update init_react_ui.py too
+export const App = () => (
+  <Routes>
+    <Route path="/" element={<BaseLayout />}>
+      <Route index element={<Navigate to="dags" />} />
+      <Route path="dags" element={<DagsList />} />

Review Comment:
   WDYT about just making this the index instead?
   ```suggestion
         <Route index element={<DagsList />} />
   ```



##########
airflow/ui/src/layouts/BaseLayout.tsx:
##########
@@ -0,0 +1,34 @@
+/*!
+ * 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.
+ */
+
+import { Box } from "@chakra-ui/react";
+import { Outlet } from "react-router-dom";
+
+import { Nav } from "./Nav";
+
+export const BaseLayout = () => {
+  return (
+    <div>

Review Comment:
   Does this need to be a flexbox?



##########
airflow/ui/src/layouts/Nav.tsx:
##########
@@ -94,7 +70,11 @@ export const Nav = () => {
           <Icon as={AirflowPin} height="35px" width="35px" />
         </Box>
         <NavButton title="Home" icon={<FiHome size="1.75rem" />} isDisabled />
-        <NavButton title="DAGs" icon={<DagIcon height={7} width={7} />} />
+        <NavButton
+          title="DAGs"
+          to="dags"
+          icon={<DagIcon height={7} width={7} />}
+        />

Review Comment:
   Maybe not in this PR, but it would be nice to put the navItems in an array 
and then just map on this component.



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