|
1 | 1 | import React from "react"; |
2 | | -import { createStyles, Theme, withStyles, WithStyles, Grid, Box } from "@material-ui/core"; |
| 2 | +import { createStyles, Theme, withStyles, WithStyles, Grid, Box, Button } from "@material-ui/core"; |
3 | 3 | import { connect } from "react-redux"; |
4 | 4 | import { TDispatchProp } from "types"; |
5 | 5 | import { Certificate, dns01Issuer, http01Issuer } from "types/certificate"; |
6 | 6 | import { BasePage } from "pages/BasePage"; |
7 | 7 | import { RootState } from "reducers"; |
8 | | -import { withRouter, RouteComponentProps } from "react-router-dom"; |
| 8 | +import { withRouter, RouteComponentProps, Link } from "react-router-dom"; |
9 | 9 | import { FlexRowItemCenterBox } from "widgets/Box"; |
10 | 10 | import { KPanel } from "widgets/KPanel"; |
11 | 11 | import { Alert } from "@material-ui/lab"; |
12 | | -import DomainStatus from "widgets/DomainStatus"; |
| 12 | +import DomainStatus, { acmePrefix } from "widgets/DomainStatus"; |
13 | 13 | import { Expansion } from "forms/Route/expansion"; |
14 | 14 | import { Loading } from "widgets/Loading"; |
15 | 15 | import { CollapseWrapper } from "widgets/CollapseWrapper"; |
@@ -47,7 +47,7 @@ interface State {} |
47 | 47 |
|
48 | 48 | class CertificateDetailRaw extends React.PureComponent<Props, State> { |
49 | 49 | private renderDomainGuide = (cert: Certificate | undefined) => { |
50 | | - const { classes, ingressIP } = this.props; |
| 50 | + const { classes, ingressIP, acmeServer } = this.props; |
51 | 51 | if (cert === undefined) { |
52 | 52 | return null; |
53 | 53 | } else { |
@@ -85,39 +85,61 @@ class CertificateDetailRaw extends React.PureComponent<Props, State> { |
85 | 85 | </Box> |
86 | 86 | ); |
87 | 87 | } else if (cert.get("httpsCertIssuer") === dns01Issuer) { |
88 | | - const domains = cert.get("wildcardCertDNSChallengeDomainMap"); |
89 | | - return ( |
90 | | - <Box> |
91 | | - <Box className={classes.key}>Domains</Box> |
92 | | - <Box pl={0} pt={1}> |
93 | | - {domains |
94 | | - ?.map((cname, domain) => { |
95 | | - return ( |
96 | | - <> |
97 | | - <CollapseWrapper |
98 | | - title={ |
99 | | - <FlexRowItemCenterBox> |
100 | | - <DomainStatus domain={domain} cnameDomain={cname} mr={1} /> |
101 | | - {domain} |
102 | | - </FlexRowItemCenterBox> |
103 | | - } |
104 | | - defaultOpen={true} |
105 | | - showIcon={true} |
106 | | - > |
107 | | - <Box p={1}> |
108 | | - Add a CNAME Record |
109 | | - <pre className={classes.action}> |
110 | | - {domain} CNAME {cname}{" "} |
111 | | - </pre> |
112 | | - </Box> |
113 | | - </CollapseWrapper> |
114 | | - </> |
115 | | - ); |
116 | | - }) |
117 | | - .toList()} |
| 88 | + if (!acmeServer || !acmeServer.get("ready")) { |
| 89 | + const domains = cert.get("domains"); |
| 90 | + return ( |
| 91 | + <Box> |
| 92 | + <Box className={classes.key}>Domains</Box> |
| 93 | + <Box pl={0} pt={1}> |
| 94 | + {domains |
| 95 | + ?.map((domain) => { |
| 96 | + return ( |
| 97 | + <FlexRowItemCenterBox key={domain}> |
| 98 | + <DomainStatus domain={acmePrefix + domain} cnameDomain={""} mr={1} /> |
| 99 | + {domain} |
| 100 | + </FlexRowItemCenterBox> |
| 101 | + ); |
| 102 | + }) |
| 103 | + .toList()} |
| 104 | + </Box> |
118 | 105 | </Box> |
119 | | - </Box> |
120 | | - ); |
| 106 | + ); |
| 107 | + } else { |
| 108 | + const domains = cert.get("wildcardCertDNSChallengeDomainMap"); |
| 109 | + return ( |
| 110 | + <Box> |
| 111 | + <Box className={classes.key}>Domains</Box> |
| 112 | + <Box pl={0} pt={1}> |
| 113 | + {domains |
| 114 | + ?.map((ns, domain) => { |
| 115 | + return ( |
| 116 | + <Box key={domain}> |
| 117 | + <CollapseWrapper |
| 118 | + title={ |
| 119 | + <FlexRowItemCenterBox> |
| 120 | + <DomainStatus domain={acmePrefix + domain} nsDomain={ns} mr={1} /> |
| 121 | + {domain} |
| 122 | + </FlexRowItemCenterBox> |
| 123 | + } |
| 124 | + defaultOpen={true} |
| 125 | + showIcon={true} |
| 126 | + > |
| 127 | + <Box p={1}> |
| 128 | + Add a NS Record |
| 129 | + <pre className={classes.action}> |
| 130 | + {acmePrefix} |
| 131 | + {domain} NS {ns}{" "} |
| 132 | + </pre> |
| 133 | + </Box> |
| 134 | + </CollapseWrapper> |
| 135 | + </Box> |
| 136 | + ); |
| 137 | + }) |
| 138 | + .toList()} |
| 139 | + </Box> |
| 140 | + </Box> |
| 141 | + ); |
| 142 | + } |
121 | 143 | } else { |
122 | 144 | const domains = cert.get("domains"); |
123 | 145 | return ( |
@@ -154,42 +176,46 @@ class CertificateDetailRaw extends React.PureComponent<Props, State> { |
154 | 176 | <Box p={2}> |
155 | 177 | <Expansion title="ACME DNS Server" defaultUnfold> |
156 | 178 | <Loading /> |
| 179 | + Waiting for staring. |
157 | 180 | </Expansion> |
158 | 181 | </Box> |
159 | 182 | ); |
160 | 183 | } |
161 | 184 |
|
162 | 185 | return ( |
163 | 186 | <Box p={2}> |
164 | | - <Expansion title="ACME DNS Server" defaultUnfold={!acmeServer.get("ready")}> |
| 187 | + <Expansion title="ACME DNS Server is running" defaultUnfold={!acmeServer.get("ready")}> |
165 | 188 | <Box p={2}> |
166 | 189 | {acmeServer.get("ready") ? ( |
167 | 190 | <Alert severity="success">Kalm DNS server is running well, you don't need to do any more.</Alert> |
168 | 191 | ) : ( |
169 | | - <> |
170 | | - <Alert severity="info"> |
171 | | - You simply need to do the following to get your DNS server up and running. |
172 | | - </Alert> |
| 192 | + <Alert severity="info"> |
| 193 | + You simply need to do the following to get your DNS server up and running. |
| 194 | + </Alert> |
| 195 | + )} |
| 196 | + <> |
| 197 | + <Box p={1}> |
| 198 | + DNS Server Domain: |
173 | 199 | <Box p={1}> |
174 | | - DNS Server Domain: {acmeServer.get("acmeDomain")} |
175 | | - <Box p={1}> |
176 | | - Add a CNAME Record |
177 | | - <pre className={classes.action}> |
178 | | - {acmeServer.get("acmeDomain")} CNAME {acmeServer.get("nsDomain")} |
179 | | - </pre> |
180 | | - </Box> |
| 200 | + NS Record: |
| 201 | + <pre className={classes.action}> |
| 202 | + {acmeServer.get("acmeDomain")} NS {acmeServer.get("nsDomain")} |
| 203 | + </pre> |
181 | 204 | </Box> |
| 205 | + </Box> |
| 206 | + <Box p={1}> |
| 207 | + Shadow Domain: |
182 | 208 | <Box p={1}> |
183 | | - Shadow Domain: {acmeServer.get("nsDomain")} |
184 | | - <Box p={1}> |
185 | | - Add a A Record |
186 | | - <pre className={classes.action}> |
187 | | - {acmeServer.get("nsDomain")} A {acmeServer.get("ipForNameServer")} |
188 | | - </pre> |
189 | | - </Box> |
| 209 | + A Record: |
| 210 | + <pre className={classes.action}> |
| 211 | + {acmeServer.get("nsDomain")} A {acmeServer.get("ipForNameServer")} |
| 212 | + </pre> |
190 | 213 | </Box> |
191 | | - </> |
192 | | - )} |
| 214 | + </Box> |
| 215 | + <Button color="primary" variant="outlined" size="small" component={Link} to="/certificates/acme/edit"> |
| 216 | + Edit |
| 217 | + </Button> |
| 218 | + </> |
193 | 219 | </Box> |
194 | 220 | </Expansion> |
195 | 221 | </Box> |
@@ -225,7 +251,7 @@ class CertificateDetailRaw extends React.PureComponent<Props, State> { |
225 | 251 | <FlexRowItemCenterBox> |
226 | 252 | <Box className={classes.key}>Status</Box> |
227 | 253 | <Box pl={2} /> |
228 | | - {certInfo?.get("ready") ? "Ready" : "Not Ready"} |
| 254 | + {certInfo?.get("ready") ? certInfo?.get("ready") : "Not Ready"} |
229 | 255 | </FlexRowItemCenterBox> |
230 | 256 |
|
231 | 257 | {this.renderDomainGuide(certInfo)} |
|
0 commit comments