|
3 | 3 | Button, |
4 | 4 | ButtonType, |
5 | 5 | ButtonVariant, |
| 6 | + Content, |
6 | 7 | Form, |
7 | 8 | HelperText, |
8 | 9 | HelperTextItem, |
@@ -56,6 +57,7 @@ const getNewHostnames = ( |
56 | 57 | const [changeEnabled, reason] = canChangeHostname(h); |
57 | 58 | const hostnameRes = { |
58 | 59 | newHostname: changeEnabled ? templateToHostname(index, values) : undefined, |
| 60 | + oldHostname: getHostname(h), |
59 | 61 | reason: changeEnabled ? undefined : reason, |
60 | 62 | }; |
61 | 63 | if (changeEnabled) { |
@@ -176,6 +178,7 @@ const MassChangeHostnameForm = ({ |
176 | 178 |
|
177 | 179 | const newHostnames = getNewHostnames(values, selectedHosts, canChangeHostname); |
178 | 180 | const { t } = useTranslation(); |
| 181 | + |
179 | 182 | return ( |
180 | 183 | <Form onSubmit={handleSubmit}> |
181 | 184 | <ModalBody> |
@@ -206,44 +209,47 @@ const MassChangeHostnameForm = ({ |
206 | 209 | </StackItem> |
207 | 210 | <StackItem> |
208 | 211 | {t('ai:Preview')} |
209 | | - <div className="hostname-preview"> |
210 | | - {selectedHosts.map((h, index) => { |
211 | | - const { newHostname, reason } = newHostnames[index]; |
212 | | - return ( |
213 | | - <Split key={h.id || index} hasGutter> |
214 | | - <SplitItem className="hostname-column"> |
215 | | - <div className="hostname-column__text"> |
216 | | - <strong>{getHostname(h)}</strong> |
217 | | - </div> |
218 | | - </SplitItem> |
219 | | - <SplitItem> |
220 | | - <div> |
221 | | - <strong>{'>'}</strong> |
222 | | - </div> |
223 | | - </SplitItem> |
224 | | - <SplitItem isFilled> |
225 | | - {reason ? ( |
226 | | - <Popover |
227 | | - aria-label={t('ai:Cannot change hostname popover')} |
228 | | - headerContent={<div>{t('ai:Hostname cannot be changed')}</div>} |
229 | | - bodyContent={<div>{reason}</div>} |
| 212 | + <Split className="hostname-preview" hasGutter> |
| 213 | + <SplitItem className="hostname-column"> |
| 214 | + {newHostnames.map((host, i) => ( |
| 215 | + <div className="hostname-column__text" key={`old-hostname-${i}`}> |
| 216 | + <strong>{host.oldHostname}</strong> |
| 217 | + </div> |
| 218 | + ))} |
| 219 | + </SplitItem> |
| 220 | + <SplitItem> |
| 221 | + {newHostnames.map((_, i) => ( |
| 222 | + <div key={`divider-${i}`}> |
| 223 | + <strong>{'>'}</strong> |
| 224 | + </div> |
| 225 | + ))} |
| 226 | + </SplitItem> |
| 227 | + <SplitItem> |
| 228 | + {newHostnames.map((host, i) => ( |
| 229 | + <div key={`new-hostname-${i}`}> |
| 230 | + {host.reason ? ( |
| 231 | + <Popover |
| 232 | + aria-label={t('ai:Cannot change hostname popover')} |
| 233 | + headerContent={<div>{t('ai:Hostname cannot be changed')}</div>} |
| 234 | + bodyContent={<div>{host.reason}</div>} |
| 235 | + > |
| 236 | + <Button |
| 237 | + variant="link" |
| 238 | + icon={<InfoCircleIcon color={blueInfoColor.value} />} |
| 239 | + isInline |
230 | 240 | > |
231 | | - <Button |
232 | | - variant="link" |
233 | | - icon={<InfoCircleIcon color={blueInfoColor.value} />} |
234 | | - isInline |
235 | | - > |
236 | | - {t('ai:Not changeable')} |
237 | | - </Button> |
238 | | - </Popover> |
239 | | - ) : ( |
240 | | - newHostname || t('ai:New hostname will appear here...') |
241 | | - )} |
242 | | - </SplitItem> |
243 | | - </Split> |
244 | | - ); |
245 | | - })} |
246 | | - </div> |
| 241 | + {t('ai:Not changeable')} |
| 242 | + </Button> |
| 243 | + </Popover> |
| 244 | + ) : ( |
| 245 | + <Content> |
| 246 | + {host.newHostname || t('ai:New hostname will appear here...')} |
| 247 | + </Content> |
| 248 | + )} |
| 249 | + </div> |
| 250 | + ))} |
| 251 | + </SplitItem> |
| 252 | + </Split> |
247 | 253 | </StackItem> |
248 | 254 | <StackItem> |
249 | 255 | <ModalProgress |
|
0 commit comments