Move New Credentials to separate component for Add Tenant (#2056)

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2022-05-31 17:28:50 -07:00
committed by GitHub
parent d3b1be80eb
commit dec7b138e9
3 changed files with 54 additions and 25 deletions

View File

@@ -32,7 +32,6 @@ import {
IWizardButton,
IWizardElement,
} from "../../Common/GenericWizard/types";
import CredentialsPrompt from "../../Common/CredentialsPrompt/CredentialsPrompt";
import { AppState } from "../../../../store";
import Configure from "./Steps/Configure";
import IdentityProvider from "./Steps/IdentityProvider";
@@ -57,6 +56,7 @@ import { selFeatures } from "../../consoleSlice";
import makeStyles from "@mui/styles/makeStyles";
import { resetAddTenantForm } from "./createTenantSlice";
import CreateTenantButton from "./CreateTenantButton";
import NewTenantCredentials from "./NewTenantCredentials";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@@ -75,14 +75,6 @@ const AddTenant = () => {
const features = useSelector(selFeatures);
// Modals
const showNewCredentials = useSelector(
(state: AppState) => state.createTenant.showNewCredentials
);
const createdAccount = useSelector(
(state: AppState) => state.createTenant.createdAccount
);
// Fields
const addSending = useSelector(
(state: AppState) => state.createTenant.addingTenant
@@ -181,23 +173,9 @@ const AddTenant = () => {
let filteredWizardSteps = wizardSteps;
const closeCredentialsModal = () => {
dispatch(resetAddTenantForm());
history.push("/tenants");
};
return (
<Fragment>
{showNewCredentials && (
<CredentialsPrompt
newServiceAccount={createdAccount}
open={showNewCredentials}
closeModal={() => {
closeCredentialsModal();
}}
entity="Tenant"
/>
)}
<NewTenantCredentials />
<PageHeader
label={
<BackLink

View File

@@ -0,0 +1,51 @@
// 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 License as published by
// the Free Software Foundation, either version 3 of the License, 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 License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import React, { Fragment } from "react";
import CredentialsPrompt from "../../Common/CredentialsPrompt/CredentialsPrompt";
import { resetAddTenantForm } from "./createTenantSlice";
import history from "../../../../history";
import { useDispatch, useSelector } from "react-redux";
import { AppState } from "../../../../store";
const NewTenantCredentials = () => {
const dispatch = useDispatch();
const showNewCredentials = useSelector(
(state: AppState) => state.createTenant.showNewCredentials
);
const createdAccount = useSelector(
(state: AppState) => state.createTenant.createdAccount
);
return (
<Fragment>
{showNewCredentials && (
<CredentialsPrompt
newServiceAccount={createdAccount}
open={showNewCredentials}
closeModal={() => {
dispatch(resetAddTenantForm());
history.push("/tenants");
}}
entity="Tenant"
/>
)}
</Fragment>
);
};
export default NewTenantCredentials;

View File

@@ -89,7 +89,7 @@ export const createNamespaceAsync = createAsyncThunk(
.invoke("POST", "/api/v1/namespace", {
name: namespace,
})
.then((res) => {
.then((_) => {
// revalidate the name to have the storage classes populated
dispatch(validateNamespaceAsync());
return true;