From 947c7524688e47b8bbd9f625f3ce305a42a5658d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20=C3=85lund?= Date: Wed, 17 Jun 2020 09:54:52 +0200 Subject: [PATCH] Add Welcome msgs to catalog (#1306) * Add Welcome msgs to catalog * Fix importing of greetings * Fix broken test --- plugins/catalog/package.json | 1 + .../components/CatalogPage/CatalogLayout.tsx | 46 ++++++ .../CatalogPage/CatalogPage.test.tsx | 2 +- .../components/CatalogPage/CatalogPage.tsx | 13 +- .../utils/locales/goodAfternoon.locales.json | 134 ++++++++++++++++++ .../utils/locales/goodEvening.locales.json | 100 +++++++++++++ .../utils/locales/goodMorning.locales.json | 64 +++++++++ .../components/CatalogPage/utils/timeUtil.js | 72 ++++++++++ .../CatalogPage/utils/timeUtil.test.js | 44 ++++++ yarn.lock | 2 +- 10 files changed, 466 insertions(+), 12 deletions(-) create mode 100644 plugins/catalog/src/components/CatalogPage/CatalogLayout.tsx create mode 100644 plugins/catalog/src/components/CatalogPage/utils/locales/goodAfternoon.locales.json create mode 100644 plugins/catalog/src/components/CatalogPage/utils/locales/goodEvening.locales.json create mode 100644 plugins/catalog/src/components/CatalogPage/utils/locales/goodMorning.locales.json create mode 100644 plugins/catalog/src/components/CatalogPage/utils/timeUtil.js create mode 100644 plugins/catalog/src/components/CatalogPage/utils/timeUtil.test.js diff --git a/plugins/catalog/package.json b/plugins/catalog/package.json index eb8672bc42..d7329e4b2f 100644 --- a/plugins/catalog/package.json +++ b/plugins/catalog/package.json @@ -30,6 +30,7 @@ "@material-ui/core": "^4.9.1", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.45", + "moment": "^2.26.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-router": "^6.0.0-alpha.5", diff --git a/plugins/catalog/src/components/CatalogPage/CatalogLayout.tsx b/plugins/catalog/src/components/CatalogPage/CatalogLayout.tsx new file mode 100644 index 0000000000..9eccf81818 --- /dev/null +++ b/plugins/catalog/src/components/CatalogPage/CatalogLayout.tsx @@ -0,0 +1,46 @@ +/* + * Copyright 2020 Spotify AB + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import React, { FC } from 'react'; +import { Header, HomepageTimer, Page, pageTheme } from '@backstage/core'; +import { getTimeBasedGreeting } from './utils/timeUtil'; + +const CatalogLayout: FC<{}> = props => { + const { children } = props; + // const profile = useProfile(); + const profile = { givenName: 'friend' }; + const greeting = getTimeBasedGreeting(); + + return ( + +
+ +
+ {children} +
+ ); +}; + +export default CatalogLayout; diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx index 7601031699..2e1989323c 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.test.tsx @@ -64,7 +64,7 @@ describe('CatalogPage', () => { ), ); expect( - await rendered.findByText('Keep track of your software'), + await rendered.findByText('Backstage Service Catalog'), ).toBeInTheDocument(); }); }); diff --git a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx index c8074b1cc9..3ba63188c1 100644 --- a/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx +++ b/plugins/catalog/src/components/CatalogPage/CatalogPage.tsx @@ -19,14 +19,11 @@ import { Content, ContentHeader, DismissableBanner, - Header, HeaderTabs, - HomepageTimer, - Page, - pageTheme, SupportButton, useApi, } from '@backstage/core'; +import CatalogLayout from './CatalogLayout'; import { rootRoute as scaffolderRootRoute } from '@backstage/plugin-scaffolder'; import { Button, Link, makeStyles, Typography } from '@material-ui/core'; import Edit from '@material-ui/icons/Edit'; @@ -155,10 +152,7 @@ export const CatalogPage: FC<{}> = () => { ]; return ( - -
- -
+ = () => { } id="catalog_page_welcome_banner" /> -