Skip to content

Commit

Permalink
Merge branch 'master' into bugfix_1395
Browse files Browse the repository at this point in the history
  • Loading branch information
MariiaNebesnova committed Jul 24, 2023
2 parents 38786b3 + 06b9be8 commit 40d9d35
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
18 changes: 11 additions & 7 deletions src/app/components/Guide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -19,10 +19,8 @@ const serverGuide = (splittedMD: Array<string>) =>

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();
Expand All @@ -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",
Expand Down Expand Up @@ -65,8 +70,7 @@ export const Guide = () => {
};

const onCheckButtonClick = async () => {
setSettingsChecking(true);
dispatch(defineServer());
dispatch(redefineServer());
};

return (
Expand Down
3 changes: 2 additions & 1 deletion src/app/main.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -62,7 +63,7 @@ const mainSlice = createSlice({
},
},
extraReducers: (builder) => {
defineServerReducer(builder), removeAllReducer(builder);
defineServerReducer(builder), redefineServerReducer(builder), removeAllReducer(builder);
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/reducers/defineServer.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AxiosResponse<BaseUrl>>, isRemote: boolean) =>
Expand Down
13 changes: 13 additions & 0 deletions src/app/reducers/redefineServer.thunk.ts
Original file line number Diff line number Diff line change
@@ -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<MainState>) => {
return builder.addCase(redefineServer.pending, (state) => {
state.backendAvailable = BackendStatus.Retry;
});
};
1 change: 1 addition & 0 deletions src/app/types/mainSlice.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.

0 comments on commit 40d9d35

Please sign in to comment.