changed option folder structure

master
Tudor Stanciu 2021-05-16 00:24:58 +03:00
parent c40c6b3881
commit 1e17dc47de
15 changed files with 70 additions and 60 deletions

View File

@ -0,0 +1,24 @@
import * as types from "./actionTypes";
import api from "./api";
import { sendHttpRequest } from "../../../redux/actions/httpActions";
export function loadForwardOptions(optionId) {
return async function(dispatch, getState) {
try {
const options = getState().options[optionId];
if (options && (options.loading || options.loaded)) return;
dispatch({ type: types.LOAD_FORWARD_OPTIONS_STARTED, id: optionId });
const data = await dispatch(
sendHttpRequest(api.getForwardOptions(optionId))
);
dispatch({
type: types.LOAD_FORWARD_OPTIONS_SUCCESS,
payload: data,
id: optionId
});
} catch (error) {
throw error;
}
};
}

View File

@ -0,0 +1,2 @@
export const LOAD_FORWARD_OPTIONS_STARTED = "LOAD_FORWARD_OPTIONS_STARTED";
export const LOAD_FORWARD_OPTIONS_SUCCESS = "LOAD_FORWARD_OPTIONS_SUCCESS";

View File

@ -0,0 +1,9 @@
import { get } from "../../../api/axiosApi";
const baseUrl = `${process.env.REVERSE_PROXY_API_URL}/server`;
const getForwardOptions = optionId =>
get(`${baseUrl}/forward-options/${optionId}`);
export default {
getForwardOptions
};

View File

@ -0,0 +1 @@
//ForwardOptions

View File

@ -11,12 +11,12 @@ import {
Tooltip
} from "@material-ui/core";
import { useTranslation } from "react-i18next";
import styles from "../../../components/common/styles/tableStyles";
import styles from "../../../../../components/common/styles/tableStyles";
import {
StyledTableCell,
StyledTableRow
} from "../../../components/common/MaterialTable";
import ActiveIcon from "../../../components/common/ActiveIcon";
} from "../../../../../components/common/MaterialTable";
import ActiveIcon from "../../../../../components/common/ActiveIcon";
import Typography from "@material-ui/core/Typography";
const useStyles = makeStyles(styles);

View File

@ -2,7 +2,7 @@ import React, { useEffect } from "react";
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import PropTypes from "prop-types";
import { loadForwardOptions } from "../actionCreators";
import { loadForwardOptions } from "../../actionCreators";
import ForwardOptionsComponent from "./ForwardOptionsComponent";
const ForwardOptionsContainer = ({ actions, forward, options }) => {

View File

@ -0,0 +1,25 @@
import * as types from "./actionTypes";
import initialState from "../../../redux/reducers/initialState";
export function optionsReducer(state = initialState.options, action) {
switch (action.type) {
case types.LOAD_FORWARD_OPTIONS_STARTED:
return {
...state,
[action.id]: { loading: true, loaded: false }
};
case types.LOAD_FORWARD_OPTIONS_SUCCESS:
return {
...state,
[action.id]: {
...action.payload,
loading: false,
loaded: true
}
};
default:
return state;
}
}

View File

@ -6,7 +6,7 @@ import { loadActiveSession } from "../actionCreators";
import { loadSessionForwards } from "../../session/actionCreators";
import { getActiveForwards } from "../selectors";
import ActiveSessionComponent from "./ActiveSessionComponent";
import ForwardOptionsDialog from "../../session/components/ForwardOptionsDialog";
import ForwardOptionsDialog from "../../forwards/options/components/simple/ForwardOptionsDialog";
const ActiveSessionContainer = ({ actions, session, forwards, domain }) => {
const [expanded, setExpanded] = useState(false);

View File

@ -34,24 +34,3 @@ export function loadSessionForwards(sessionId) {
}
};
}
export function loadForwardOptions(optionId) {
return async function(dispatch, getState) {
try {
const options = getState().options[optionId];
if (options && (options.loading || options.loaded)) return;
dispatch({ type: types.LOAD_FORWARD_OPTIONS_STARTED, id: optionId });
const data = await dispatch(
sendHttpRequest(api.getForwardOptions(optionId))
);
dispatch({
type: types.LOAD_FORWARD_OPTIONS_SUCCESS,
payload: data,
id: optionId
});
} catch (error) {
throw error;
}
};
}

View File

@ -3,6 +3,3 @@ export const LOAD_SERVER_SESSIONS_SUCCESS = "LOAD_SERVER_SESSIONS_SUCCESS";
export const LOAD_SESSION_FORWARDS_STARTED = "LOAD_SESSION_FORWARDS_STARTED";
export const LOAD_SESSION_FORWARDS_SUCCESS = "LOAD_SESSION_FORWARDS_SUCCESS";
export const LOAD_FORWARD_OPTIONS_STARTED = "LOAD_FORWARD_OPTIONS_STARTED";
export const LOAD_FORWARD_OPTIONS_SUCCESS = "LOAD_FORWARD_OPTIONS_SUCCESS";

View File

@ -5,11 +5,7 @@ const getServerSessions = () => get(`${baseUrl}/sessions`);
const getSessionForwards = sessionId =>
get(`${baseUrl}/session-forwards/${sessionId}`);
const getForwardOptions = optionId =>
get(`${baseUrl}/forward-options/${optionId}`);
export default {
getServerSessions,
getSessionForwards,
getForwardOptions
getSessionForwards
};

View File

@ -3,7 +3,7 @@ import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import PropTypes from "prop-types";
import SessionListComponent from "./SessionListComponent";
import ForwardOptionsDialog from "./ForwardOptionsDialog";
import ForwardOptionsDialog from "../../forwards/options/components/simple/ForwardOptionsDialog";
import { loadServerSessions, loadSessionForwards } from "../actionCreators";
const SessionContainer = ({ actions, sessions, forwards }) => {

View File

@ -35,26 +35,3 @@ export function forwardsReducer(state = initialState.forwards, action) {
return state;
}
}
export function optionsReducer(state = initialState.options, action) {
switch (action.type) {
case types.LOAD_FORWARD_OPTIONS_STARTED:
return {
...state,
[action.id]: { loading: true, loaded: false }
};
case types.LOAD_FORWARD_OPTIONS_SUCCESS:
return {
...state,
[action.id]: {
...action.payload,
loading: false,
loaded: true
}
};
default:
return state;
}
}

View File

@ -3,9 +3,9 @@ import ajaxStatusReducer from "./ajaxStatusReducer";
import serverReducer from "../../features/server/reducer";
import {
sessionsReducer,
forwardsReducer,
optionsReducer
forwardsReducer
} from "../../features/session/reducers";
import { optionsReducer } from "../../features/forwards/options/reducers";
import releaseNotesReducer from "../../features/releaseNotes/reducer";
import frontendSessionReducer from "../../features/frontendSession/reducer";
import snackbarReducer from "../../features/snackbar/reducer";