From 7242c1b15552c9c21b70fda9e8a9c190375d1310 Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Fri, 8 May 2020 15:10:15 +0200 Subject: [PATCH 1/5] Fix linting --- plugins/circleci/src/App.tsx | 15 +++++++++ .../circleci/src/components/Layout/Layout.tsx | 15 +++++++++ .../circleci/src/components/Layout/index.ts | 15 +++++++++ .../components/PluginHeader/PluginHeader.tsx | 15 +++++++++ .../src/components/PluginHeader/index.ts | 15 +++++++++ .../src/pages/BuildsPage/BuildsPage.tsx | 15 +++++++++ .../circleci/src/pages/BuildsPage/index.ts | 15 +++++++++ .../pages/BuildsPage/lib/Builds/Builds.tsx | 15 +++++++++ .../src/pages/BuildsPage/lib/Builds/index.ts | 15 +++++++++ .../pages/BuildsPage/lib/CITable/CITable.tsx | 17 +++++++++- .../src/pages/BuildsPage/lib/CITable/index.ts | 15 +++++++++ .../DetailedViewPage/DetailedViewPage.tsx | 17 +++++++++- .../src/pages/DetailedViewPage/index.ts | 15 +++++++++ .../lib/ActionOutput/ActionOutput.tsx | 15 +++++++++ .../lib/ActionOutput/index.ts | 15 +++++++++ .../src/pages/SettingsPage/SettingsPage.tsx | 17 +++++++++- .../circleci/src/pages/SettingsPage/index.ts | 15 +++++++++ plugins/circleci/src/proxy.ts | 15 +++++++++ .../src/state/models/buildWithSteps.ts | 21 +++++++++++++ plugins/circleci/src/state/models/builds.ts | 31 +++++++++++++++++-- plugins/circleci/src/state/models/index.ts | 15 +++++++++ plugins/circleci/src/state/models/settings.ts | 21 ++++++++++++- plugins/circleci/src/state/store.ts | 15 +++++++++ 23 files changed, 373 insertions(+), 6 deletions(-) diff --git a/plugins/circleci/src/App.tsx b/plugins/circleci/src/App.tsx index 111989405f..eddb9556ad 100644 --- a/plugins/circleci/src/App.tsx +++ b/plugins/circleci/src/App.tsx @@ -1,3 +1,18 @@ +/* + * 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, Switch } from 'react-router'; import { Provider, useDispatch } from 'react-redux'; diff --git a/plugins/circleci/src/components/Layout/Layout.tsx b/plugins/circleci/src/components/Layout/Layout.tsx index 4ddf4b7c90..880e3f82a8 100644 --- a/plugins/circleci/src/components/Layout/Layout.tsx +++ b/plugins/circleci/src/components/Layout/Layout.tsx @@ -1,3 +1,18 @@ +/* + * 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'; // @ts-ignore diff --git a/plugins/circleci/src/components/Layout/index.ts b/plugins/circleci/src/components/Layout/index.ts index 9877e7f4ae..236fc98851 100644 --- a/plugins/circleci/src/components/Layout/index.ts +++ b/plugins/circleci/src/components/Layout/index.ts @@ -1 +1,16 @@ +/* + * 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/circleci/src/components/PluginHeader/PluginHeader.tsx b/plugins/circleci/src/components/PluginHeader/PluginHeader.tsx index 9676f86e42..b65683f4f8 100644 --- a/plugins/circleci/src/components/PluginHeader/PluginHeader.tsx +++ b/plugins/circleci/src/components/PluginHeader/PluginHeader.tsx @@ -1,3 +1,18 @@ +/* + * 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, { FC } from 'react'; import { Link as RouterLink, useLocation } from 'react-router-dom'; import { ContentHeader, SupportButton } from '@backstage/core'; diff --git a/plugins/circleci/src/components/PluginHeader/index.ts b/plugins/circleci/src/components/PluginHeader/index.ts index e9231f1318..4de972f6f2 100644 --- a/plugins/circleci/src/components/PluginHeader/index.ts +++ b/plugins/circleci/src/components/PluginHeader/index.ts @@ -1 +1,16 @@ +/* + * 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 './PluginHeader'; diff --git a/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx b/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx index 6c1c3f0638..70722ae487 100644 --- a/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx +++ b/plugins/circleci/src/pages/BuildsPage/BuildsPage.tsx @@ -1,3 +1,18 @@ +/* + * 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, { FC } from 'react'; import { Content } from '@backstage/core'; import { Grid } from '@material-ui/core'; diff --git a/plugins/circleci/src/pages/BuildsPage/index.ts b/plugins/circleci/src/pages/BuildsPage/index.ts index 94086cd569..bb9de5d696 100644 --- a/plugins/circleci/src/pages/BuildsPage/index.ts +++ b/plugins/circleci/src/pages/BuildsPage/index.ts @@ -1 +1,16 @@ +/* + * 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 './BuildsPage'; diff --git a/plugins/circleci/src/pages/BuildsPage/lib/Builds/Builds.tsx b/plugins/circleci/src/pages/BuildsPage/lib/Builds/Builds.tsx index ebf4e37300..97227d5342 100644 --- a/plugins/circleci/src/pages/BuildsPage/lib/Builds/Builds.tsx +++ b/plugins/circleci/src/pages/BuildsPage/lib/Builds/Builds.tsx @@ -1,3 +1,18 @@ +/* + * 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. + */ /* * Copyright 2020 Spotify AB * diff --git a/plugins/circleci/src/pages/BuildsPage/lib/Builds/index.ts b/plugins/circleci/src/pages/BuildsPage/lib/Builds/index.ts index c2649d7919..e91a9496b7 100644 --- a/plugins/circleci/src/pages/BuildsPage/lib/Builds/index.ts +++ b/plugins/circleci/src/pages/BuildsPage/lib/Builds/index.ts @@ -1 +1,16 @@ +/* + * 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 { Builds } from './Builds'; diff --git a/plugins/circleci/src/pages/BuildsPage/lib/CITable/CITable.tsx b/plugins/circleci/src/pages/BuildsPage/lib/CITable/CITable.tsx index cf4fd74b81..8be304e873 100644 --- a/plugins/circleci/src/pages/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/circleci/src/pages/BuildsPage/lib/CITable/CITable.tsx @@ -1,3 +1,18 @@ +/* + * 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, { FC } from 'react'; import { Link, Typography, Box, IconButton } from '@material-ui/core'; import { Replay as RetryIcon, GitHub as GithubIcon } from '@material-ui/icons'; @@ -29,7 +44,7 @@ export type CITableBuildInfo = { passed: number; skipped: number; failed: number; - testUrl: string; //fixme better name + testUrl: string; // fixme better name }; onRetryClick: () => void; }; diff --git a/plugins/circleci/src/pages/BuildsPage/lib/CITable/index.ts b/plugins/circleci/src/pages/BuildsPage/lib/CITable/index.ts index 279634bce6..600d6d689f 100644 --- a/plugins/circleci/src/pages/BuildsPage/lib/CITable/index.ts +++ b/plugins/circleci/src/pages/BuildsPage/lib/CITable/index.ts @@ -1 +1,16 @@ +/* + * 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 { CITable, CITableBuildInfo } from './CITable'; diff --git a/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx b/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx index 297936b765..0a0c90c649 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx +++ b/plugins/circleci/src/pages/DetailedViewPage/DetailedViewPage.tsx @@ -1,3 +1,18 @@ +/* + * 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, { FC } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; @@ -72,7 +87,7 @@ const pickClassName = ( return classes.neutral; }; export const DetailedViewPage: FC<{}> = () => { - let { buildId = '' } = useParams(); + const { buildId = '' } = useParams(); const classes = useStyles(); const dispatch: Dispatch = useDispatch(); const api = useApi(circleCIApiRef); diff --git a/plugins/circleci/src/pages/DetailedViewPage/index.ts b/plugins/circleci/src/pages/DetailedViewPage/index.ts index 578eec4e64..62bbabbfe5 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/index.ts +++ b/plugins/circleci/src/pages/DetailedViewPage/index.ts @@ -1 +1,16 @@ +/* + * 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 './DetailedViewPage'; diff --git a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx index 03bf984835..f502c7bede 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx +++ b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/ActionOutput.tsx @@ -1,3 +1,18 @@ +/* + * 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, { useEffect, useState, FC, Suspense } from 'react'; import { ExpansionPanel, diff --git a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/index.ts b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/index.ts index 1e4fd5dfac..7cf74c73f8 100644 --- a/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/index.ts +++ b/plugins/circleci/src/pages/DetailedViewPage/lib/ActionOutput/index.ts @@ -1 +1,16 @@ +/* + * 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 { ActionOutput } from './ActionOutput'; diff --git a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx index 155669737a..4f2e3d0239 100644 --- a/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx +++ b/plugins/circleci/src/pages/SettingsPage/SettingsPage.tsx @@ -1,3 +1,18 @@ +/* + * 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, { useState } from 'react'; import { useSelector, useDispatch } from 'react-redux'; import { @@ -60,7 +75,7 @@ export const SettingsPage = () => { title={ <> Project Credentials - {/*{authed ? : } */} + {/* {authed ? : } */} ; pollingIntervalId: number | null; pollingState: PollingState; + getBuildError: Error | null; }; const INTERVAL_AMOUNT = 1500; @@ -19,6 +35,7 @@ export const buildWithSteps = { builds: {}, pollingIntervalId: null, pollingState: PollingState.Idle, + getBuildError: null, } as BuildState, reducers: { setBuild(state: BuildState, payload: BuildWithSteps) { @@ -30,6 +47,9 @@ export const buildWithSteps = { builds: { ...state.builds, [payload.build_num!]: payload }, }; }, + setBuildError(state: BuildState, payload: Error | null) { + return { ...state, getBuildError: payload }; + }, setPollingIntervalId(state: BuildState, payload: number | null) { return { ...state, @@ -45,6 +65,7 @@ export const buildWithSteps = { state: iRootState, ) { try { + d; //ispatch.buildWithSteps.() const options = { token: state.settings.token, vcs: { diff --git a/plugins/circleci/src/state/models/builds.ts b/plugins/circleci/src/state/models/builds.ts index 8d5f9727d6..57481b1d6f 100644 --- a/plugins/circleci/src/state/models/builds.ts +++ b/plugins/circleci/src/state/models/builds.ts @@ -1,3 +1,18 @@ +/* + * 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 { Dispatch, iRootState } from '../store'; import { BuildSummary, GitType } from 'circleci-api'; import { CircleCIApi } from '../../api'; @@ -6,6 +21,8 @@ export type BuildsState = { builds: BuildSummary[]; pollingIntervalId: number | null; pollingState: PollingState; + restartBuildError: Error | null; + getBuildsError: Error | null; }; const INTERVAL_AMOUNT = 1500; @@ -19,6 +36,8 @@ export const builds = { builds: [] as BuildSummary[], pollingIntervalId: null, pollingState: PollingState.Idle, + restartBuildError: null, + getBuildsError: null, }, reducers: { setBuilds(state: BuildsState, payload: BuildSummary[]) { @@ -35,10 +54,17 @@ export const builds = { payload === null ? PollingState.Idle : PollingState.Polling, }; }, + setRestartBuildError(state: BuildsState, payload: Error | null) { + return { ...state, restartBuildError: payload }; + }, + setGetBuildsError(state: BuildsState, payload: Error | null) { + return { ...state, getBuildsError: payload }; + }, }, effects: (dispatch: Dispatch) => ({ async getBuilds(api: CircleCIApi, state: iRootState) { try { + dispatch.builds.setGetBuildsError(null); const builds = await api.getBuilds({ token: state.settings.token, vcs: { @@ -49,7 +75,7 @@ export const builds = { }); dispatch.builds.setBuilds(builds); } catch (e) { - console.log(e); + dispatch.builds.setGetBuildsError(null); } }, async restartBuild( @@ -57,6 +83,7 @@ export const builds = { state: iRootState, ) { try { + dispatch.builds.setRestartBuildError(null); await api.retry(buildId, { token: state.settings.token, vcs: { @@ -66,7 +93,7 @@ export const builds = { }, }); } catch (e) { - console.log(e); + dispatch.builds.setRestartBuildError(e); } }, diff --git a/plugins/circleci/src/state/models/index.ts b/plugins/circleci/src/state/models/index.ts index ff1396d97d..44c87dcc3b 100644 --- a/plugins/circleci/src/state/models/index.ts +++ b/plugins/circleci/src/state/models/index.ts @@ -1,3 +1,18 @@ +/* + * 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 { settings } from './settings'; import { builds } from './builds'; import { buildWithSteps } from './buildWithSteps'; diff --git a/plugins/circleci/src/state/models/settings.ts b/plugins/circleci/src/state/models/settings.ts index dda4f86cfa..49b261852a 100644 --- a/plugins/circleci/src/state/models/settings.ts +++ b/plugins/circleci/src/state/models/settings.ts @@ -1,3 +1,18 @@ +/* + * 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 { Dispatch, iRootState } from '../store'; import { circleCIApiRef } from '../../api'; @@ -30,11 +45,15 @@ export const settings = { }: SettingsState & { doPersist: boolean }) { if (doPersist) dispatch.settings.persist(credentials); }, + setRehydrateError(state: SettingsState, payload: Error | null) { + return { ...state, rehydrateError: payload }; + }, persist(credentials: SettingsState) { sessionStorage.setItem(STORAGE_KEY, JSON.stringify(credentials)); }, rehydrate(_: any, state: iRootState) { try { + dispatch.settings.setRehydrateError(null); const stateFromStorage = JSON.parse( sessionStorage.getItem(STORAGE_KEY)!, ); @@ -49,7 +68,7 @@ export const settings = { doPersist: false, }); } catch (e) { - console.log(e); + dispatch.settings.setRehydrateError(e); } }, }), diff --git a/plugins/circleci/src/state/store.ts b/plugins/circleci/src/state/store.ts index 43b447bf9c..503a2e9b73 100644 --- a/plugins/circleci/src/state/store.ts +++ b/plugins/circleci/src/state/store.ts @@ -1,3 +1,18 @@ +/* + * 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 { init, RematchRootState, RematchDispatch } from '@rematch/core'; import { models, RootModel } from './models'; From 158c38b850cb73896595c070f42b33d183e9f044 Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Fri, 8 May 2020 15:19:36 +0200 Subject: [PATCH 2/5] Fix linting --- plugins/circleci/package.json | 2 ++ plugins/circleci/src/api/index.ts | 1 - plugins/circleci/src/components/Layout/Layout.tsx | 2 +- .../lib/ActionOutput/ActionOutput.tsx | 8 ++++---- .../src/pages/SettingsPage/SettingsPage.tsx | 14 ++++---------- .../circleci/src/state/models/buildWithSteps.ts | 4 ++-- plugins/circleci/src/state/models/builds.ts | 4 ++-- yarn.lock | 5 +++++ 8 files changed, 20 insertions(+), 20 deletions(-) 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" From d182818081c1270441289b4f395ce751582cd451 Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Fri, 8 May 2020 15:41:27 +0200 Subject: [PATCH 3/5] Fix linting --- packages/app/package.json | 3 ++- packages/app/src/setupProxy.js | 15 +++++++++++++++ yarn.lock | 15 +++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index 0ab288fcca..d04031181e 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -17,6 +17,7 @@ "@material-ui/core": "^4.9.1", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.45", + "http-proxy-middleware": "^1.0.3", "prop-types": "^15.7.2", "react": "^16.12.0", "react-dom": "^16.12.0", @@ -26,11 +27,11 @@ }, "devDependencies": { "@testing-library/cypress": "^6.0.0", - "@types/jquery": "^3.3.34", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", "@testing-library/user-event": "^7.1.2", "@types/jest": "^24.0.0", + "@types/jquery": "^3.3.34", "@types/node": "^12.0.0", "@types/react-router-dom": "^5.1.3", "@types/zen-observable": "^0.8.0", diff --git a/packages/app/src/setupProxy.js b/packages/app/src/setupProxy.js index 38cb098a03..cf15313f27 100644 --- a/packages/app/src/setupProxy.js +++ b/packages/app/src/setupProxy.js @@ -1,3 +1,18 @@ +/* + * 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. + */ const createProxyMiddleware = require('http-proxy-middleware'); // FIXME: somehow get it from within the plugin itself? diff --git a/yarn.lock b/yarn.lock index 236e495db6..002974ad40 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4128,7 +4128,7 @@ "@types/http-proxy" "*" "@types/node" "*" -"@types/http-proxy@*": +"@types/http-proxy@*", "@types/http-proxy@^1.17.3": version "1.17.4" resolved "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b" integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q== @@ -11078,7 +11078,18 @@ http-proxy-middleware@0.19.1: lodash "^4.17.11" micromatch "^3.1.10" -http-proxy@^1.17.0: +http-proxy-middleware@^1.0.3: + version "1.0.3" + resolved "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-1.0.3.tgz#f73daad8dac622d51fe1769960c914b9b1f75a72" + integrity sha512-GHvPeBD+A357zS5tHjzj6ISrVOjjCiy0I92bdyTJz0pNmIjFxO0NX/bX+xkGgnclKQE/5hHAB9JEQ7u9Pw4olg== + dependencies: + "@types/http-proxy" "^1.17.3" + http-proxy "^1.18.0" + is-glob "^4.0.1" + lodash "^4.17.15" + micromatch "^4.0.2" + +http-proxy@^1.17.0, http-proxy@^1.18.0: version "1.18.0" resolved "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a" integrity sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ== From f3c42578c4c484338fb72655d298cfb953158825 Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Fri, 8 May 2020 15:59:50 +0200 Subject: [PATCH 4/5] Fix linting --- packages/app/package.json | 2 +- packages/app/src/setupProxy.js | 1 + yarn.lock | 15 ++------------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/app/package.json b/packages/app/package.json index d04031181e..47f553a98b 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -17,7 +17,7 @@ "@material-ui/core": "^4.9.1", "@material-ui/icons": "^4.9.1", "@material-ui/lab": "4.0.0-alpha.45", - "http-proxy-middleware": "^1.0.3", + "@types/http-proxy": "^1.17.4", "prop-types": "^15.7.2", "react": "^16.12.0", "react-dom": "^16.12.0", diff --git a/packages/app/src/setupProxy.js b/packages/app/src/setupProxy.js index cf15313f27..68ab231e89 100644 --- a/packages/app/src/setupProxy.js +++ b/packages/app/src/setupProxy.js @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +// eslint-disable-next-line const createProxyMiddleware = require('http-proxy-middleware'); // FIXME: somehow get it from within the plugin itself? diff --git a/yarn.lock b/yarn.lock index 002974ad40..6818944223 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4128,7 +4128,7 @@ "@types/http-proxy" "*" "@types/node" "*" -"@types/http-proxy@*", "@types/http-proxy@^1.17.3": +"@types/http-proxy@*", "@types/http-proxy@^1.17.4": version "1.17.4" resolved "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.4.tgz#e7c92e3dbe3e13aa799440ff42e6d3a17a9d045b" integrity sha512-IrSHl2u6AWXduUaDLqYpt45tLVCtYv7o4Z0s1KghBCDgIIS9oW5K1H8mZG/A2CfeLdEa7rTd1ACOiHBc1EMT2Q== @@ -11078,18 +11078,7 @@ http-proxy-middleware@0.19.1: lodash "^4.17.11" micromatch "^3.1.10" -http-proxy-middleware@^1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-1.0.3.tgz#f73daad8dac622d51fe1769960c914b9b1f75a72" - integrity sha512-GHvPeBD+A357zS5tHjzj6ISrVOjjCiy0I92bdyTJz0pNmIjFxO0NX/bX+xkGgnclKQE/5hHAB9JEQ7u9Pw4olg== - dependencies: - "@types/http-proxy" "^1.17.3" - http-proxy "^1.18.0" - is-glob "^4.0.1" - lodash "^4.17.15" - micromatch "^4.0.2" - -http-proxy@^1.17.0, http-proxy@^1.18.0: +http-proxy@^1.17.0: version "1.18.0" resolved "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.0.tgz#dbe55f63e75a347db7f3d99974f2692a314a6a3a" integrity sha512-84I2iJM/n1d4Hdgc6y2+qY5mDaz2PUVjlg9znE9byl+q0uC3DeByqBGReQu5tpLK0TAqTIXScRUV+dg7+bUPpQ== From 520503b85c3c315fbd2259a7782a32f29aaf40b5 Mon Sep 17 00:00:00 2001 From: Nikita Nek Dudnik Date: Fri, 8 May 2020 16:34:07 +0200 Subject: [PATCH 5/5] Fix tests failing on image import --- package.json | 1 + packages/cli/config/jest.js | 1 + yarn.lock | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f7eb2c5f5..6459abcc5e 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "devDependencies": { "@spotify/eslint-config-oss": "^1.0.1", "husky": "^4.2.3", + "identity-obj-proxy": "^3.0.0", "lerna": "^3.20.2", "lint-staged": "^10.1.0", "prettier": "^2.0.5" diff --git a/packages/cli/config/jest.js b/packages/cli/config/jest.js index 77f345a0dd..7f5f05b212 100644 --- a/packages/cli/config/jest.js +++ b/packages/cli/config/jest.js @@ -28,6 +28,7 @@ if (fs.existsSync('jest.config.js')) { modulePaths: [''], moduleNameMapper: { '\\.(css|less|scss|sss|styl)$': require.resolve('jest-css-modules'), + '.+\\.(png|jpg|ttf|woff|woff2)$': 'identity-obj-proxy', }, // We build .esm.js files with plugin:build, so to be able to load these in tests they need to be transformed // TODO: jest is working on module support, it's possible that we can remove this in the future diff --git a/yarn.lock b/yarn.lock index 6818944223..b8f62a16a3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11169,7 +11169,7 @@ icss-utils@^4.0.0, icss-utils@^4.1.1: dependencies: postcss "^7.0.14" -identity-obj-proxy@3.0.0: +identity-obj-proxy@3.0.0, identity-obj-proxy@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/identity-obj-proxy/-/identity-obj-proxy-3.0.0.tgz#94d2bda96084453ef36fbc5aaec37e0f79f1fc14" integrity sha1-lNK9qWCERT7zb7xarsN+D3nx/BQ=