Skip to content

Commit

Permalink
Changed useDispatch implementation to comply with TS specification (#…
Browse files Browse the repository at this point in the history
…2110)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
  • Loading branch information
bexsoft committed Jun 10, 2022
1 parent c509e5d commit df38c84
Show file tree
Hide file tree
Showing 181 changed files with 539 additions and 473 deletions.
6 changes: 3 additions & 3 deletions portal-ui/src/ProtectedRoutes.tsx
Expand Up @@ -22,7 +22,7 @@ import useApi from "./screens/Console/Common/Hooks/useApi";
import { ErrorResponseHandler } from "./common/types";
import { ReplicationSite } from "./screens/Console/Configurations/SiteReplication/SiteReplication";
import { baseUrl } from "./history";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import {
globalSetDistributedSetup,
operatorMode,
Expand All @@ -31,15 +31,15 @@ import {
userLogged,
} from "./systemSlice";
import { SRInfoStateType } from "./types";
import { AppState } from "./store";
import { AppState, useAppDispatch } from "./store";
import { saveSessionResponse } from "./screens/Console/consoleSlice";

interface ProtectedRouteProps {
Component: any;
}

const ProtectedRoute = ({ Component }: ProtectedRouteProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();

const isOperatorMode = useSelector(selOpMode);

Expand Down
5 changes: 3 additions & 2 deletions portal-ui/src/screens/Console/Account/Account.tsx
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
Expand Down Expand Up @@ -58,6 +58,7 @@ import ServiceAccountPolicy from "./ServiceAccountPolicy";
import { setErrorSnackMessage, setSnackBarMessage } from "../../../systemSlice";
import makeStyles from "@mui/styles/makeStyles";
import { selFeatures } from "../consoleSlice";
import { useAppDispatch } from "../../../store";

const DeleteServiceAccount = withSuspense(
React.lazy(() => import("./DeleteServiceAccount"))
Expand All @@ -78,7 +79,7 @@ const useStyles = makeStyles((theme: Theme) =>
);

const Account = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const navigate = useNavigate();

const classes = useStyles();
Expand Down
Expand Up @@ -48,8 +48,9 @@ import CredentialsPrompt from "../Common/CredentialsPrompt/CredentialsPrompt";
import SectionTitle from "../Common/SectionTitle";
import { getRandomString } from "../../../screens/Console/Tenants/utils";
import PanelTitle from "../Common/PanelTitle/PanelTitle";
import { useDispatch } from "react-redux";

import { setErrorSnackMessage } from "../../../systemSlice";
import { useAppDispatch } from "../../../store";

interface IAddServiceAccountProps {
classes: any;
Expand All @@ -75,7 +76,7 @@ const styles = (theme: Theme) =>
});

const AddServiceAccount = ({ classes }: IAddServiceAccountProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const navigate = useNavigate();

const [addSending, setAddSending] = useState<boolean>(false);
Expand Down
5 changes: 3 additions & 2 deletions portal-ui/src/screens/Console/Account/ChangePasswordModal.tsx
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useState } from "react";
import { useDispatch } from "react-redux";

import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
Expand All @@ -36,6 +36,7 @@ import { ChangePasswordIcon } from "../../../icons";
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
import { setModalErrorSnackMessage } from "../../../systemSlice";
import { useAppDispatch } from "../../../store";

const styles = (theme: Theme) =>
createStyles({
Expand All @@ -56,7 +57,7 @@ const ChangePassword = ({
open,
closeModal,
}: IChangePasswordProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [currentPassword, setCurrentPassword] = useState<string>("");
const [newPassword, setNewPassword] = useState<string>("");
const [reNewPassword, setReNewPassword] = useState<string>("");
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useState } from "react";
import { useDispatch } from "react-redux";

import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
Expand All @@ -35,6 +35,7 @@ import { ErrorResponseHandler } from "../../../common/types";
import api from "../../../common/api";
import { ChangePasswordIcon } from "../../../icons";
import { setModalErrorSnackMessage } from "../../../systemSlice";
import { useAppDispatch } from "../../../store";

const styles = (theme: Theme) =>
createStyles({
Expand All @@ -60,7 +61,7 @@ const ChangeUserPassword = ({
userName,
closeModal,
}: IChangeUserPasswordProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [newPassword, setNewPassword] = useState<string>("");
const [reNewPassword, setReNewPassword] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false);
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from "react";
import { useDispatch } from "react-redux";

import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
Expand All @@ -27,6 +27,7 @@ import ConfirmDialog from "../Common/ModalWrapper/ConfirmDialog";
import { ConfirmDeleteIcon } from "../../../icons";
import { encodeURLString } from "../../../common/utils";
import { setErrorSnackMessage } from "../../../systemSlice";
import { useAppDispatch } from "../../../store";

const styles = (theme: Theme) =>
createStyles({
Expand All @@ -50,7 +51,7 @@ const DeleteServiceAccount = ({
deleteOpen,
selectedServiceAccount,
}: IDeleteServiceAccountProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const onDelSuccess = () => closeDeleteModalAndRefresh(true);
const onDelError = (err: ErrorResponseHandler) =>
dispatch(setErrorSnackMessage(err));
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useEffect, useState } from "react";
import { useDispatch } from "react-redux";

import { Button } from "@mui/material";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
Expand All @@ -34,6 +34,7 @@ import { ChangeAccessPolicyIcon } from "../../../icons";
import CodeMirrorWrapper from "../Common/FormComponents/CodeMirrorWrapper/CodeMirrorWrapper";
import { encodeURLString } from "../../../common/utils";
import { setModalErrorSnackMessage } from "../../../systemSlice";
import { useAppDispatch } from "../../../store";

const styles = (theme: Theme) =>
createStyles({
Expand Down Expand Up @@ -68,7 +69,7 @@ const ServiceAccountPolicy = ({
selectedAccessKey,
closeModalAndRefresh,
}: IServiceAccountPolicyProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [loading, setLoading] = useState<boolean>(true);
const [policyDefinition, setPolicyDefinition] = useState<string>("");
useEffect(() => {
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useNavigate, useParams } from "react-router-dom";
import { Paper } from "@mui/material";
import Tabs from "@mui/material/Tabs";
Expand All @@ -40,6 +40,7 @@ import {
import { encodeURLString } from "../../../../common/utils";
import { setErrorSnackMessage } from "../../../../systemSlice";
import { selBucketDetailsLoading } from "./bucketDetailsSlice";
import { useAppDispatch } from "../../../../store";

function a11yProps(index: any) {
return {
Expand All @@ -49,7 +50,7 @@ function a11yProps(index: any) {
}

const AccessDetails = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const navigate = useNavigate();
const params = useParams();

Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useParams } from "react-router-dom";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
Expand Down Expand Up @@ -45,6 +45,7 @@ import RBIconButton from "./SummaryItems/RBIconButton";
import { setErrorSnackMessage } from "../../../../systemSlice";
import makeStyles from "@mui/styles/makeStyles";
import { selBucketDetailsLoading } from "./bucketDetailsSlice";
import { useAppDispatch } from "../../../../store";

const AddAccessRuleModal = withSuspense(
React.lazy(() => import("./AddAccessRule"))
Expand Down Expand Up @@ -75,7 +76,7 @@ const useStyles = makeStyles((theme: Theme) =>
);

const AccessRule = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const classes = useStyles();
const params = useParams();

Expand Down
Expand Up @@ -25,12 +25,13 @@ import {
formFieldStyles,
modalStyleUtils,
} from "../../Common/FormComponents/common/styleLibrary";
import { useDispatch } from "react-redux";

import api from "../../../../common/api";
import { ErrorResponseHandler } from "../../../../common/types";
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
import { AddAccessRuleIcon } from "../../../../icons";
import { setErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

interface IAddAccessRule {
classes: any;
Expand All @@ -51,7 +52,7 @@ const AddAccessRule = ({
classes,
bucket,
}: IAddAccessRule) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();

const [prefix, setPrefix] = useState("");
const [selectedAccess, setSelectedAccess] = useState<any>("readonly");
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useState } from "react";
import { useDispatch } from "react-redux";

import { Button, Grid } from "@mui/material";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
Expand All @@ -31,6 +31,7 @@ import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
import api from "../../../../common/api";
import { AddNewTagIcon } from "../../../../icons";
import { setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

interface IBucketTagModal {
modalOpen: boolean;
Expand All @@ -56,7 +57,7 @@ const AddBucketTagModal = ({

classes,
}: IBucketTagModal) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [newKey, setNewKey] = useState<string>("");
const [newLabel, setNewLabel] = useState<string>("");
const [isSending, setIsSending] = useState<boolean>(false);
Expand Down
Expand Up @@ -15,7 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { ChangeEvent, useCallback, useEffect, useState } from "react";
import { useDispatch } from "react-redux";

import Grid from "@mui/material/Grid";
import { Button } from "@mui/material";
import { Theme } from "@mui/material/styles";
Expand All @@ -40,6 +40,7 @@ import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBo
import AutocompleteWrapper from "../../Common/FormComponents/AutocompleteWrapper/AutocompleteWrapper";
import { EventSubscriptionIcon } from "../../../../icons";
import { setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

const styles = (theme: Theme) =>
createStyles({
Expand All @@ -65,7 +66,7 @@ const AddEvent = ({
selectedBucket,
closeModalAndRefresh,
}: IAddEventProps) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [addLoading, setAddLoading] = useState<boolean>(false);
const [prefix, setPrefix] = useState<string>("");
const [suffix, setSuffix] = useState<string>("");
Expand Down
Expand Up @@ -16,7 +16,7 @@

import React, { Fragment, useEffect, useState } from "react";
import get from "lodash/get";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
Expand Down Expand Up @@ -53,6 +53,7 @@ import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMe
import { BucketVersioning } from "../types";
import FormSwitchWrapper from "../../Common/FormComponents/FormSwitchWrapper/FormSwitchWrapper";
import { selDistSet, setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

interface IReplicationModal {
open: boolean;
Expand Down Expand Up @@ -98,7 +99,7 @@ const AddLifecycleModal = ({
classes,
bucketName,
}: IReplicationModal) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const distributedSetup = useSelector(selDistSet);
const [loadingTiers, setLoadingTiers] = useState<boolean>(true);
const [tiersList, setTiersList] = useState<ITiersDropDown[]>([]);
Expand Down
Expand Up @@ -39,8 +39,9 @@ import { getBytes, k8sScalarUnitsExcluding } from "../../../../common/utils";
import QueryMultiSelector from "../../Common/FormComponents/QueryMultiSelector/QueryMultiSelector";
import { BucketReplicationIcon } from "../../../../icons";
import InputUnitMenu from "../../Common/FormComponents/InputUnitMenu/InputUnitMenu";
import { useDispatch } from "react-redux";

import { setModalErrorSnackMessage } from "../../../../systemSlice";
import { useAppDispatch } from "../../../../store";

interface IReplicationModal {
open: boolean;
Expand Down Expand Up @@ -86,7 +87,7 @@ const AddReplicationModal = ({

setReplicationRules,
}: IReplicationModal) => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const [addLoading, setAddLoading] = useState<boolean>(false);
const [priority, setPriority] = useState<string>("1");
const [accessKey, setAccessKey] = useState<string>("");
Expand Down
Expand Up @@ -15,14 +15,14 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { Fragment, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useSelector } from "react-redux";
import { useNavigate, useParams } from "react-router-dom";
import { Theme } from "@mui/material/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
import { Grid, IconButton, Tooltip } from "@mui/material";
import get from "lodash/get";
import { AppState } from "../../../../store";
import { AppState, useAppDispatch } from "../../../../store";
import { containerForHeader } from "../../Common/FormComponents/common/styleLibrary";

import ListObjects from "../ListBuckets/Objects/ListObjects/ListObjects";
Expand Down Expand Up @@ -50,7 +50,7 @@ const styles = (theme: Theme) =>
});

const BrowserHandler = () => {
const dispatch = useDispatch();
const dispatch = useAppDispatch();
const navigate = useNavigate();
const params = useParams();

Expand Down

0 comments on commit df38c84

Please sign in to comment.