Skip to content

Commit

Permalink
revert ErrorBoundary and GQL changes; use config for getting stackVer…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
fiskus committed Nov 4, 2024
1 parent b3ea86c commit 904fefe
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 121 deletions.
10 changes: 3 additions & 7 deletions catalog/app/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ 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 * 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'
Expand All @@ -36,21 +33,20 @@ 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(stack.version || '')
copyToClipboard(cfg.stackVersion || '')
push('Web catalog container hash has been copied to clipboard')
}, [push, stack.version])
}, [push])
return (
<M.Typography
className={classes.revision}
onClick={handleCopy}
title="Copy product revision hash to clipboard"
variant="caption"
>
Version: {stack.version}
Version: {cfg.stackVersion}
</M.Typography>
)
}
Expand Down
34 changes: 2 additions & 32 deletions catalog/app/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,10 @@ 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 (
<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(() => () => (
<M.MuiThemeProvider theme={style.navTheme}>
<ComponentError />
</M.MuiThemeProvider>
))

const useRootStyles = M.makeStyles({
root: {
overflowX: 'hidden',
Expand Down Expand Up @@ -79,11 +49,11 @@ export function Layout({ bare = false, dark = false, children, pre }: LayoutProp
return (
<Root dark={dark}>
<NavBar.Provider>
<ErrorBoundary>{bare ? <NavBar.Container /> : <NavBar.NavBar />}</ErrorBoundary>
{bare ? <NavBar.Container /> : <NavBar.NavBar />}
{!!pre && pre}
{!!children && <M.Box p={4}>{children}</M.Box>}
<M.Box flexGrow={1} />
<ErrorBoundary>{!!isHomepage && isHomepage.isExact && <Footer />}</ErrorBoundary>
{isHomepage?.isExact && <Footer />}
{bookmarks && <Bookmarks.Sidebar bookmarks={bookmarks} bucket={bucket} />}
</NavBar.Provider>
</Root>
Expand Down
31 changes: 0 additions & 31 deletions catalog/app/model/graphql/schema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4176,18 +4176,6 @@ export default {
},
],
},
{
name: 'stack',
type: {
kind: 'NON_NULL',
ofType: {
kind: 'OBJECT',
name: 'Stack',
ofType: null,
},
},
args: [],
},
{
name: 'subscription',
type: {
Expand Down Expand Up @@ -5027,25 +5015,6 @@ 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: 0 additions & 6 deletions catalog/app/model/graphql/types.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,6 @@ 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 @@ -1079,11 +1078,6 @@ 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
1 change: 1 addition & 0 deletions catalog/app/utils/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface ConfigJson {
qurator?: boolean

build_version?: string // not sure where this comes from
stackVersion?: string // FIXME: Make required
}

const ajv = new Ajv({ allErrors: true, removeAdditional: true })
Expand Down
35 changes: 0 additions & 35 deletions catalog/app/utils/Stack.generated.ts

This file was deleted.

5 changes: 0 additions & 5 deletions catalog/app/utils/Stack.graphql

This file was deleted.

4 changes: 4 additions & 0 deletions catalog/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
"qurator": {
"type": "boolean",
"description": "Enable Qurator AI Assistant (powered by Amazon Bedrock)"
},
"stack_version": {
"type": "string",
"description": "Stack release version, uses semver"
}
},
"required": [
Expand Down
5 changes: 0 additions & 5 deletions shared/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,6 @@ type Me {

union SwitchRoleResult = Me | InvalidInput | OperationError

type Stack {
version: String!
}

type Query {
me: Me

Expand All @@ -558,7 +554,6 @@ 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 904fefe

Please sign in to comment.