Show modal to restart minio after subnet register (#2752)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 <http://www.gnu.org/APIKeys/>.
|
||||
|
||||
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<boolean>(false);
|
||||
const [curTab, setCurTab] = useState<number>(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 = (
|
||||
<Fragment>
|
||||
<Box
|
||||
sx={{
|
||||
border: "1px solid #eaeaea",
|
||||
borderRadius: "2px",
|
||||
display: "flex",
|
||||
flexFlow: "column",
|
||||
padding: "43px",
|
||||
}}
|
||||
>
|
||||
{apiKeyRegistered ? (
|
||||
<ClusterRegistered email={"Operator"} />
|
||||
) : (
|
||||
<ApiKeyRegister registerEndpoint={"/api/v1/subnet/apikey/register"} />
|
||||
)}
|
||||
</Box>
|
||||
</Fragment>
|
||||
);
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<PageHeaderWrapper
|
||||
label="Register to MinIO Subscription Network"
|
||||
actions={<React.Fragment />}
|
||||
/>
|
||||
|
||||
<PageLayout>
|
||||
<Tabs
|
||||
value={curTab}
|
||||
onChange={(e: React.ChangeEvent<{}>, newValue: number) => {
|
||||
setCurTab(newValue);
|
||||
}}
|
||||
indicatorColor="primary"
|
||||
textColor="primary"
|
||||
aria-label="cluster-tabs"
|
||||
variant="scrollable"
|
||||
scrollButtons="auto"
|
||||
>
|
||||
<Tab
|
||||
label="API Key"
|
||||
id="simple-tab-0"
|
||||
aria-controls="simple-tabpanel-1"
|
||||
/>
|
||||
</Tabs>
|
||||
<TabPanel index={0} value={curTab}>
|
||||
{apiKeyRegistration}
|
||||
</TabPanel>
|
||||
</PageLayout>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
export default withStyles(styles)(RegisterOperator);
|
||||
@@ -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());
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user