From cdea1674674a5eafda17e019b1752513156e61c1 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:51:22 +0100 Subject: [PATCH] adding ExpandableListItem.tsx --- public/locales/de-DE/translation.json | 5 + public/locales/en-US/translation.json | 5 + src/components/ExpandableListItem.tsx | 38 +++++ src/components/LanguageButton.tsx | 2 - src/components/index.ts | 2 + .../AliasesRoute/AliasesListItem.tsx | 10 +- .../ExpandedUrlsListItem.tsx | 43 +++++ .../ProxiedImagesListItem.tsx | 147 ++++++++---------- .../SinglePixelImageTrackersListItem.tsx | 70 +++------ src/routes/AuthenticatedRoute.tsx | 4 +- src/routes/ReportDetailRoute.tsx | 7 + src/server-types.ts | 3 +- 12 files changed, 189 insertions(+), 147 deletions(-) create mode 100644 src/components/ExpandableListItem.tsx create mode 100644 src/route-widgets/ReportDetailRoute/ExpandedUrlsListItem.tsx diff --git a/public/locales/de-DE/translation.json b/public/locales/de-DE/translation.json index 219de9f..5b97c6a 100644 --- a/public/locales/de-DE/translation.json +++ b/public/locales/de-DE/translation.json @@ -231,6 +231,11 @@ "isStored": "Auf Server gespeichert", "isProxying": "Wird weitergeleitet" } + }, + "expandedUrls": { + "text_zero": "Keine gekürzten URLs gefunden", + "text_one": "Eine URL entkürzt", + "text_other": "{{count}} URLs entkürzt" } } } diff --git a/public/locales/en-US/translation.json b/public/locales/en-US/translation.json index d6fcc4b..871fcf5 100644 --- a/public/locales/en-US/translation.json +++ b/public/locales/en-US/translation.json @@ -231,6 +231,11 @@ "isStored": "Stored on Server", "isProxying": "Being forwarded" } + }, + "expandedUrls": { + "text_zero": "No shortened URLs found", + "text_one": "Expanded 1 URL", + "text_other": "Expanded {{count}} URLs" } } } diff --git a/src/components/ExpandableListItem.tsx b/src/components/ExpandableListItem.tsx new file mode 100644 index 0000000..c0afd83 --- /dev/null +++ b/src/components/ExpandableListItem.tsx @@ -0,0 +1,38 @@ +import {ReactElement, ReactNode, useState} from "react" + +import {Box, Collapse, ListItemButton, ListItemIcon, ListItemText, useTheme} from "@mui/material" + +export interface ExpandedUrlsListItemProps { + data: T[] + icon: ReactElement + title: string + children: ReactNode +} + +export default function ExpandedUrlsListItem({ + data, + children, + icon, + title, +}: ExpandedUrlsListItemProps): ReactElement { + const [isExpanded, setIsExpanded] = useState(false) + const theme = useTheme() + + return ( + <> + { + if (data.length > 0) { + setIsExpanded(value => !value) + } + }} + > + {icon} + {title} + + + {children} + + + ) +} diff --git a/src/components/LanguageButton.tsx b/src/components/LanguageButton.tsx index d723f40..3c7a763 100644 --- a/src/components/LanguageButton.tsx +++ b/src/components/LanguageButton.tsx @@ -22,8 +22,6 @@ export default function LanguageButton(): ReactElement { const {isLocked, showDialog} = useContext(LockNavigationContext) const {i18n} = useTranslation() - console.log(i18n.resolvedLanguage, SORTED_ENTRIES) - return (