fix broken stack overflow stories - mock stack overflow api

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2023-03-10 15:41:08 +01:00
parent ca69adb78f
commit 3ef5fb09ca
6 changed files with 71 additions and 6 deletions
@@ -20,10 +20,16 @@ import {
StackOverflowQuestionsRequestParams,
} from '../types';
/**
* @public
*/
export const stackOverflowApiRef = createApiRef<StackOverflowApi>({
id: 'plugin.stackoverflow.service',
});
/**
* @public
*/
export type StackOverflowApi = {
listQuestions(options?: {
requestParams: StackOverflowQuestionsRequestParams;
@@ -21,6 +21,26 @@ import { ConfigReader } from '@backstage/config';
import { Grid } from '@material-ui/core';
import React, { ComponentType } from 'react';
import { StackOverflowIcon } from '../../icons';
import { stackOverflowApiRef } from '../../api';
const mockStackOverflowApi = {
listQuestions: async () => [
{
title: 'Customizing Spotify backstage UI',
link: 'stackoverflow.question/1',
answer_count: 0,
tags: ['backstage'],
owner: { 'some owner': 'name' },
},
{
title: 'Customizing Spotify backstage UI',
link: 'stackoverflow.question/1',
answer_count: 0,
tags: ['backstage'],
owner: { 'some owner': 'name' },
},
],
};
export default {
title: 'Plugins/Home/Components/StackOverflow',
@@ -39,6 +59,7 @@ export default {
},
}),
],
[stackOverflowApiRef, mockStackOverflowApi],
]}
>
<Story />
+2
View File
@@ -30,3 +30,5 @@ export type {
StackOverflowQuestionsContentProps,
StackOverflowQuestionsRequestParams,
} from './types';
export { stackOverflowApiRef } from './api';
export type { StackOverflowApi } from './api';