Skip to content

Commit cb7d646

Browse files
authored
Fix mass hostname change content alignment (#3344)
1 parent a495bb0 commit cb7d646

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

libs/ui-lib/lib/common/components/hosts/MassChangeHostnameModal.tsx

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Button,
44
ButtonType,
55
ButtonVariant,
6+
Content,
67
Form,
78
HelperText,
89
HelperTextItem,
@@ -56,6 +57,7 @@ const getNewHostnames = (
5657
const [changeEnabled, reason] = canChangeHostname(h);
5758
const hostnameRes = {
5859
newHostname: changeEnabled ? templateToHostname(index, values) : undefined,
60+
oldHostname: getHostname(h),
5961
reason: changeEnabled ? undefined : reason,
6062
};
6163
if (changeEnabled) {
@@ -176,6 +178,7 @@ const MassChangeHostnameForm = ({
176178

177179
const newHostnames = getNewHostnames(values, selectedHosts, canChangeHostname);
178180
const { t } = useTranslation();
181+
179182
return (
180183
<Form onSubmit={handleSubmit}>
181184
<ModalBody>
@@ -206,44 +209,47 @@ const MassChangeHostnameForm = ({
206209
</StackItem>
207210
<StackItem>
208211
{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
230240
>
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>
247253
</StackItem>
248254
<StackItem>
249255
<ModalProgress

0 commit comments

Comments
 (0)