diff --git a/packages/app/src/apis.ts b/packages/app/src/apis.ts index abc490b658..df17886216 100644 --- a/packages/app/src/apis.ts +++ b/packages/app/src/apis.ts @@ -58,6 +58,10 @@ import { import { scaffolderApiRef, ScaffolderApi } from '@backstage/plugin-scaffolder'; import { rollbarApiRef, RollbarClient } from '@backstage/plugin-rollbar'; +import { + MockGithubActionsClient, + githubActionsApiRef, +} from '@backstage/plugin-github-actions'; export const apis = (config: ConfigApi) => { // eslint-disable-next-line no-console @@ -75,6 +79,7 @@ export const apis = (config: ConfigApi) => { builder.add(storageApiRef, WebStorage.create({ errorApi })); builder.add(circleCIApiRef, new CircleCIApi()); + builder.add(githubActionsApiRef, new MockGithubActionsClient()); builder.add(featureFlagsApiRef, new FeatureFlags()); builder.add(lighthouseApiRef, new LighthouseRestApi('http://localhost:3003')); diff --git a/plugins/github-actions/src/api/GithubActionsApi.ts b/plugins/github-actions/src/api/GithubActionsApi.ts index 58892173ed..c47cff7eda 100644 --- a/plugins/github-actions/src/api/GithubActionsApi.ts +++ b/plugins/github-actions/src/api/GithubActionsApi.ts @@ -18,6 +18,7 @@ import { createApiRef } from '@backstage/core'; import { Build, BuildDetails } from './types'; import { Entity } from '@backstage/catalog-model'; + export const githubActionsApiRef = createApiRef({ id: 'plugin.githubactions.service', description: 'Used by the Github Actions plugin to make requests', diff --git a/plugins/github-actions/src/apis/builds/BuildsClient.ts b/plugins/github-actions/src/api/MockGithubActionsClient.ts similarity index 77% rename from plugins/github-actions/src/apis/builds/BuildsClient.ts rename to plugins/github-actions/src/api/MockGithubActionsClient.ts index 6fbc6a6c53..89ecad3931 100644 --- a/plugins/github-actions/src/apis/builds/BuildsClient.ts +++ b/plugins/github-actions/src/api/MockGithubActionsClient.ts @@ -14,20 +14,16 @@ * limitations under the License. */ +import { GithubActionsApi } from './GithubActionsApi'; import { Build, BuildDetails, BuildStatus } from './types'; -export class BuildsClient { - static create(): BuildsClient { - return new BuildsClient(); - } - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async listBuilds(_entityUri: string): Promise { +export class MockGithubActionsClient implements GithubActionsApi { + async listBuilds(): Promise { return []; } // eslint-disable-next-line @typescript-eslint/no-unused-vars - async getBuild(_buildUri: string): Promise { + async getBuild(): Promise { return { build: { commitId: 'TODO', diff --git a/plugins/github-actions/src/apis/builds/index.ts b/plugins/github-actions/src/apis/builds/index.ts deleted file mode 100644 index 9ce2150893..0000000000 --- a/plugins/github-actions/src/apis/builds/index.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * 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 { BuildsClient } from './BuildsClient'; -export * from './types'; diff --git a/plugins/github-actions/src/apis/builds/types.ts b/plugins/github-actions/src/apis/builds/types.ts deleted file mode 100644 index 134a663d02..0000000000 --- a/plugins/github-actions/src/apis/builds/types.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * 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 enum BuildStatus { - Null, - Success, - Failure, - Pending, - Running, -} - -export type Build = { - commitId: string; - message: string; - branch: string; - status: BuildStatus; - uri: string; -}; - -export type BuildDetails = { - build: Build; - author: string; - logUrl: string; - overviewUrl: string; -}; diff --git a/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx b/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx index ae979d0cc0..85568c8c07 100644 --- a/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx +++ b/plugins/github-actions/src/components/BuildListPage/BuildListPage.tsx @@ -36,6 +36,7 @@ import { githubActionsApiRef } from '../../api'; import { useApi, githubAuthApiRef } from '@backstage/core-api'; import { Entity } from '@backstage/catalog-model'; + const LongText = ({ text, max }: { text: string; max: number }) => { if (text.length < max) { return {text};