diff --git a/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx b/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx
index 046cd171b9..fe4cb61446 100644
--- a/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx
+++ b/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx
@@ -1,5 +1,5 @@
import { useState, FC, useEffect } from 'react';
-import { List, ListItem, TextField, Button } from '@material-ui/core';
+import { ListItem, TextField, Button } from '@material-ui/core';
import React from 'react';
export const ProjectInput: FC<{
@@ -16,13 +16,13 @@ export const ProjectInput: FC<{
}, [apiGitInfo]);
return (
-
+ <>
setOwner(e.target.value)}
+ onChange={(e) => setOwner(e.target.value)}
/>
@@ -30,7 +30,7 @@ export const ProjectInput: FC<{
name="circleci-repo"
label="Repo"
value={repo}
- onChange={e => setRepo(e.target.value)}
+ onChange={(e) => setRepo(e.target.value)}
/>
@@ -43,6 +43,6 @@ export const ProjectInput: FC<{
Save
-
+ >
);
};
diff --git a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx
index 950792bfab..8ea1a4d4fb 100644
--- a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx
+++ b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useState, useEffect } from 'react';
import { Button, TextField, List, Grid, ListItem } from '@material-ui/core';
import { circleCIApiRef } from 'api';
import {
@@ -8,12 +8,12 @@ import {
ContentHeader,
SupportButton,
} from '@backstage/core';
-import { ProjectInput } from 'components/ProjectInput/ProjectInput';
import { Link as RouterLink } from 'react-router-dom';
import { Layout } from 'components/Layout';
export const SettingsPage = () => {
const api = useApi(circleCIApiRef);
+ const apiGitInfo = api.options.vcs;
const [authed, setAuthed] = React.useState(api.authed);
const [token, setToken] = React.useState('');
@@ -25,6 +25,16 @@ export const SettingsPage = () => {
.catch(() => setAuthed(false));
}, []);
+ const [owner, setOwner] = useState('');
+ const [repo, setRepo] = useState('');
+
+ useEffect(() => {
+ if (apiGitInfo && apiGitInfo.owner !== owner && apiGitInfo.owner)
+ setOwner(apiGitInfo.owner);
+ if (apiGitInfo && apiGitInfo.repo !== repo && apiGitInfo.repo)
+ setRepo(apiGitInfo.repo);
+ }, [apiGitInfo]);
+
return (
@@ -52,6 +62,32 @@ export const SettingsPage = () => {
/>
+
+ setOwner(e.target.value)}
+ />
+
+
+ setRepo(e.target.value)}
+ />
+
+
+
+
diff --git a/plugins/circleci/src/utils/index.ts b/plugins/circleci/src/utils/index.ts
new file mode 100644
index 0000000000..77697659e0
--- /dev/null
+++ b/plugins/circleci/src/utils/index.ts
@@ -0,0 +1,62 @@
+import { circleCIApiRef } from 'api';
+import { BuildSummary } from 'circleci-api';
+import { CITableBuildInfo } from 'components/CITable';
+
+const makeReadableStatus = (status: string | undefined) => {
+ if (typeof status === 'undefined') return '';
+ return ({
+ retried: 'Retried',
+ canceled: 'Canceled',
+ infrastructure_fail: 'Infra fail',
+ timedout: 'Timedout',
+ not_run: 'Not run',
+ running: 'Running',
+ failed: 'Failed',
+ queued: 'Queued',
+ scheduled: 'Scheduled',
+ not_running: 'Not running',
+ no_tests: 'No tests',
+ fixed: 'Fixed',
+ success: 'Success',
+ } as Record)[status];
+};
+
+export const transformBuildSummary = (
+ api: typeof circleCIApiRef.T,
+ buildData: BuildSummary,
+) => {
+ const tableBuildInfo: CITableBuildInfo = {
+ id: String(buildData.build_num),
+ buildName: buildData.subject
+ ? buildData.subject +
+ (buildData.retry_of ? ` (retry of #${buildData.retry_of})` : '')
+ : '',
+ onRetryClick: () => api.retry(String(buildData.build_num)),
+ source: {
+ branchName: String(buildData.branch),
+ commit: {
+ hash: String(buildData.vcs_revision),
+ url: 'todo',
+ },
+ },
+ status: makeReadableStatus(buildData.status),
+ buildUrl: buildData.build_url,
+ // tests: {
+ // failed: 0,
+ // passed: 10,
+ // skipped: 3,
+ // testUrl: 'nourlnow',
+ // total: 13,
+ // },
+ };
+ return tableBuildInfo;
+};
+
+export const transformBuildSummaries = (
+ buildsData: BuildSummary[],
+ api: typeof circleCIApiRef.T,
+): CITableBuildInfo[] => {
+ return buildsData.map((buildSummary) =>
+ transformBuildSummary(api, buildSummary),
+ );
+};