From e29633c333c75551953b99f83f590bc0a7393d87 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Wed, 19 Jul 2023 16:11:16 +0300 Subject: [PATCH 1/3] improve versions errors handling --- src/app/components/Guide.tsx | 18 +++++++++++------- src/app/main.slice.ts | 3 ++- src/app/reducers/defineServer.thunk.ts | 2 +- src/app/reducers/redefineServer.thunk.ts | 13 +++++++++++++ src/app/types/mainSlice.types.ts | 1 + .../utils}/compatibleVersions.ts | 0 6 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 src/app/reducers/redefineServer.thunk.ts rename src/{common/constants => app/utils}/compatibleVersions.ts (100%) diff --git a/src/app/components/Guide.tsx b/src/app/components/Guide.tsx index 74e0d0df..12aa8386 100644 --- a/src/app/components/Guide.tsx +++ b/src/app/components/Guide.tsx @@ -7,8 +7,8 @@ import { useDispatch, useSelector } from "react-redux"; import readme from "../../../README.md"; import { BackendStatus } from "../types/mainSlice.types"; import { RootState } from "../store/store"; -import { defineServer } from "../reducers/defineServer.thunk"; import { useGuideRehype } from "../utils/useGuideRehype"; +import { redefineServer } from "../reducers/redefineServer.thunk"; const splitMD = (source: string) => source.match(/^#+ [^#]*/gm); @@ -19,10 +19,8 @@ const serverGuide = (splittedMD: Array) => export const Guide = () => { const backendStatus = useSelector((_state: RootState) => _state.main.backendAvailable); - const step = - backendStatus === BackendStatus.OutdatedServerLocal || backendStatus === BackendStatus.AccessFailed ? 1 : 0; - const [isSettingsChecking, setSettingsChecking] = useState(false); - const [currentStep, setCurrentStep] = useState(step); + const isSettingsChecking = backendStatus === BackendStatus.Retry; + const [currentStep, setCurrentStep] = useState(0); const [pluginGuideComponent, setPluginGuide] = useGuideRehype(); const [serverGuideComponent, setServerGuide] = useGuideRehype(); const dispatch = useDispatch(); @@ -34,6 +32,13 @@ export const Guide = () => { setServerGuide(serverGuide(splittedMD)); }, []); + useEffect(() => { + if (backendStatus === BackendStatus.Retry) return; + const _step = + backendStatus === BackendStatus.OutdatedServerLocal || backendStatus === BackendStatus.AccessFailed ? 1 : 0; + setCurrentStep(_step); + }, [backendStatus]); + const steps = [ { title: "Step 1", @@ -65,8 +70,7 @@ export const Guide = () => { }; const onCheckButtonClick = async () => { - setSettingsChecking(true); - dispatch(defineServer()); + dispatch(redefineServer()); }; return ( diff --git a/src/app/main.slice.ts b/src/app/main.slice.ts index 097fe346..51d394e3 100644 --- a/src/app/main.slice.ts +++ b/src/app/main.slice.ts @@ -3,6 +3,7 @@ import { defineServerReducer } from "./reducers/defineServer.thunk"; import { PageObjectId } from "../features/pageObjects/types/pageObjectSlice.types"; import { BackendStatus, MainState, Notification, PageType } from "./types/mainSlice.types"; import { removeAllReducer } from "./reducers/removeAll.thunk"; +import { redefineServerReducer } from "./reducers/redefineServer.thunk"; const initialState: MainState = { backendAvailable: BackendStatus.TryToAccess, @@ -58,7 +59,7 @@ const mainSlice = createSlice({ }, }, extraReducers: (builder) => { - defineServerReducer(builder), removeAllReducer(builder); + defineServerReducer(builder), redefineServerReducer(builder), removeAllReducer(builder); }, }); diff --git a/src/app/reducers/defineServer.thunk.ts b/src/app/reducers/defineServer.thunk.ts index 02694fbc..f886ac2b 100644 --- a/src/app/reducers/defineServer.thunk.ts +++ b/src/app/reducers/defineServer.thunk.ts @@ -4,7 +4,7 @@ import { toInteger } from "lodash"; import { BackendStatus, BaseUrl, MainState } from "../types/mainSlice.types"; import { LocalUrl, RemoteUrl } from "../utils/constants"; import { HttpEndpoint, request } from "../../services/backend"; -import { compatibleBuildVer, compatibleMajorVer, compatibleMinorVer } from "../../common/constants/compatibleVersions"; +import { compatibleBuildVer, compatibleMajorVer, compatibleMinorVer } from "../utils/compatibleVersions"; export const defineServer = createAsyncThunk("main/defineServer", async () => { const checkVersion = (request: Promise>, isRemote: boolean) => diff --git a/src/app/reducers/redefineServer.thunk.ts b/src/app/reducers/redefineServer.thunk.ts new file mode 100644 index 00000000..fc714c1f --- /dev/null +++ b/src/app/reducers/redefineServer.thunk.ts @@ -0,0 +1,13 @@ +import { ActionReducerMapBuilder, createAsyncThunk } from "@reduxjs/toolkit"; +import { BackendStatus, MainState } from "../types/mainSlice.types"; +import { defineServer } from "./defineServer.thunk"; + +export const redefineServer = createAsyncThunk("main/redefineServer", async (_, thunkApi) => { + thunkApi.dispatch(defineServer()); +}); + +export const redefineServerReducer = (builder: ActionReducerMapBuilder) => { + return builder.addCase(redefineServer.pending, (state) => { + state.backendAvailable = BackendStatus.Retry; + }); +}; diff --git a/src/app/types/mainSlice.types.ts b/src/app/types/mainSlice.types.ts index 03c51c46..d8bd6594 100644 --- a/src/app/types/mainSlice.types.ts +++ b/src/app/types/mainSlice.types.ts @@ -42,6 +42,7 @@ export enum BackendStatus { OutdatedPluginLocal = "Plugin version need to be updated.", IncompatibleVersionRemote = "Remote server version is incompatible. Please, update plugin", IncompatibleVersions = "Remote and local server versions are incompatible. Please, update plugin or local server, or try to connect the remote server.", + Retry = "Retrying...", } export enum PageType { diff --git a/src/common/constants/compatibleVersions.ts b/src/app/utils/compatibleVersions.ts similarity index 100% rename from src/common/constants/compatibleVersions.ts rename to src/app/utils/compatibleVersions.ts From fb6368efc2b8468e18e540fc14114d59e807474e Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Mon, 24 Jul 2023 12:13:27 +0300 Subject: [PATCH 2/3] ver up --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index ede2cb1b..779aee09 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN", "description": "JDN – helps Test Automation Engineer to create Page Objects in the test automation framework and speed up test development", "devtools_page": "index.html", - "version": "3.13.528", + "version": "3.13.529", "icons": { "128": "icon128.png" }, diff --git a/package.json b/package.json index 21c40d9f..5b9305fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.13.528", + "version": "3.13.529", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv", From 4c062ad8062040261e30b258893a669cd4030826 Mon Sep 17 00:00:00 2001 From: MariiaNebesnova Date: Mon, 24 Jul 2023 12:15:35 +0300 Subject: [PATCH 3/3] ver up --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 779aee09..f68f8377 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "JDN", "description": "JDN – helps Test Automation Engineer to create Page Objects in the test automation framework and speed up test development", "devtools_page": "index.html", - "version": "3.13.529", + "version": "3.13.530", "icons": { "128": "icon128.png" }, diff --git a/package.json b/package.json index 5b9305fb..19885e98 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jdn-ai-chrome-extension", - "version": "3.13.529", + "version": "3.13.530", "description": "jdn-ai chrome extension", "scripts": { "start": "webpack --watch --env devenv",