added dev env

Signed-off-by: Alex Rybchenko <arybchenko@box.com>
This commit is contained in:
Alex Rybchenko
2022-02-25 15:52:15 +01:00
parent 9297424748
commit a4b4cf5ede
19 changed files with 3087 additions and 3903 deletions
+44 -2
View File
@@ -13,7 +13,49 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import React from 'react';
import { Content, Page } from '@backstage/core-components';
import { googleAuthApiRef } from '@backstage/core-plugin-api';
import { createDevApp } from '@backstage/dev-utils';
import { gcalendarPlugin } from '../src/plugin';
import { calendarListMock, eventsMock } from './mocks';
import { gcalendarPlugin, CalendarCard } from '../src/plugin';
import { gcalendarApiRef } from '../src';
createDevApp().registerPlugin(gcalendarPlugin).render();
createDevApp()
.registerPlugin(gcalendarPlugin)
.registerApi({
api: googleAuthApiRef,
deps: {},
factory: () =>
({
async getAccessToken() {
return Promise.resolve('token');
},
} as unknown as typeof googleAuthApiRef.T),
})
.registerApi({
api: gcalendarApiRef,
deps: {},
factory: () =>
({
async getCalendars() {
return Promise.resolve(calendarListMock);
},
async getEvents() {
return Promise.resolve({
items: eventsMock,
});
},
} as unknown as typeof gcalendarApiRef.T),
})
.addPage({
element: (
<Page themeId="home">
<Content>
<CalendarCard />
</Content>
</Page>
),
title: 'Root Page',
})
.render();
+57
View File
@@ -0,0 +1,57 @@
/*
* Copyright 2022 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 { DateTime } from 'luxon';
import { GCalendar, GCalendarEvent } from '../src/api';
const primaryCalendar: GCalendar = {
id: 'calendar-1',
summary: 'test-1@test.com',
primary: true,
};
const nonPrimaryCalendar: GCalendar = {
id: 'calendar-2',
summary: 'test-2@test.com',
primary: false,
backgroundColor: '#9BF0E1',
};
export const calendarListMock = {
items: [primaryCalendar, nonPrimaryCalendar],
};
export const eventsMock: GCalendarEvent[] = [...Array(3).keys()].map(i => ({
id: i.toString(),
summary: `Meeting ${i + 1}`,
start: {
dateTime: DateTime.now()
.minus({ hour: i + 1 })
.toISO(),
timeZone: 'Europe/London',
},
end: {
dateTime: DateTime.now().minus({ hour: i }).toISO(),
timeZone: 'Europe/London',
},
description: '<h3>Dummy title</h3><p>Dummy description</p>',
conferenceData: {
entryPoints: [
{
entryPointType: 'video',
uri: 'https://zoom.us/',
},
],
},
}));