diff --git a/plugins/circleci/package.json b/plugins/circleci/package.json index f2c94f06e1..3b04ee28f2 100644 --- a/plugins/circleci/package.json +++ b/plugins/circleci/package.json @@ -32,11 +32,13 @@ "@types/react-lazylog": "^4.5.0", "@types/react-redux": "^7.1.8", "circleci-api": "^4.0.0", + "moment": "^2.25.3", "react": "16.13.1", "react-dom": "16.13.1", "react-lazylog": "^4.5.2", "react-redux": "^7.2.0", "react-router": "^5.1.2", + "react-router-dom": "^5.1.2", "react-use": "^13.0.0" }, "files": [ diff --git a/plugins/circleci/src/api/index.ts b/plugins/circleci/src/api/index.ts index de76791cc5..89f9623e90 100644 --- a/plugins/circleci/src/api/index.ts +++ b/plugins/circleci/src/api/index.ts @@ -60,7 +60,6 @@ export class CircleCIApi { } async getBuild(buildNumber: number, options: CircleCIOptions) { - console.log({ buildNumber, options }); return getFullBuild(options.token, buildNumber, { circleHost: this.apiUrl, ...options.vcs, diff --git a/plugins/circleci/src/components/Layout/Layout.tsx b/plugins/circleci/src/components/Layout/Layout.tsx index 880e3f82a8..eab8ab0e88 100644 --- a/plugins/circleci/src/components/Layout/Layout.tsx +++ b/plugins/circleci/src/components/Layout/Layout.tsx @@ -25,7 +25,7 @@ export const Layout: React.FC = ({ children }) => ( pageTitleOverride="Circle CI" title={ - + Backstage Logo Circle CI } diff --git a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx index f502c7bede..dd526c1b5f 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx +++ b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx @@ -35,7 +35,6 @@ const useStyles = makeStyles({ button: { order: -1, marginRight: 0, - // FIXME: how not to hardcode this marginLeft: '-20px', }, }); @@ -51,12 +50,13 @@ export const ActionOutput: FC<{ const [messages, setMessages] = useState([]); useEffect(() => { fetch(url) - .then((res) => res.json()) - .then((actionOutput) => { - actionOutput && + .then(res => res.json()) + .then(actionOutput => { + if (typeof actionOutput !== 'undefined') { setMessages( actionOutput.map(({ message }: { message: string }) => message), ); + } }); }, [url]); diff --git a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx index 4f2e3d0239..20fe096605 100644 --- a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx +++ b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx @@ -36,20 +36,14 @@ export const SettingsPage = () => { token: tokenFromStore, owner: ownerFromStore, repo: repoFromStore, - } = useSelector( - (state: iRootState): SettingsState => - (console.log({ state }) as any) || state.settings, - ); + } = useSelector((state: iRootState): SettingsState => state.settings); - // const apiGitInfo = api.options.vcs; - // const [authed] = React.useState(false); const [token, setToken] = React.useState(() => tokenFromStore); const [owner, setOwner] = React.useState(() => ownerFromStore); const [repo, setRepo] = React.useState(() => repoFromStore); const dispatch: Dispatch = useDispatch(); - React.useEffect(() => () => console.log('Settings unmounterd'), []); React.useEffect(() => { if (tokenFromStore !== token) { setToken(tokenFromStore); @@ -95,7 +89,7 @@ export const SettingsPage = () => { value={token} fullWidth variant="outlined" - onChange={(e) => setToken(e.target.value)} + onChange={e => setToken(e.target.value)} /> @@ -105,7 +99,7 @@ export const SettingsPage = () => { label="Owner" variant="outlined" value={owner} - onChange={(e) => setOwner(e.target.value)} + onChange={e => setOwner(e.target.value)} /> @@ -115,7 +109,7 @@ export const SettingsPage = () => { fullWidth variant="outlined" value={repo} - onChange={(e) => setRepo(e.target.value)} + onChange={e => setRepo(e.target.value)} /> diff --git a/plugins/circleci/src/state/models/buildWithSteps.ts b/plugins/circleci/src/state/models/buildWithSteps.ts index a5ad4d89b3..796348f205 100644 --- a/plugins/circleci/src/state/models/buildWithSteps.ts +++ b/plugins/circleci/src/state/models/buildWithSteps.ts @@ -65,7 +65,7 @@ export const buildWithSteps = { state: iRootState, ) { try { - d; //ispatch.buildWithSteps.() + dispatch.buildWithSteps.setBuildError(null); const options = { token: state.settings.token, vcs: { @@ -77,7 +77,7 @@ export const buildWithSteps = { const build = await api.getBuild(buildId, options); dispatch.buildWithSteps.setBuild(build); } catch (e) { - console.log(e); + dispatch.buildWithSteps.setBuildError(e); } }, startPolling( diff --git a/plugins/circleci/src/state/models/builds.ts b/plugins/circleci/src/state/models/builds.ts index 57481b1d6f..6f8a30e868 100644 --- a/plugins/circleci/src/state/models/builds.ts +++ b/plugins/circleci/src/state/models/builds.ts @@ -65,7 +65,7 @@ export const builds = { async getBuilds(api: CircleCIApi, state: iRootState) { try { dispatch.builds.setGetBuildsError(null); - const builds = await api.getBuilds({ + const newBuilds = await api.getBuilds({ token: state.settings.token, vcs: { owner: state.settings.owner, @@ -73,7 +73,7 @@ export const builds = { type: GitType.GITHUB, }, }); - dispatch.builds.setBuilds(builds); + dispatch.builds.setBuilds(newBuilds); } catch (e) { dispatch.builds.setGetBuildsError(null); } diff --git a/yarn.lock b/yarn.lock index 6be455842e..236e495db6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14624,6 +14624,11 @@ moment@2.24.0: resolved "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b" integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg== +moment@^2.25.3: + version "2.25.3" + resolved "https://registry.npmjs.org/moment/-/moment-2.25.3.tgz#252ff41319cf41e47761a1a88cab30edfe9808c0" + integrity sha512-PuYv0PHxZvzc15Sp8ybUCoQ+xpyPWvjOuK72a5ovzp2LI32rJXOiIfyoFoYvG3s6EwwrdkMyWuRiEHSZRLJNdg== + morgan@^1.10.0: version "1.10.0" resolved "https://registry.npmjs.org/morgan/-/morgan-1.10.0.tgz#091778abc1fc47cd3509824653dae1faab6b17d7"