pierrejeambrun commented on code in PR #55604:
URL: https://github.com/apache/airflow/pull/55604#discussion_r2369419299
##########
airflow-core/src/airflow/ui/src/components/LimitedItemsList.tsx:
##########
@@ -16,28 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/
-import { Box, Text, HStack, StackSeparator } from "@chakra-ui/react";
+import { Box, Text, HStack, useDisclosure, Heading, Stack, StackSeparator }
from "@chakra-ui/react";
import React, { type ReactNode } from "react";
import { useTranslation } from "react-i18next";
-import { Tooltip } from "./ui";
+import { Tooltip, Dialog, Button } from "./ui";
type ListProps = {
readonly icon?: ReactNode;
readonly interactive?: boolean;
readonly items: Array<ReactNode | string>;
readonly maxItems?: number;
+ readonly modalTitle?: string;
readonly separator?: string;
+ readonly showModal?: boolean;
};
export const LimitedItemsList = ({
icon,
interactive = false,
items,
maxItems,
+ modalTitle = "All Items",
Review Comment:
That can't be hardcoded in ensligh, it should be a translation key, and use
translations
##########
airflow-core/src/airflow/ui/src/components/LimitedItemsList.tsx:
##########
@@ -52,31 +57,101 @@ export const LimitedItemsList = ({
}
return (
- <HStack align="center" gap={1}>
- {icon}
- <Box fontSize="sm">
- {displayItems.map((item, index) => (
- // eslint-disable-next-line react/no-array-index-key
- <React.Fragment key={index}>
- <Text as="span">{item}</Text>
- {index < displayItems.length - 1 ||
- (shouldTruncate && remainingItems.length >= 1 && index ===
displayItems.length - 1) ? (
- <Text as="span">{separator}</Text>
- ) : undefined}
- </React.Fragment>
- ))}
- {shouldTruncate ? (
- remainingItems.length === 1 ? (
- <Text as="span">{remainingItems[0]}</Text>
- ) : (
- <Tooltip content={remainingItemsList} interactive={interactive}>
- <Text as="span" cursor="help">
+ <>
+ <HStack align="center" gap={1}>
+ {icon}
+ <Box fontSize="sm">
+ {displayItems.map((item, index) => (
+ // eslint-disable-next-line react/no-array-index-key
+ <React.Fragment key={index}>
+ <Text as="span">{item}</Text>
+ {index < displayItems.length - 1 ||
+ (shouldTruncate && remainingItems.length >= 1 && index ===
displayItems.length - 1) ? (
+ <Text as="span">{separator}</Text>
+ ) : undefined}
+ </React.Fragment>
+ ))}
+ {shouldTruncate ? (
+ remainingItems.length === 1 ? (
+ <Text as="span">{remainingItems[0]}</Text>
+ ) : showModal ? (
+ <Button
+ _hover={{ color: "blue.600", textDecoration: "underline" }}
+ color="blue.500"
+ cursor="pointer"
+ fontSize="sm"
+ minH="auto"
+ onClick={onOpen}
+ px={1}
+ py={0}
+ size="xs"
+ variant="ghost"
+ >
{translate("limitedList", { count: remainingItems.length })}
- </Text>
- </Tooltip>
- )
- ) : undefined}
- </Box>
- </HStack>
+ </Button>
+ ) : (
+ <Tooltip content={remainingItemsList} interactive={interactive}>
+ <Text as="span" cursor="help">
+ {translate("limitedList", { count: remainingItems.length })}
+ </Text>
+ </Tooltip>
+ )
+ ) : undefined}
+ </Box>
+ </HStack>
+
+ {/* Modal for showing all items */}
+ {showModal ? (
+ <Dialog.Root onOpenChange={onClose} open={open} size="xl">
+ <Dialog.Content backdrop>
+ <Dialog.Header>
+ <Heading size="lg">{modalTitle}</Heading>
+ </Dialog.Header>
+
+ <Dialog.CloseTrigger />
+
+ <Dialog.Body>
+ <Box>
+ <Text color="gray.600" fontSize="sm" mb={3}>
+ {translate("limitedList.showingItems", { count: items.length
})}
+ </Text>
+
+ <Box
+ bg="bg.subtle"
+ border="1px solid"
+ borderColor="border.subtle"
+ borderRadius="md"
+ maxH="400px"
+ overflowY="auto"
+ p={3}
+ >
+ {interactive ? (
+ <HStack flexWrap="wrap" gap={2}>
+ {items.map((item, index) => (
+ <Box key={typeof item === "string" ? item :
index}>{item}</Box>
Review Comment:
We probably need some separator there, a tag can contain empty spaces.
--
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]