backstage
63 строки · 1.9 Кб
1/*
2* Copyright 2023 The Backstage Authors
3*
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
7*
8* http://www.apache.org/licenses/LICENSE-2.0
9*
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.
15*/
16import React from 'react';
17import { createDevApp } from '@backstage/dev-utils';
18import { microsoftCalendarPlugin, MicrosoftCalendarCard } from '../src/plugin';
19import { microsoftCalendarApiRef } from '../src';
20import responseMock from './mock.json';
21import { microsoftAuthApiRef } from '@backstage/core-plugin-api';
22import { Content, Page } from '@backstage/core-components';
23import { Grid } from '@material-ui/core';
24
25createDevApp()
26.registerPlugin(microsoftCalendarPlugin)
27.registerApi({
28api: microsoftAuthApiRef,
29deps: {},
30factory: () =>
31({
32async getAccessToken() {
33return Promise.resolve('token');
34},
35} as unknown as typeof microsoftAuthApiRef.T),
36})
37.registerApi({
38api: microsoftCalendarApiRef,
39deps: {},
40factory: () =>
41({
42async getCalendars() {
43return Promise.resolve(responseMock.calendars);
44},
45async getEvents() {
46return Promise.resolve(responseMock.events);
47},
48} as unknown as typeof microsoftCalendarApiRef.T),
49})
50.addPage({
51element: (
52<Page themeId="home">
53<Content>
54<Grid item xs={12} md={6}>
55<MicrosoftCalendarCard />
56</Grid>
57</Content>
58</Page>
59),
60title: 'Microsoft-Calendar Plugin Demo',
61path: '/microsoft-calendar',
62})
63.render();
64