2
* Copyright 2021 The Backstage Authors
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
19
createComponentExtension,
21
createRoutableExtension,
24
} from '@backstage/core-plugin-api';
25
import { createCardExtension } from '@backstage/plugin-home-react';
29
FeaturedDocsCardProps,
30
} from './homePageComponents';
31
import { rootRouteRef } from './routes';
32
import { VisitsStorageApi, visitsApiRef } from './api';
33
import { StarredEntitiesProps } from './homePageComponents/StarredEntities/Content';
36
export const homePlugin = createPlugin({
42
storageApi: storageApiRef,
43
identityApi: identityApiRef,
45
factory: ({ storageApi, identityApi }) =>
46
VisitsStorageApi.create({ storageApi, identityApi }),
55
export const HomepageCompositionRoot = homePlugin.provide(
56
createRoutableExtension({
57
name: 'HomepageCompositionRoot',
59
import('./components').then(m => m.HomepageCompositionRoot),
60
mountPoint: rootRouteRef,
65
export const ComponentAccordion = homePlugin.provide(
66
createComponentExtension({
67
name: 'ComponentAccordion',
70
import('./componentRenderers').then(m => m.ComponentAccordion),
76
export const ComponentTabs = homePlugin.provide(
77
createComponentExtension({
78
name: 'ComponentTabs',
80
lazy: () => import('./componentRenderers').then(m => m.ComponentTabs),
86
export const ComponentTab = homePlugin.provide(
87
createComponentExtension({
90
lazy: () => import('./componentRenderers').then(m => m.ComponentTab),
96
* A component to display a playful greeting for the user.
100
export const WelcomeTitle = homePlugin.provide(
101
createComponentExtension({
102
name: 'WelcomeTitle',
105
import('./homePageComponents/WelcomeTitle').then(m => m.WelcomeTitle),
111
* A component to display a company logo for the user.
115
export const HomePageCompanyLogo = homePlugin.provide(
116
createComponentExtension({
120
import('./homePageComponents/CompanyLogo').then(m => m.CompanyLogo),
126
export const HomePageRandomJoke = homePlugin.provide(
127
createCardExtension<{ defaultCategory?: 'any' | 'programming' }>({
128
name: 'HomePageRandomJoke',
129
title: 'Random Joke',
130
components: () => import('./homePageComponents/RandomJoke'),
131
description: 'Shows a random joke about optional category',
133
height: { minRows: 4 },
134
width: { minColumns: 3 },
138
title: 'Random Joke settings',
144
enum: ['any', 'programming', 'dad'],
154
* A component to display a list of tools for the user.
158
export const HomePageToolkit = homePlugin.provide(
159
createCardExtension<ToolkitContentProps>({
160
name: 'HomePageToolkit',
162
components: () => import('./homePageComponents/Toolkit'),
167
* A component to display a list of starred entities for the user.
171
export const HomePageStarredEntities = homePlugin.provide(
172
createCardExtension<Partial<StarredEntitiesProps>>({
173
name: 'HomePageStarredEntities',
174
title: 'Your Starred Entities',
175
components: () => import('./homePageComponents/StarredEntities'),
180
* A component to display a configurable list of clocks for various time zones.
184
export const HeaderWorldClock = homePlugin.provide(
185
createComponentExtension({
186
name: 'HeaderWorldClock',
189
import('./homePageComponents/HeaderWorldClock').then(
190
m => m.HeaderWorldClock,
197
* Display top visited pages for the homepage
200
export const HomePageTopVisited = homePlugin.provide(
201
createCardExtension<Partial<VisitedByTypeProps>>({
202
name: 'HomePageTopVisited',
203
components: () => import('./homePageComponents/VisitedByType/TopVisited'),
208
* Display recently visited pages for the homepage
211
export const HomePageRecentlyVisited = homePlugin.provide(
212
createCardExtension<Partial<VisitedByTypeProps>>({
213
name: 'HomePageRecentlyVisited',
215
import('./homePageComponents/VisitedByType/RecentlyVisited'),
220
* A component to display specific Featured Docs.
224
export const FeaturedDocsCard = homePlugin.provide(
225
createCardExtension<FeaturedDocsCardProps>({
226
name: 'FeaturedDocsCard',
227
title: 'Featured Docs',
228
components: () => import('./homePageComponents/FeaturedDocsCard'),