From b3ea86c36220d22eb0c708503068668182ee2385 Mon Sep 17 00:00:00 2001 From: Maksim Chervonnyi Date: Fri, 18 Oct 2024 16:00:32 +0200 Subject: [PATCH 1/9] Show release version in footer --- .github/workflows/deploy-catalog.yaml | 2 +- .../Footer/{Footer.js => Footer.tsx} | 77 +++++++++++-------- .../components/Footer/{index.js => index.ts} | 0 catalog/app/components/Layout/Layout.tsx | 34 +++++++- .../{Notification.js => Notification.tsx} | 31 ++++---- catalog/app/model/graphql/schema.generated.ts | 31 ++++++++ catalog/app/model/graphql/types.generated.ts | 6 ++ catalog/app/utils/Stack.generated.ts | 35 +++++++++ catalog/app/utils/Stack.graphql | 5 ++ shared/graphql/schema.graphql | 5 ++ 10 files changed, 180 insertions(+), 46 deletions(-) rename catalog/app/components/Footer/{Footer.js => Footer.tsx} (80%) rename catalog/app/components/Footer/{index.js => index.ts} (100%) rename catalog/app/containers/Notifications/{Notification.js => Notification.tsx} (70%) create mode 100644 catalog/app/utils/Stack.generated.ts create mode 100644 catalog/app/utils/Stack.graphql diff --git a/.github/workflows/deploy-catalog.yaml b/.github/workflows/deploy-catalog.yaml index 94e31bfda51..7df1108363c 100644 --- a/.github/workflows/deploy-catalog.yaml +++ b/.github/workflows/deploy-catalog.yaml @@ -4,7 +4,7 @@ on: push: branches: - master - - selective-package-download + - stack-version paths: - '.github/workflows/deploy-catalog.yaml' - 'catalog/**' diff --git a/catalog/app/components/Footer/Footer.js b/catalog/app/components/Footer/Footer.tsx similarity index 80% rename from catalog/app/components/Footer/Footer.js rename to catalog/app/components/Footer/Footer.tsx index 28850786fa1..c5252462d8f 100644 --- a/catalog/app/components/Footer/Footer.js +++ b/catalog/app/components/Footer/Footer.tsx @@ -4,15 +4,18 @@ import * as M from '@material-ui/core' import * as Intercom from 'components/Intercom' import Logo from 'components/Logo' +import Skeleton from 'components/Skeleton' import cfg from 'constants/config' import * as style from 'constants/style' import * as URLS from 'constants/urls' import * as Notifications from 'containers/Notifications' import * as CatalogSettings from 'utils/CatalogSettings' -import HashLink from 'utils/HashLink' +import * as GQL from 'utils/GraphQL' import * as NamedRoutes from 'utils/NamedRoutes' import copyToClipboard from 'utils/clipboard' +import STACK_QUERY from 'utils/Stack.generated' + import bg from './bg.png' import iconFacebook from './icon-facebook.svg' import iconGithub from './icon-github.svg' @@ -33,45 +36,54 @@ const useVersionStyles = M.makeStyles((t) => ({ })) function Version() { + const { stack } = GQL.useQueryS(STACK_QUERY) const classes = useVersionStyles() const { push } = Notifications.use() const handleCopy = React.useCallback(() => { - copyToClipboard(process.env.REVISION_HASH) + copyToClipboard(stack.version || '') push('Web catalog container hash has been copied to clipboard') - }, [push]) + }, [push, stack.version]) return ( -
- - Revision: {process.env.REVISION_HASH.substring(0, 8)} - -
+ + Version: {stack.version} + ) } const FooterLogo = () => -const NavLink = (props) => ( - +const NavLink = (props: M.LinkProps) => ( + ) const NavSpacer = () => -const NavIcon = ({ icon, ...props }) => ( - - - -) +const useNavIconStyles = M.makeStyles({ + root: { + display: 'block', + height: '18px', + }, +}) + +interface NavIconProps extends M.BoxProps { + href: string + icon: string + target: string +} + +const NavIcon = ({ icon, ...props }: NavIconProps) => { + const classes = useNavIconStyles() + return ( + + + + ) +} const useStyles = M.makeStyles((t) => ({ root: { @@ -80,7 +92,7 @@ const useStyles = M.makeStyles((t) => ({ '0px -12px 24px 0px rgba(25, 22, 59, 0.05)', '0px -16px 40px 0px rgba(25, 22, 59, 0.07)', '0px -24px 88px 0px rgba(25, 22, 59, 0.16)', - ], + ].join(' '), height: 230, paddingTop: t.spacing(6), position: 'relative', @@ -114,6 +126,9 @@ const useStyles = M.makeStyles((t) => ({ `, }, }, + logoLink: { + display: 'block', + }, })) export default function Footer() { @@ -137,9 +152,9 @@ export default function Footer() { ) : ( - + - + )} @@ -195,7 +210,9 @@ export default function Footer() { - + }> + + diff --git a/catalog/app/components/Footer/index.js b/catalog/app/components/Footer/index.ts similarity index 100% rename from catalog/app/components/Footer/index.js rename to catalog/app/components/Footer/index.ts diff --git a/catalog/app/components/Layout/Layout.tsx b/catalog/app/components/Layout/Layout.tsx index f74da8f2b7d..8335222c4ae 100644 --- a/catalog/app/components/Layout/Layout.tsx +++ b/catalog/app/components/Layout/Layout.tsx @@ -3,10 +3,40 @@ import { useRouteMatch } from 'react-router-dom' import * as M from '@material-ui/core' import Footer from 'components/Footer' +import * as style from 'constants/style' import * as Bookmarks from 'containers/Bookmarks' import * as NavBar from 'containers/NavBar' +import { createBoundary } from 'utils/ErrorBoundary' import * as NamedRoutes from 'utils/NamedRoutes' +const useComponentErrorStyles = M.makeStyles((t) => ({ + root: { + background: t.palette.secondary.dark, + position: 'relative', + }, + container: { + color: t.palette.error.light, + padding: t.spacing(2), + }, +})) + +function ComponentError() { + const classes = useComponentErrorStyles() + return ( +
+ + Failed to render component + +
+ ) +} + +const ErrorBoundary = createBoundary(() => () => ( + + + +)) + const useRootStyles = M.makeStyles({ root: { overflowX: 'hidden', @@ -49,11 +79,11 @@ export function Layout({ bare = false, dark = false, children, pre }: LayoutProp return ( - {bare ? : } + {bare ? : } {!!pre && pre} {!!children && {children}} - {!!isHomepage && isHomepage.isExact &&