From 21ac45698a8804ce5b74857c22090097f1845699 Mon Sep 17 00:00:00 2001 From: Ivan Shmidt Date: Mon, 4 May 2020 23:10:14 +0200 Subject: [PATCH] feat: visual adjustments --- plugins/circleci/src/api/index.ts | 4 +- .../src/components/CITable/CITable.tsx | 42 ++++++++----------- .../components/CircleCIFetch/CirleCIFetch.tsx | 14 +++---- .../components/ProjectInput/ProjectInput.tsx | 26 +++++++----- .../components/SettingsPage/SettingsPage.tsx | 13 ++++-- 5 files changed, 53 insertions(+), 46 deletions(-) diff --git a/plugins/circleci/src/api/index.ts b/plugins/circleci/src/api/index.ts index 93916f82bb..955daf3fba 100644 --- a/plugins/circleci/src/api/index.ts +++ b/plugins/circleci/src/api/index.ts @@ -31,8 +31,8 @@ export const circleCIApiRef = new ApiRef({ }); export class CircleCIApi { - token: string = ''; - private options: Partial; + private token: string = ''; + options: Partial; authed: boolean = false; constructor(options?: Partial) { diff --git a/plugins/circleci/src/components/CITable/CITable.tsx b/plugins/circleci/src/components/CITable/CITable.tsx index 882f52fbe0..5efb0edb9f 100644 --- a/plugins/circleci/src/components/CITable/CITable.tsx +++ b/plugins/circleci/src/components/CITable/CITable.tsx @@ -11,9 +11,6 @@ import { TableRow, Link, CircularProgress, - List, - ListItem, - ListItemText, } from '@material-ui/core'; import { Replay as RetryIcon } from '@material-ui/icons'; import { @@ -78,7 +75,7 @@ export const CITable: FC<{ builds: CITableBuildInfo[]; }> = ({ builds }) => { const classes = useStyles(); - + const isTestDataAvailable = builds.some(build => build.tests); return ( @@ -88,8 +85,8 @@ export const CITable: FC<{ BuildSourceStatus - Tests - Actions + {isTestDataAvailable && Tests} + Actions @@ -102,28 +99,25 @@ export const CITable: FC<{ - - - - - - - - + {build.source.branchName} +
+ {build.source.commit.hash}
{getStatusComponent(build.status)} - - {build.tests && ( - <> - {build.tests.passed}/{build.tests.total} ( - {build.tests.failed ? build.tests.failed + ', ' : ''} - {build.tests.skipped ? build.tests.skipped : ''}) - - )} - - + {build.tests && ( + + { + <> + {build.tests.passed}/{build.tests.total} ( + {build.tests.failed ? build.tests.failed + ', ' : ''} + {build.tests.skipped ? build.tests.skipped : ''}) + + } + + )} + diff --git a/plugins/circleci/src/components/CircleCIFetch/CirleCIFetch.tsx b/plugins/circleci/src/components/CircleCIFetch/CirleCIFetch.tsx index 59c667182f..92d4ca5ce2 100644 --- a/plugins/circleci/src/components/CircleCIFetch/CirleCIFetch.tsx +++ b/plugins/circleci/src/components/CircleCIFetch/CirleCIFetch.tsx @@ -68,13 +68,13 @@ const transform = ( }, status: makeReadableStatus(buildData.status), buildUrl: buildData.build_url, - tests: { - failed: 0, - passed: 10, - skipped: 3, - testUrl: 'nourlnow', - total: 13, - }, + // tests: { + // failed: 0, + // passed: 10, + // skipped: 3, + // testUrl: 'nourlnow', + // total: 13, + // }, }; return tableBuildInfo; }); diff --git a/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx b/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx index 79ca532f70..046cd171b9 100644 --- a/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx +++ b/plugins/circleci/src/components/ProjectInput/ProjectInput.tsx @@ -1,14 +1,20 @@ -import { useState, FC } from "react"; -import { List, ListItem, TextField, Button } from "@material-ui/core"; -import React from "react"; +import { useState, FC, useEffect } from 'react'; +import { List, ListItem, TextField, Button } from '@material-ui/core'; +import React from 'react'; -export const ProjectInput:FC<{ - setGitInfo: (info: {owner: string, repo: string}) => void - }> = ({setGitInfo}) => { - +export const ProjectInput: FC<{ + setGitInfo: (info: { owner: string; repo: string }) => void; + apiGitInfo?: { owner?: string; repo?: string }; +}> = ({ setGitInfo, apiGitInfo = {} }) => { const [owner, setOwner] = useState(''); const [repo, setRepo] = useState(''); - + + useEffect(() => { + if (apiGitInfo.owner !== owner && apiGitInfo.owner) + setOwner(apiGitInfo.owner); + if (apiGitInfo.repo !== repo && apiGitInfo.repo) setRepo(apiGitInfo.repo); + }, [apiGitInfo]); + return ( @@ -34,9 +40,9 @@ export const ProjectInput:FC<{ color="primary" onClick={() => setGitInfo({ owner, repo })} > - Load + Save ); -}; \ No newline at end of file +}; diff --git a/plugins/circleci/src/components/SettingsPage/SettingsPage.tsx b/plugins/circleci/src/components/SettingsPage/SettingsPage.tsx index 4c377f090c..8a0ba78118 100644 --- a/plugins/circleci/src/components/SettingsPage/SettingsPage.tsx +++ b/plugins/circleci/src/components/SettingsPage/SettingsPage.tsx @@ -41,8 +41,8 @@ export const SettingsPage = () => { A description of your plugin goes here. - - + + {authed ? ( @@ -79,7 +79,14 @@ export const SettingsPage = () => { )} - api.setVCSOptions(info)} /> + + + + api.setVCSOptions(info)} + /> +