diff --git a/portal-ui/src/screens/Console/Support/ApiKeyRegister.tsx b/portal-ui/src/screens/Console/Support/ApiKeyRegister.tsx index fbbb0d313..4743747df 100644 --- a/portal-ui/src/screens/Console/Support/ApiKeyRegister.tsx +++ b/portal-ui/src/screens/Console/Support/ApiKeyRegister.tsx @@ -24,7 +24,10 @@ import RegisterHelpBox from "./RegisterHelpBox"; import { SubnetLoginRequest, SubnetLoginResponse } from "../License/types"; import api from "../../../common/api"; import { useAppDispatch } from "../../../store"; -import { setErrorSnackMessage } from "../../../systemSlice"; +import { + setErrorSnackMessage, + setServerNeedsRestart, +} from "../../../systemSlice"; import { ErrorResponseHandler } from "../../../common/types"; import { spacingUtils } from "../Common/FormComponents/common/styleLibrary"; import { Theme } from "@mui/material/styles"; @@ -66,6 +69,7 @@ const ApiKeyRegister = ({ classes, registerEndpoint }: IApiKeyRegister) => { .then((resp: SubnetLoginResponse) => { setLoading(false); if (resp && resp.registered) { + dispatch(setServerNeedsRestart(true)); navigate(IAM_PAGES.LICENSE); } }) diff --git a/portal-ui/src/screens/Console/Support/OfflineRegistration.tsx b/portal-ui/src/screens/Console/Support/OfflineRegistration.tsx index dc9396256..e61d153d7 100644 --- a/portal-ui/src/screens/Console/Support/OfflineRegistration.tsx +++ b/portal-ui/src/screens/Console/Support/OfflineRegistration.tsx @@ -26,7 +26,10 @@ import { useSelector } from "react-redux"; import CommentBoxWrapper from "../Common/FormComponents/CommentBoxWrapper/CommentBoxWrapper"; import useApi from "../Common/Hooks/useApi"; import { fetchLicenseInfo } from "./registerThunks"; -import { setErrorSnackMessage } from "../../../systemSlice"; +import { + setErrorSnackMessage, + setServerNeedsRestart, +} from "../../../systemSlice"; const OfflineRegistration = () => { const dispatch = useAppDispatch(); @@ -47,6 +50,7 @@ const OfflineRegistration = () => { const [isSaving, invokeApplyLicenseApi] = useApi( () => { dispatch(fetchLicenseInfo()); + dispatch(setServerNeedsRestart(true)); }, (err) => { dispatch(setErrorSnackMessage(err)); diff --git a/portal-ui/src/screens/Console/Support/RegisterOperator.tsx b/portal-ui/src/screens/Console/Support/RegisterOperator.tsx deleted file mode 100644 index b441df86d..000000000 --- a/portal-ui/src/screens/Console/Support/RegisterOperator.tsx +++ /dev/null @@ -1,124 +0,0 @@ -// This file is part of MinIO Console Server -// Copyright (c) 2022 MinIO, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public APIKey as published by -// the Free Software Foundation, either version 3 of the APIKey, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public APIKey for more details. -// -// You should have received a copy of the GNU Affero General Public APIKey -// along with this program. If not, see . - -import React, { Fragment, useCallback, useEffect, useState } from "react"; -import { Theme } from "@mui/material/styles"; -import createStyles from "@mui/styles/createStyles"; -import { - actionsTray, - containerForHeader, - searchField, - spacingUtils, -} from "../Common/FormComponents/common/styleLibrary"; -import withStyles from "@mui/styles/withStyles"; -import { Box } from "@mui/material"; -import PageLayout from "../Common/Layout/PageLayout"; -import api from "../../../common/api"; - -import { ErrorResponseHandler } from "../../../common/types"; - -import Tabs from "@mui/material/Tabs"; -import Tab from "@mui/material/Tab"; -import { TabPanel } from "../../shared/tabs"; -import { ClusterRegistered } from "./utils"; -import ApiKeyRegister from "./ApiKeyRegister"; -import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper"; - -interface IRegister { - classes: any; -} - -const styles = (theme: Theme) => - createStyles({ - ...actionsTray, - ...searchField, - ...spacingUtils, - ...containerForHeader, - }); - -const RegisterOperator = ({ classes }: IRegister) => { - const [apiKeyRegistered, setAPIKeyRegistered] = useState(false); - const [curTab, setCurTab] = useState(0); - - const fetchAPIKeyInfo = useCallback(() => { - api - .invoke("GET", `/api/v1/subnet/apikey/info`) - .then((res: any) => { - setAPIKeyRegistered(true); - }) - .catch((err: ErrorResponseHandler) => { - setAPIKeyRegistered(false); - }); - }, []); - - useEffect(() => { - fetchAPIKeyInfo(); - }, [fetchAPIKeyInfo]); - - const apiKeyRegistration = ( - - - {apiKeyRegistered ? ( - - ) : ( - - )} - - - ); - - return ( - - } - /> - - - , newValue: number) => { - setCurTab(newValue); - }} - indicatorColor="primary" - textColor="primary" - aria-label="cluster-tabs" - variant="scrollable" - scrollButtons="auto" - > - - - - {apiKeyRegistration} - - - - ); -}; - -export default withStyles(styles)(RegisterOperator); diff --git a/portal-ui/src/screens/Console/Support/registerThunks.ts b/portal-ui/src/screens/Console/Support/registerThunks.ts index a18e258cf..a02a8ad4b 100644 --- a/portal-ui/src/screens/Console/Support/registerThunks.ts +++ b/portal-ui/src/screens/Console/Support/registerThunks.ts @@ -35,7 +35,10 @@ import { SubnetRegisterRequest, } from "../License/types"; import { ErrorResponseHandler } from "../../../common/types"; -import { setErrorSnackMessage } from "../../../systemSlice"; +import { + setErrorSnackMessage, + setServerNeedsRestart, +} from "../../../systemSlice"; import { createAsyncThunk } from "@reduxjs/toolkit"; import { AppState } from "../../../store"; import { hasPermission } from "../../../common/SecureComponent"; @@ -104,6 +107,7 @@ export const callRegister = createAsyncThunk( .invoke("POST", "/api/v1/subnet/register", request) .then(() => { dispatch(setLoading(false)); + dispatch(setServerNeedsRestart(true)); dispatch(resetRegisterForm()); dispatch(fetchLicenseInfo()); })