From ec7fce2d41f94e0ff2c958ae575c30da4e8a84e8 Mon Sep 17 00:00:00 2001 From: Renan Mendes Carvalho Date: Wed, 16 Aug 2023 10:52:29 +0200 Subject: [PATCH] feature(home-plugin): Bootstrap skeleton. Signed-off-by: Renan Mendes Carvalho --- .../RecentlyVisited/Content.tsx | 24 +++++++++++++ .../RecentlyVisited.stories.tsx | 36 +++++++++++++++++++ .../RecentlyVisited/RecentlyVisited.test.tsx | 26 ++++++++++++++ .../RecentlyVisited/RecentlyVisited.tsx | 24 +++++++++++++ .../RecentlyVisited/index.ts | 17 +++++++++ plugins/home/src/plugin.ts | 11 ++++++ 6 files changed, 138 insertions(+) create mode 100644 plugins/home/src/homePageComponents/RecentlyVisited/Content.tsx create mode 100644 plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.stories.tsx create mode 100644 plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.test.tsx create mode 100644 plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.tsx create mode 100644 plugins/home/src/homePageComponents/RecentlyVisited/index.ts diff --git a/plugins/home/src/homePageComponents/RecentlyVisited/Content.tsx b/plugins/home/src/homePageComponents/RecentlyVisited/Content.tsx new file mode 100644 index 0000000000..4d06751e22 --- /dev/null +++ b/plugins/home/src/homePageComponents/RecentlyVisited/Content.tsx @@ -0,0 +1,24 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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 from 'react'; +import { RecentlyVisited } from './RecentlyVisited'; + +/** + * Display recently visited pages for the homepage + * @public + */ +export const Content = () => ; diff --git a/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.stories.tsx b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.stories.tsx new file mode 100644 index 0000000000..bb04a1ebc7 --- /dev/null +++ b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.stories.tsx @@ -0,0 +1,36 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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 from 'react'; +import { wrapInTestApp } from '@backstage/test-utils'; +import { ComponentType, PropsWithChildren } from 'react'; +import { Grid } from '@material-ui/core'; +import { HomePageRecentlyVisited } from '../../plugin'; + +export default { + title: 'Plugins/Home/Components/RecentlyVisited', + decorators: [ + (Story: ComponentType>) => wrapInTestApp(), + ], +}; + +export const Default = () => { + return ( + + + + ); +}; diff --git a/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.test.tsx b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.test.tsx new file mode 100644 index 0000000000..5ccab63fa8 --- /dev/null +++ b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.test.tsx @@ -0,0 +1,26 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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 from 'react'; +import { RecentlyVisited } from './RecentlyVisited'; +import { renderInTestApp } from '@backstage/test-utils'; + +describe('', () => { + it('should render', async () => { + const { getByText } = await renderInTestApp(); + expect(getByText('RecentlyVisited')).toBeInTheDocument(); + }); +}); diff --git a/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.tsx b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.tsx new file mode 100644 index 0000000000..6f2abe3b60 --- /dev/null +++ b/plugins/home/src/homePageComponents/RecentlyVisited/RecentlyVisited.tsx @@ -0,0 +1,24 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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 from 'react'; +import Typography from '@material-ui/core/Typography'; + +/** + * Display recently visited pages for the homepage + * @public + */ +export const RecentlyVisited = () => RecentlyVisited; diff --git a/plugins/home/src/homePageComponents/RecentlyVisited/index.ts b/plugins/home/src/homePageComponents/RecentlyVisited/index.ts new file mode 100644 index 0000000000..f1cdf3734f --- /dev/null +++ b/plugins/home/src/homePageComponents/RecentlyVisited/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 The Backstage Authors + * + * 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. + */ + +export { Content } from './Content'; diff --git a/plugins/home/src/plugin.ts b/plugins/home/src/plugin.ts index 74a1c11390..20cfddc724 100644 --- a/plugins/home/src/plugin.ts +++ b/plugins/home/src/plugin.ts @@ -172,3 +172,14 @@ export const HeaderWorldClock = homePlugin.provide( }, }), ); + +/** + * Display recently visited pages for the homepage + * @public + */ +export const HomePageRecentlyVisited = homePlugin.provide( + createCardExtension({ + name: 'HomePageRecentlyVisited', + components: () => import('./homePageComponents/RecentlyVisited'), + }), +);