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", 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 495540e4..2e711309 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, @@ -62,7 +63,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 a825825d..e0a3bd26 100644 --- a/src/app/types/mainSlice.types.ts +++ b/src/app/types/mainSlice.types.ts @@ -43,6 +43,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