chore(jenkins): ran prettier
This commit is contained in:
@@ -62,8 +62,7 @@ import {
|
||||
GithubActionsClient,
|
||||
githubActionsApiRef,
|
||||
} from '@backstage/plugin-github-actions';
|
||||
import {jenkinsApiRef, JenkinsApi} from "@backstage/plugin-jenkins";
|
||||
|
||||
import { jenkinsApiRef, JenkinsApi } from '@backstage/plugin-jenkins';
|
||||
|
||||
import { TravisCIApi, travisCIApiRef } from '@roadiehq/backstage-plugin-travis-ci';
|
||||
|
||||
@@ -87,10 +86,7 @@ export const apis = (config: ConfigApi) => {
|
||||
new CircleCIApi(`${backendUrl}/proxy/circleci/api`),
|
||||
);
|
||||
|
||||
builder.add(
|
||||
jenkinsApiRef,
|
||||
new JenkinsApi(`${backendUrl}/proxy/jenkins/api`),
|
||||
);
|
||||
builder.add(jenkinsApiRef, new JenkinsApi(`${backendUrl}/proxy/jenkins/api`));
|
||||
|
||||
builder.add(githubActionsApiRef, new GithubActionsClient());
|
||||
|
||||
|
||||
@@ -29,7 +29,10 @@ import {
|
||||
} from '@backstage/core';
|
||||
import { SentryIssuesWidget } from '@backstage/plugin-sentry';
|
||||
import { Widget as GithubActionsWidget } from '@backstage/plugin-github-actions';
|
||||
import { JenkinsBuildsWidget, JenkinsLastBuildWidget } from '@backstage/plugin-jenkins';
|
||||
import {
|
||||
JenkinsBuildsWidget,
|
||||
JenkinsLastBuildWidget,
|
||||
} from '@backstage/plugin-jenkins';
|
||||
import { Grid, Box } from '@material-ui/core';
|
||||
import { Alert } from '@material-ui/lab';
|
||||
import React, { FC, useEffect, useState } from 'react';
|
||||
@@ -190,17 +193,17 @@ export const EntityPage: FC<{}> = () => {
|
||||
</Grid>
|
||||
{entity.metadata?.annotations?.[
|
||||
'backstage.io/jenkins-github-folder'
|
||||
] && (
|
||||
<Grid item sm={4}>
|
||||
<JenkinsLastBuildWidget entity={entity} branch='master' />
|
||||
</Grid>
|
||||
] && (
|
||||
<Grid item sm={4}>
|
||||
<JenkinsLastBuildWidget entity={entity} branch="master" />
|
||||
</Grid>
|
||||
)}
|
||||
{entity.metadata?.annotations?.[
|
||||
'backstage.io/jenkins-github-folder'
|
||||
] && (
|
||||
<Grid item sm={8}>
|
||||
<JenkinsBuildsWidget entity={entity} />
|
||||
</Grid>
|
||||
] && (
|
||||
<Grid item sm={8}>
|
||||
<JenkinsBuildsWidget entity={entity} />
|
||||
</Grid>
|
||||
)}
|
||||
{entity.metadata?.annotations?.[
|
||||
'backstage.io/github-actions-id'
|
||||
|
||||
@@ -15,15 +15,13 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {Builds} from '../../pages/BuildsPage/lib/Builds';
|
||||
import {Entity} from "@backstage/catalog-model";
|
||||
import { Builds } from '../../pages/BuildsPage/lib/Builds';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
|
||||
export const JenkinsBuildsWidget = ({entity}: {
|
||||
entity: Entity;
|
||||
}) => {
|
||||
export const JenkinsBuildsWidget = ({ entity }: { entity: Entity }) => {
|
||||
const [owner, repo] = (
|
||||
entity?.metadata.annotations?.['backstage.io/jenkins-github-folder'] ?? '/'
|
||||
).split('/');
|
||||
|
||||
|
||||
return <Builds owner={owner} repo={repo} />;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,19 +15,11 @@
|
||||
*/
|
||||
import React from 'react';
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import {
|
||||
Link,
|
||||
Theme,
|
||||
makeStyles,
|
||||
LinearProgress,
|
||||
} from '@material-ui/core';
|
||||
import {
|
||||
InfoCard,
|
||||
StructuredMetadataTable,
|
||||
} from '@backstage/core';
|
||||
import { Link, Theme, makeStyles, LinearProgress } from '@material-ui/core';
|
||||
import { InfoCard, StructuredMetadataTable } from '@backstage/core';
|
||||
import ExternalLinkIcon from '@material-ui/icons/Launch';
|
||||
import {useBuilds} from "../../state";
|
||||
import {JenkinsRunStatus} from "../../pages/BuildsPage/lib/Status";
|
||||
import { useBuilds } from '../../state';
|
||||
import { JenkinsRunStatus } from '../../pages/BuildsPage/lib/Status';
|
||||
|
||||
const useStyles = makeStyles<Theme>({
|
||||
externalLinkIcon: {
|
||||
@@ -37,9 +29,9 @@ const useStyles = makeStyles<Theme>({
|
||||
});
|
||||
|
||||
const WidgetContent = ({
|
||||
loading,
|
||||
lastRun,
|
||||
}: {
|
||||
loading,
|
||||
lastRun,
|
||||
}: {
|
||||
loading?: boolean;
|
||||
lastRun: any;
|
||||
branch: string;
|
||||
@@ -51,7 +43,9 @@ const WidgetContent = ({
|
||||
metadata={{
|
||||
status: (
|
||||
<>
|
||||
<JenkinsRunStatus status={lastRun.building ? 'running': lastRun.result} />
|
||||
<JenkinsRunStatus
|
||||
status={lastRun.building ? 'running' : lastRun.result}
|
||||
/>
|
||||
</>
|
||||
),
|
||||
build: lastRun.fullDisplayName,
|
||||
@@ -67,28 +61,22 @@ const WidgetContent = ({
|
||||
};
|
||||
|
||||
export const JenkinsLastBuildWidget = ({
|
||||
entity,
|
||||
branch = 'master',
|
||||
}: {
|
||||
entity,
|
||||
branch = 'master',
|
||||
}: {
|
||||
entity: Entity;
|
||||
branch: string;
|
||||
}) => {
|
||||
const [owner, repo] = (
|
||||
entity?.metadata.annotations?.['backstage.io/jenkins-github-folder'] ?? '/'
|
||||
).split('/');
|
||||
const [
|
||||
{loading, value}
|
||||
] = useBuilds(owner, repo, branch);
|
||||
|
||||
const lastRun = value ?? {} ;
|
||||
|
||||
const [{ loading, value }] = useBuilds(owner, repo, branch);
|
||||
|
||||
const lastRun = value ?? {};
|
||||
|
||||
return (
|
||||
<InfoCard title={`Last ${branch} build`}>
|
||||
<WidgetContent
|
||||
loading={loading}
|
||||
branch={branch}
|
||||
lastRun={lastRun}
|
||||
/>
|
||||
<WidgetContent loading={loading} branch={branch} lastRun={lastRun} />
|
||||
</InfoCard>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -14,20 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import React from 'react';
|
||||
import {CITable} from '../CITable';
|
||||
import {useBuilds} from '../../../../state';
|
||||
|
||||
export const Builds = ({
|
||||
owner,
|
||||
repo
|
||||
}: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
}) => {
|
||||
import { CITable } from '../CITable';
|
||||
import { useBuilds } from '../../../../state';
|
||||
|
||||
export const Builds = ({ owner, repo }: { owner: string; repo: string }) => {
|
||||
const [
|
||||
{total, loading, value, projectName, page, pageSize},
|
||||
{setPage, retry, setPageSize},
|
||||
{ total, loading, value, projectName, page, pageSize },
|
||||
{ setPage, retry, setPageSize },
|
||||
] = useBuilds(owner, repo);
|
||||
return (
|
||||
<CITable
|
||||
|
||||
@@ -14,12 +14,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {StatusPending, StatusRunning, StatusOK, StatusWarning, StatusAborted, StatusError} from '@backstage/core';
|
||||
import {
|
||||
StatusPending,
|
||||
StatusRunning,
|
||||
StatusOK,
|
||||
StatusWarning,
|
||||
StatusAborted,
|
||||
StatusError,
|
||||
} from '@backstage/core';
|
||||
import React from 'react';
|
||||
|
||||
export const JenkinsRunStatus = ({
|
||||
status,
|
||||
}: {
|
||||
status,
|
||||
}: {
|
||||
status: string | undefined;
|
||||
}) => {
|
||||
if (status === undefined) return null;
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { JenkinsRunStatus } from './JenkinsRunStatus'
|
||||
export { JenkinsRunStatus } from './JenkinsRunStatus';
|
||||
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
|
||||
import { createPlugin, createRouteRef } from '@backstage/core';
|
||||
import {DetailedViewPage} from "./pages/BuildWithStepsPage";
|
||||
import { DetailedViewPage } from './pages/BuildWithStepsPage';
|
||||
|
||||
export const buildRouteRef = createRouteRef({
|
||||
path: '/jenkins/job',
|
||||
title: 'Jenkins run',
|
||||
});
|
||||
|
||||
|
||||
export const plugin = createPlugin({
|
||||
id: 'jenkins',
|
||||
register({ router }) {
|
||||
|
||||
Reference in New Issue
Block a user