Skip to content

Commit

Permalink
Show release version in footer
Browse files Browse the repository at this point in the history
  • Loading branch information
fiskus committed Oct 22, 2024
1 parent dc68d84 commit b3ea86c
Show file tree
Hide file tree
Showing 10 changed files with 180 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-catalog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
- selective-package-download
- stack-version
paths:
- '.github/workflows/deploy-catalog.yaml'
- 'catalog/**'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Check warning on line 7 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L7

Added line #L7 was not covered by tests
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'

Check warning on line 13 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L13

Added line #L13 was not covered by tests
import * as NamedRoutes from 'utils/NamedRoutes'
import copyToClipboard from 'utils/clipboard'

import STACK_QUERY from 'utils/Stack.generated'

Check warning on line 17 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L17

Added line #L17 was not covered by tests

import bg from './bg.png'
import iconFacebook from './icon-facebook.svg'
import iconGithub from './icon-github.svg'
Expand All @@ -33,45 +36,54 @@ const useVersionStyles = M.makeStyles((t) => ({
}))

function Version() {
const { stack } = GQL.useQueryS(STACK_QUERY)

Check warning on line 39 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L39

Added line #L39 was not covered by tests
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 (
<div>
<M.Typography
className={classes.revision}
onClick={handleCopy}
title="Copy product revision hash to clipboard"
variant="caption"
>
Revision: {process.env.REVISION_HASH.substring(0, 8)}
</M.Typography>
</div>
<M.Typography
className={classes.revision}
onClick={handleCopy}
title="Copy product revision hash to clipboard"
variant="caption"
>
Version: {stack.version}
</M.Typography>
)
}

const FooterLogo = () => <Logo height="29px" width="76.5px" />

const NavLink = (props) => (
<M.Link
variant="button"
underline="none"
color="textPrimary"
component={props.to ? HashLink : undefined}
{...props}
/>
const NavLink = (props: M.LinkProps) => (

Check warning on line 60 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L60

Added line #L60 was not covered by tests
<M.Link variant="button" underline="none" color="textPrimary" {...props} />
)

const NavSpacer = () => <M.Box ml={{ xs: 2, sm: 3 }} />

const NavIcon = ({ icon, ...props }) => (
<M.Box component="a" {...props}>
<M.Box component="img" height={18} src={icon} alt="" display="block" />
</M.Box>
)
const useNavIconStyles = M.makeStyles({

Check warning on line 66 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L66

Added line #L66 was not covered by tests
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 (

Check warning on line 81 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L79-L81

Added lines #L79 - L81 were not covered by tests
<M.Box component="a" {...props}>
<img className={classes.root} src={icon} alt="" />
</M.Box>
)
}

const useStyles = M.makeStyles((t) => ({
root: {
Expand All @@ -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',
Expand Down Expand Up @@ -114,6 +126,9 @@ const useStyles = M.makeStyles((t) => ({
`,
},
},
logoLink: {
display: 'block',
},
}))

export default function Footer() {
Expand All @@ -137,9 +152,9 @@ export default function Footer() {
<FooterLogo />
</a>
) : (
<M.Box component={Link} to={urls.home()} display="block">
<Link className={classes.logoLink} to={urls.home()}>

Check warning on line 155 in catalog/app/components/Footer/Footer.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Footer/Footer.tsx#L155

Added line #L155 was not covered by tests
<FooterLogo />
</M.Box>
</Link>
)}
</M.Box>

Expand Down Expand Up @@ -195,7 +210,9 @@ export default function Footer() {
</M.Box>
</M.Container>
<M.Container maxWidth="lg">
<Version />
<React.Suspense fallback={<Skeleton width={80} height={14} />}>
<Version />
</React.Suspense>
</M.Container>
</footer>
</M.MuiThemeProvider>
Expand Down
File renamed without changes.
34 changes: 32 additions & 2 deletions catalog/app/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Check warning on line 6 in catalog/app/components/Layout/Layout.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Layout/Layout.tsx#L6

Added line #L6 was not covered by tests
import * as Bookmarks from 'containers/Bookmarks'
import * as NavBar from 'containers/NavBar'
import { createBoundary } from 'utils/ErrorBoundary'

Check warning on line 9 in catalog/app/components/Layout/Layout.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Layout/Layout.tsx#L9

Added line #L9 was not covered by tests
import * as NamedRoutes from 'utils/NamedRoutes'

const useComponentErrorStyles = M.makeStyles((t) => ({

Check warning on line 12 in catalog/app/components/Layout/Layout.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Layout/Layout.tsx#L12

Added line #L12 was not covered by tests
root: {
background: t.palette.secondary.dark,
position: 'relative',
},
container: {
color: t.palette.error.light,
padding: t.spacing(2),
},
}))

function ComponentError() {
const classes = useComponentErrorStyles()
return (

Check warning on line 25 in catalog/app/components/Layout/Layout.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Layout/Layout.tsx#L23-L25

Added lines #L23 - L25 were not covered by tests
<div className={classes.root}>
<M.Container maxWidth="lg" className={classes.container}>
<M.Typography>Failed to render component</M.Typography>
</M.Container>
</div>
)
}

const ErrorBoundary = createBoundary(() => () => (

Check warning on line 34 in catalog/app/components/Layout/Layout.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/components/Layout/Layout.tsx#L34

Added line #L34 was not covered by tests
<M.MuiThemeProvider theme={style.navTheme}>
<ComponentError />
</M.MuiThemeProvider>
))

const useRootStyles = M.makeStyles({
root: {
overflowX: 'hidden',
Expand Down Expand Up @@ -49,11 +79,11 @@ export function Layout({ bare = false, dark = false, children, pre }: LayoutProp
return (
<Root dark={dark}>
<NavBar.Provider>
{bare ? <NavBar.Container /> : <NavBar.NavBar />}
<ErrorBoundary>{bare ? <NavBar.Container /> : <NavBar.NavBar />}</ErrorBoundary>
{!!pre && pre}
{!!children && <M.Box p={4}>{children}</M.Box>}
<M.Box flexGrow={1} />
{!!isHomepage && isHomepage.isExact && <Footer />}
<ErrorBoundary>{!!isHomepage && isHomepage.isExact && <Footer />}</ErrorBoundary>
{bookmarks && <Bookmarks.Sidebar bookmarks={bookmarks} bucket={bucket} />}
</NavBar.Provider>
</Root>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PT from 'prop-types'
import React from 'react'
import * as M from '@material-ui/core'

Expand All @@ -8,7 +7,24 @@ const useStyles = M.makeStyles((t) => ({
},
}))

export default function Notification({ id, ttl, message, action, dismiss }) {
interface NotificationProps {
id: string
ttl?: number | null
message: React.ReactNode
action: {
onClick: () => void
label: React.ReactNode
}
dismiss: (id: string) => void
}

export default function Notification({
id,
ttl,
message,
action,
dismiss,
}: NotificationProps) {

Check warning on line 27 in catalog/app/containers/Notifications/Notification.tsx

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/containers/Notifications/Notification.tsx#L21-L27

Added lines #L21 - L27 were not covered by tests
const classes = useStyles()

const handleClose = React.useCallback(() => dismiss(id), [dismiss, id])
Expand Down Expand Up @@ -40,14 +56,3 @@ export default function Notification({ id, ttl, message, action, dismiss }) {
/>
)
}

Notification.propTypes = {
id: PT.string.isRequired,
ttl: PT.oneOf([null, PT.number.isRequired]),
message: PT.node.isRequired,
action: PT.shape({
label: PT.string.isRequired,
onClick: PT.func.isRequired,
}),
dismiss: PT.func.isRequired,
}
31 changes: 31 additions & 0 deletions catalog/app/model/graphql/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4176,6 +4176,18 @@ export default {
},
],
},
{
name: 'stack',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'OBJECT',
name: 'Stack',
ofType: null,
},
},
args: [],
},
{
name: 'subscription',
type: {
Expand Down Expand Up @@ -5015,6 +5027,25 @@ export default {
],
interfaces: [],
},
{
kind: 'OBJECT',
name: 'Stack',
fields: [
{
name: 'version',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'SCALAR',
name: 'String',
ofType: null,
},
},
args: [],
},
],
interfaces: [],
},
{
kind: 'OBJECT',
name: 'Status',
Expand Down
6 changes: 6 additions & 0 deletions catalog/app/model/graphql/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ export interface Query {
readonly searchPackages: PackagesSearchResult
readonly searchMoreObjects: ObjectsSearchMoreResult
readonly searchMorePackages: PackagesSearchMoreResult
readonly stack: Stack
readonly subscription: SubscriptionState
readonly admin: AdminQueries
readonly policies: ReadonlyArray<Policy>
Expand Down Expand Up @@ -1078,6 +1079,11 @@ export interface SsoConfigConflict {
readonly _: Maybe<Scalars['Boolean']>
}

export interface Stack {
readonly __typename: 'Stack'
readonly version: Scalars['String']
}

export interface Status {
readonly __typename: 'Status'
readonly canaries: ReadonlyArray<Canary>
Expand Down
35 changes: 35 additions & 0 deletions catalog/app/utils/Stack.generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable @typescript-eslint/naming-convention */
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core'
import * as Types from '../model/graphql/types.generated'

export type utils_StackQueryVariables = Types.Exact<{ [key: string]: never }>

export type utils_StackQuery = { readonly __typename: 'Query' } & {
readonly stack: { readonly __typename: 'Stack' } & Pick<Types.Stack, 'version'>
}

export const utils_StackDocument = {

Check warning on line 11 in catalog/app/utils/Stack.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/utils/Stack.generated.ts#L11

Added line #L11 was not covered by tests
kind: 'Document',
definitions: [
{
kind: 'OperationDefinition',
operation: 'query',
name: { kind: 'Name', value: 'utils_Stack' },
selectionSet: {
kind: 'SelectionSet',
selections: [
{
kind: 'Field',
name: { kind: 'Name', value: 'stack' },
selectionSet: {
kind: 'SelectionSet',
selections: [{ kind: 'Field', name: { kind: 'Name', value: 'version' } }],
},
},
],
},
},
],
} as unknown as DocumentNode<utils_StackQuery, utils_StackQueryVariables>

export { utils_StackDocument as default }

Check warning on line 35 in catalog/app/utils/Stack.generated.ts

View check run for this annotation

Codecov / codecov/patch/informational

catalog/app/utils/Stack.generated.ts#L35

Added line #L35 was not covered by tests
5 changes: 5 additions & 0 deletions catalog/app/utils/Stack.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query {
stack {
version
}
}
5 changes: 5 additions & 0 deletions shared/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,10 @@ type Me {

union SwitchRoleResult = Me | InvalidInput | OperationError

type Stack {
version: String!
}

type Query {
me: Me

Expand All @@ -554,6 +558,7 @@ type Query {
): PackagesSearchResult!
searchMoreObjects(after: String!, size: Int = 30): ObjectsSearchMoreResult!
searchMorePackages(after: String!, size: Int = 30): PackagesSearchMoreResult!
stack: Stack!
subscription: SubscriptionState!

admin: AdminQueries! @admin
Expand Down

0 comments on commit b3ea86c

Please sign in to comment.