pierrejeambrun commented on code in PR #43324:
URL: https://github.com/apache/airflow/pull/43324#discussion_r1814581620
##########
airflow/ui/src/pages/DagsList/DagCard.tsx:
##########
@@ -41,14 +42,20 @@ type Props = {
const MAX_TAGS = 3;
export const DagCard = ({ dag }: Props) => {
+ const navigate = useNavigate();
const cardBorder = useColorModeValue("gray.100", "gray.700");
const tooltipBg = useColorModeValue("gray.200", "gray.700");
return (
<Box
+ _hover={{
+ borderColor: "subtle-text",
+ cursor: "pointer",
+ }}
Review Comment:
I think we should avoid this. I know that alternatives are no straigh
forward, but in the same way as we do for the table row, making `<tr>` and
`<div>` clickable is not great for accessibility I believe. Can't use tab to go
on that, or press 'enter' to click, screenreader will have a hard time with
such pattern.
##########
airflow/ui/src/pages/Error.tsx:
##########
@@ -0,0 +1,96 @@
+/*!
+ * 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,
+ VStack,
+ Heading,
+ Text,
+ Button,
+ Container,
+ HStack,
+ Code,
+ Icon,
+} from "@chakra-ui/react";
+import {
+ useNavigate,
+ useRouteError,
+ isRouteErrorResponse,
+} from "react-router-dom";
+
+import { AirflowPin } from "src/assets/AirflowPin";
+
+export const ErrorPage = () => {
+ const navigate = useNavigate();
+ const error = useRouteError();
+
+ let errorMessage = "An unexpected error occurred";
+ let statusCode = "";
+
+ if (isRouteErrorResponse(error)) {
+ statusCode = String(error.status);
+ errorMessage =
+ ((error as unknown as Error).message ||
+ (error as { statusText?: string }).statusText) ??
+ "Page Not Found";
+ } else if (error instanceof Error) {
+ errorMessage = error.message;
+ } else if (typeof error === "string") {
+ errorMessage = error;
+ }
+
+ return (
+ <Box
+ alignItems="center"
+ display="flex"
+ justifyContent="center"
+ pt={36}
+ px={4}
+ >
+ <Container maxW="lg">
+ <VStack spacing={8} textAlign="center">
+ <Icon as={AirflowPin} height="50px" width="50px" />
+
+ <VStack spacing={4}>
+ <Heading>{statusCode || "Error"}</Heading>
+ <Text fontSize="lg">{errorMessage}</Text>
+ {error instanceof Error && (
+ <Code borderRadius="md" fontSize="sm" p={3} width="full">
+ {error.stack}
+ </Code>
Review Comment:
I think this should be displayed only in 'dev' mode. In production we don't
want this I would say.
##########
airflow/ui/src/pages/DagsList/DagsList.tsx:
##########
@@ -118,9 +118,24 @@ const cardDef: CardDef<DAGResponse> = {
},
};
+const DAGS_LIST_DISPLAY = "dags_list_display";
+
export const DagsList = () => {
const [searchParams, setSearchParams] = useSearchParams();
- const [display, setDisplay] = useState<"card" | "table">("card");
+ const [display, setDisplay] = useState<"card" | "table">(() => {
+ const storage = localStorage.getItem(DAGS_LIST_DISPLAY);
+
+ if (storage === "card" || storage === "table") {
+ return storage;
+ }
+
+ return "card";
+ });
Review Comment:
Maybe we should extract that to a service class, or some utility custom hook
with some kind of `useReducer` in it.
The idea is to avoid to have each components interacting with the storage in
their own way. (types, names, etc...) Only 1 class / utility code should do
that and guarantee its integrity, having the storage full typing. Will also
limit having storage code all over the place.
--
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]