Show Credentials after adding tenant (#599)

* Show Credentials after adding tenant

* assets

* Change order of routing
This commit is contained in:
Daniel Valdivia
2021-02-10 21:09:35 -08:00
committed by GitHub
parent 940c7dc5bc
commit f958b73e48
3 changed files with 340 additions and 319 deletions

File diff suppressed because one or more lines are too long

View File

@@ -290,14 +290,14 @@ const Console = ({
component: WebhookPanel,
path: "/webhook/audit",
},
{
component: AddTenant,
path: "/add-tenant",
},
{
component: ListTenants,
path: "/tenants",
},
{
component: AddTenant,
path: "/add-tenant",
},
{
component: TenantDetails,
path: "/namespaces/:tenantNamespace/tenants/:tenantName",

View File

@@ -72,6 +72,7 @@ import { setModalErrorSnackMessage } from "../../../../actions";
import { getHardcodedAffinity } from "../TenantDetails/utils";
import history from "../../../../history";
import PageHeader from "../../Common/PageHeader/PageHeader";
import CredentialsPrompt from "../../Common/CredentialsPrompt/CredentialsPrompt";
interface IAddTenantProps {
open: boolean;
@@ -140,6 +141,13 @@ const styles = (theme: Theme) =>
});
const AddTenant = ({ classes }: IAddTenantProps) => {
// Modals
const [showNewCredentials, setShowNewCredentials] = useState<boolean>(false);
const [
createdAccount,
setCreatedAccount,
] = useState<NewServiceAccount | null>(null);
// Fields
const [addSending, setAddSending] = useState<boolean>(false);
const [tenantName, setTenantName] = useState<string>("");
@@ -292,6 +300,10 @@ const AddTenant = ({ classes }: IAddTenantProps) => {
const [vaultCAVal, setVaultCAVal] = useState<string>("");
const [gemaltoCAVal, setGemaltoCAVal] = useState<string>("");
// Flow
const showCredentialsAndRedirect = () => {};
// CA Certificates functions
const addCaCertificate = () => {
setCaCertificates((currentCertificates) => [
@@ -1225,7 +1237,9 @@ const AddTenant = ({ classes }: IAddTenantProps) => {
};
setAddSending(false);
history.push("/tenants");
setShowNewCredentials(true);
setCreatedAccount(newSrvAcc);
})
.catch((err) => {
setAddSending(false);
@@ -2831,6 +2845,10 @@ const AddTenant = ({ classes }: IAddTenantProps) => {
filteredWizardSteps = wizardSteps.filter((step) => !step.advancedOnly);
}
const closeCredentialsModal = () => {
history.push("/tenants");
};
return (
<React.Fragment>
{addSending && (
@@ -2838,6 +2856,16 @@ const AddTenant = ({ classes }: IAddTenantProps) => {
<LinearProgress />
</Grid>
)}
{showNewCredentials && (
<CredentialsPrompt
newServiceAccount={createdAccount}
open={showNewCredentials}
closeModal={() => {
closeCredentialsModal();
}}
entity="Tenant"
/>
)}
<PageHeader label={"Add Tenant"} />
<Grid container>
<Grid item xs={12} className={classes.container}>