diff --git a/.changeset/real-baboons-vanish.md b/.changeset/real-baboons-vanish.md index 93c30d8389..9c4a19cd49 100644 --- a/.changeset/real-baboons-vanish.md +++ b/.changeset/real-baboons-vanish.md @@ -2,4 +2,4 @@ '@backstage/plugin-jenkins': minor --- -Added configuration for the action column in Jenkins CI/CD table. It can be set to rebuild, view, or replay. +Updated action column in Jenkins CI/CD table to include links to view and replay. The API based rebuild action was replaced because it does not work for Jenkins workflows that have parameters. diff --git a/plugins/jenkins/README.md b/plugins/jenkins/README.md index 12c6a197da..2a0ec451c8 100644 --- a/plugins/jenkins/README.md +++ b/plugins/jenkins/README.md @@ -86,24 +86,6 @@ spec: 8. Click the component in the catalog. You should now see Jenkins builds, and a last build result for your master build. -## Customize Action - -You can customize the action in the CI/CD table. - -| Action | Description | -| ----------------- | ----------------------- | -| rebuild (default) | Run new build with API | -| view | link to view build page | -| replay | link to start replay | - -```yaml -jenkinsPlugin.__experimentalReconfigure({ - tableAction: 'view', -}); -``` - -Customized action - view - ## Features - View all runs inside a folder diff --git a/plugins/jenkins/api-report.md b/plugins/jenkins/api-report.md index bcba48e4b2..a2ae16988b 100644 --- a/plugins/jenkins/api-report.md +++ b/plugins/jenkins/api-report.md @@ -98,7 +98,7 @@ const jenkinsPlugin: BackstagePlugin< entityContent: RouteRef; }, {}, - JenkinsInputPluginOptions + {} >; export { jenkinsPlugin }; export { jenkinsPlugin as plugin }; diff --git a/plugins/jenkins/src/assets/customize_action_view.png b/plugins/jenkins/src/assets/customize_action_view.png deleted file mode 100644 index 8be43c5971..0000000000 Binary files a/plugins/jenkins/src/assets/customize_action_view.png and /dev/null differ diff --git a/plugins/jenkins/src/assets/folder-results.png b/plugins/jenkins/src/assets/folder-results.png index 2c14d5d927..340b03549d 100644 Binary files a/plugins/jenkins/src/assets/folder-results.png and b/plugins/jenkins/src/assets/folder-results.png differ diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index b0a8b84718..6fc5f2d35c 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -13,20 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Link, Progress, Table, TableColumn } from '@backstage/core-components'; -import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; -import { useEntityPermission } from '@backstage/plugin-catalog-react/alpha'; -import { Box, IconButton, Tooltip, Typography } from '@material-ui/core'; +import { Link, Table, TableColumn } from '@backstage/core-components'; +import { useRouteRef } from '@backstage/core-plugin-api'; +import { Box, IconButton, Typography } from '@material-ui/core'; import RetryIcon from '@material-ui/icons/Replay'; import VisibilityIcon from '@material-ui/icons/Visibility'; -import { default as React, useState } from 'react'; +import { default as React } from 'react'; import { Project } from '../../../../api/JenkinsApi'; import JenkinsLogo from '../../../../assets/JenkinsLogo.svg'; import { buildRouteRef } from '../../../../plugin'; import { useBuilds } from '../../../useBuilds'; import { JenkinsRunStatus } from '../Status'; -import { jenkinsExecutePermission } from '@backstage/plugin-jenkins-common'; -import { useJenkinsPluginOptions } from '../../../../options'; const FailCount = ({ count }: { count: number }): JSX.Element | null => { if (count !== 0) { @@ -176,64 +173,16 @@ const generatedColumns: TableColumn[] = [ title: 'Actions', sorting: false, render: (row: Partial) => { - const ActionWrapper = () => { - const [isLoadingRebuild, setIsLoadingRebuild] = useState(false); - const { allowed, loading } = useEntityPermission( - jenkinsExecutePermission, - ); - - const alertApi = useApi(alertApiRef); - - const onRebuild = async () => { - if (row.onRestartClick) { - setIsLoadingRebuild(true); - try { - await row.onRestartClick(); - alertApi.post({ - message: 'Jenkins re-build has successfully executed', - severity: 'success', - }); - } catch (e) { - alertApi.post({ - message: `Jenkins re-build has failed. Error: ${e.message}`, - severity: 'error', - }); - } finally { - setIsLoadingRebuild(false); - } - } - }; - - const { tableAction } = useJenkinsPluginOptions(); - - if (tableAction === 'view') { - return row.lastBuild?.url ? ( - - - - ) : null; - } else if (tableAction === 'replay') { - return row.lastBuild?.url ? ( - - - - ) : null; - } - - return ( - - <> - {isLoadingRebuild && } - {!isLoadingRebuild && ( - - - - )} - - - ); - }; - return ; + return row.lastBuild?.url ? ( +
+ + + + + + +
+ ) : null; }, width: '10%', }, diff --git a/plugins/jenkins/src/options.ts b/plugins/jenkins/src/options.ts deleted file mode 100644 index f78e6a75e9..0000000000 --- a/plugins/jenkins/src/options.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2020 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 { usePluginOptions } from '@backstage/core-plugin-api/alpha'; - -export type JenkinsPluginOptions = { - tableAction: string; -}; - -/** @ignore */ -export type JenkinsInputPluginOptions = { - tableAction: string; -}; - -export const useJenkinsPluginOptions = () => - usePluginOptions(); diff --git a/plugins/jenkins/src/plugin.ts b/plugins/jenkins/src/plugin.ts index ddef0a7dfd..7dbb6bfde1 100644 --- a/plugins/jenkins/src/plugin.ts +++ b/plugins/jenkins/src/plugin.ts @@ -25,7 +25,6 @@ import { identityApiRef, } from '@backstage/core-plugin-api'; import { JenkinsClient, jenkinsApiRef } from './api'; -import { JenkinsInputPluginOptions, JenkinsPluginOptions } from './options'; /** @public */ export const rootRouteRef = createRouteRef({ @@ -53,14 +52,6 @@ export const jenkinsPlugin = createPlugin({ routes: { entityContent: rootRouteRef, }, - __experimentalConfigure( - options?: JenkinsInputPluginOptions, - ): JenkinsPluginOptions { - const defaultOptions = { - tableAction: 'rebuild', - }; - return { ...defaultOptions, ...options }; - }, }); /** @public */