+ );
+};
+
+export default Page;
+export { BuildWithStepsView as BuildWithSteps };
diff --git a/plugins/jenkins/src/pages/BuildWithStepsPage/index.ts b/plugins/jenkins/src/components/BuildWithStepsPage/index.ts
similarity index 100%
rename from plugins/jenkins/src/pages/BuildWithStepsPage/index.ts
rename to plugins/jenkins/src/components/BuildWithStepsPage/index.ts
diff --git a/plugins/jenkins/src/pages/BuildWithStepsPage/lib/ActionOutput/ActionOutput.tsx b/plugins/jenkins/src/components/BuildWithStepsPage/lib/ActionOutput/ActionOutput.tsx
similarity index 100%
rename from plugins/jenkins/src/pages/BuildWithStepsPage/lib/ActionOutput/ActionOutput.tsx
rename to plugins/jenkins/src/components/BuildWithStepsPage/lib/ActionOutput/ActionOutput.tsx
diff --git a/plugins/jenkins/src/pages/BuildWithStepsPage/lib/ActionOutput/index.ts b/plugins/jenkins/src/components/BuildWithStepsPage/lib/ActionOutput/index.ts
similarity index 100%
rename from plugins/jenkins/src/pages/BuildWithStepsPage/lib/ActionOutput/index.ts
rename to plugins/jenkins/src/components/BuildWithStepsPage/lib/ActionOutput/index.ts
diff --git a/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
similarity index 81%
rename from plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx
rename to plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
index 7f17107374..282cbc59b5 100644
--- a/plugins/jenkins/src/pages/BuildsPage/lib/CITable/CITable.tsx
+++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx
@@ -14,21 +14,26 @@
* limitations under the License.
*/
import React, { FC } from 'react';
-import { Link, Typography, Box, IconButton } from '@material-ui/core';
+import { Box, IconButton, Link, Typography } from '@material-ui/core';
import RetryIcon from '@material-ui/icons/Replay';
import GitHubIcon from '@material-ui/icons/GitHub';
-import { Link as RouterLink } from 'react-router-dom';
+import { generatePath, Link as RouterLink } from 'react-router-dom';
import { Table, TableColumn } from '@backstage/core';
import { JenkinsRunStatus } from '../Status';
+import { useBuilds } from '../../../useBuilds';
+import { useProjectSlugFromEntity } from '../../../useProjectSlugFromEntity';
+import { buildRouteRef } from '../../../../plugin';
export type CITableBuildInfo = {
id: string;
buildName: string;
- buildUrl?: string;
+ buildNumber: number;
+ buildUrl: string;
source: {
branchName: string;
url: string;
displayName: string;
+ author?: string;
commit: {
hash: string;
};
@@ -105,7 +110,13 @@ const generatedColumns: TableColumn[] = [
field: 'buildName',
highlight: true,
render: (row: Partial) => (
-
+
{row.buildName}
),
@@ -177,7 +188,8 @@ type Props = {
pageSize: number;
onChangePageSize: (pageSize: number) => void;
};
-export const CITable: FC = ({
+
+export const CITableView: FC = ({
projectName,
loading,
pageSize,
@@ -191,7 +203,7 @@ export const CITable: FC = ({
return (
= ({
onClick: () => retry(),
},
]}
- data={builds}
+ data={builds ?? []}
onChangePage={onChangePage}
onChangeRowsPerPage={onChangePageSize}
title={
@@ -216,3 +228,18 @@ export const CITable: FC = ({
/>
);
};
+
+export const CITable = () => {
+ const { owner, repo } = useProjectSlugFromEntity();
+
+ const [tableProps, { setPage, retry, setPageSize }] = useBuilds(owner, repo);
+
+ return (
+
+ );
+};
diff --git a/plugins/jenkins/src/pages/BuildsPage/lib/CITable/index.ts b/plugins/jenkins/src/components/BuildsPage/lib/CITable/index.ts
similarity index 100%
rename from plugins/jenkins/src/pages/BuildsPage/lib/CITable/index.ts
rename to plugins/jenkins/src/components/BuildsPage/lib/CITable/index.ts
diff --git a/plugins/jenkins/src/pages/BuildsPage/lib/Status/JenkinsRunStatus.tsx b/plugins/jenkins/src/components/BuildsPage/lib/Status/JenkinsRunStatus.tsx
similarity index 100%
rename from plugins/jenkins/src/pages/BuildsPage/lib/Status/JenkinsRunStatus.tsx
rename to plugins/jenkins/src/components/BuildsPage/lib/Status/JenkinsRunStatus.tsx
diff --git a/plugins/jenkins/src/pages/BuildsPage/lib/Status/index.ts b/plugins/jenkins/src/components/BuildsPage/lib/Status/index.ts
similarity index 100%
rename from plugins/jenkins/src/pages/BuildsPage/lib/Status/index.ts
rename to plugins/jenkins/src/components/BuildsPage/lib/Status/index.ts
diff --git a/plugins/jenkins/src/components/JenkinsPluginWidget/JenkinsLastBuildWidget.tsx b/plugins/jenkins/src/components/Cards/Cards.tsx
similarity index 78%
rename from plugins/jenkins/src/components/JenkinsPluginWidget/JenkinsLastBuildWidget.tsx
rename to plugins/jenkins/src/components/Cards/Cards.tsx
index 9bd16bf9e6..5034effdcf 100644
--- a/plugins/jenkins/src/components/JenkinsPluginWidget/JenkinsLastBuildWidget.tsx
+++ b/plugins/jenkins/src/components/Cards/Cards.tsx
@@ -14,12 +14,12 @@
* limitations under the License.
*/
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 ExternalLinkIcon from '@material-ui/icons/Launch';
-import { useBuilds } from '../../state';
-import { JenkinsRunStatus } from '../../pages/BuildsPage/lib/Status';
+import { useBuilds } from '../useBuilds';
+import { JenkinsRunStatus } from '../BuildsPage/lib/Status';
+import { useProjectSlugFromEntity } from '../useProjectSlugFromEntity';
const useStyles = makeStyles({
externalLinkIcon: {
@@ -38,6 +38,7 @@ const WidgetContent = ({
}) => {
const classes = useStyles();
if (loading || !lastRun) return ;
+
return (
{
- const [owner, repo] = (
- entity?.metadata.annotations?.['backstage.io/jenkins-github-folder'] ?? '/'
- ).split('/');
- const [{ loading, value }] = useBuilds(owner, repo, branch);
-
- const lastRun = value ?? {};
-
+export const LatestRunCard = ({ branch = 'master' }: { branch: string }) => {
+ const { owner, repo } = useProjectSlugFromEntity();
+ const [{ builds, loading }] = useBuilds(owner, repo, branch);
+ const lastRun = builds ?? {};
return (
diff --git a/plugins/jenkins/src/components/PluginHeader/index.ts b/plugins/jenkins/src/components/Cards/index.ts
similarity index 93%
rename from plugins/jenkins/src/components/PluginHeader/index.ts
rename to plugins/jenkins/src/components/Cards/index.ts
index 4de972f6f2..dace09e1a9 100644
--- a/plugins/jenkins/src/components/PluginHeader/index.ts
+++ b/plugins/jenkins/src/components/Cards/index.ts
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-export * from './PluginHeader';
+export { LatestRunCard } from './Cards';
diff --git a/plugins/jenkins/src/components/Layout/Layout.tsx b/plugins/jenkins/src/components/Layout/Layout.tsx
deleted file mode 100644
index c6000437a3..0000000000
--- a/plugins/jenkins/src/components/Layout/Layout.tsx
+++ /dev/null
@@ -1,29 +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.
- */
-import React from 'react';
-import { Header, Page, pageTheme, HeaderLabel } from '@backstage/core';
-
-export const Layout: React.FC = ({ children }) => {
- return (
-
-
-
-
-
- {children}
-
- );
-};
diff --git a/plugins/jenkins/src/components/Layout/index.ts b/plugins/jenkins/src/components/Layout/index.ts
deleted file mode 100644
index 236fc98851..0000000000
--- a/plugins/jenkins/src/components/Layout/index.ts
+++ /dev/null
@@ -1,16 +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 * from './Layout';
diff --git a/plugins/jenkins/src/components/PluginHeader/PluginHeader.tsx b/plugins/jenkins/src/components/PluginHeader/PluginHeader.tsx
deleted file mode 100644
index 501649e49a..0000000000
--- a/plugins/jenkins/src/components/PluginHeader/PluginHeader.tsx
+++ /dev/null
@@ -1,36 +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.
- */
-import React from 'react';
-import { ContentHeader, SupportButton } from '@backstage/core';
-import { Box, Typography } from '@material-ui/core';
-
-export type Props = { title?: string };
-export const PluginHeader = ({ title = 'Jenkins' }) => {
- return (
- (
-
- {title}
-
- )}
- >
-
- This plugin allows you to view and interact with your builds in Jenkins.
-
-
- );
-};
diff --git a/plugins/jenkins/src/components/Router.tsx b/plugins/jenkins/src/components/Router.tsx
new file mode 100644
index 0000000000..56df5456bc
--- /dev/null
+++ b/plugins/jenkins/src/components/Router.tsx
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+import React from 'react';
+import { Route, Routes } from 'react-router';
+import { buildRouteRef, rootRouteRef } from '../plugin';
+import { DetailedViewPage } from './BuildWithStepsPage/';
+import { JENKINS_ANNOTATION } from '../constants';
+import { Entity } from '@backstage/catalog-model';
+import { WarningPanel } from '@backstage/core';
+import { CITable } from './BuildsPage/lib/CITable';
+
+export const isPluginApplicableToEntity = (entity: Entity) =>
+ Boolean(entity.metadata.annotations?.[JENKINS_ANNOTATION]) &&
+ entity.metadata.annotations?.[JENKINS_ANNOTATION] !== '';
+
+export const Router = ({ entity }: { entity: Entity }) => {
+ return !isPluginApplicableToEntity(entity) ? (
+
+