Skip to content

Commit

Permalink
fix(web): change element wrapping core/EmptyState children (#1462)
Browse files Browse the repository at this point in the history
## Problem

The elements in the login page are rendered wrongly since
#1441. That's because the `Flex`
component used for wrapping the `core/EmptyState` children. It is
missing the "direction" prop for telling it to layout children
vertically instead of horizontally. Moreover, it looks like a `Stack`
element is a better choice for this case.

## Solution

Adapt `core/EmptyState` for using an `<Stack hasGutter>` instead of a
`<Flex>` configured to behave almost the same.

## Testing

- Tested manually
  • Loading branch information
dgdavid authored Jul 12, 2024
1 parent 8f92d27 commit 0d3874b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
6 changes: 2 additions & 4 deletions web/src/components/core/EmptyState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
// @ts-check

import React from "react";
import { EmptyState, EmptyStateHeader, EmptyStateBody, Flex } from "@patternfly/react-core";
import { EmptyState, EmptyStateHeader, EmptyStateBody, Stack } from "@patternfly/react-core";
import { Icon } from "~/components/layout";

/**
Expand Down Expand Up @@ -68,9 +68,7 @@ export default function EmptyStateWrapper({
icon={<Icon name={icon} size="xxl" color={color} />}
/>
<EmptyStateBody>
<Flex rowGap={{ default: "rowGapMd" }} justifyContent={{ default: "justifyContentCenter" }}>
{children}
</Flex>
<Stack hasGutter>{children}</Stack>
</EmptyStateBody>
</EmptyState>
);
Expand Down
36 changes: 17 additions & 19 deletions web/src/components/core/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,25 @@ user privileges.",
{rootExplanationStart} <b>{rootUser}</b> {rootExplanationEnd}
</p>
<p>{_("Please, provide its password to log in to the system.")}</p>
<Stack hasGutter>
<Form id="login" onSubmit={login} aria-label={_("Login form")}>
<FormGroup fieldId="password">
<PasswordInput
id="password"
name="password"
value={password}
aria-label={_("Password input")}
onChange={(_, v) => setPassword(v)}
/>
</FormGroup>
<Form id="login" onSubmit={login} aria-label={_("Login form")}>
<FormGroup fieldId="password">
<PasswordInput
id="password"
name="password"
value={password}
aria-label={_("Password input")}
onChange={(_, v) => setPassword(v)}
/>
</FormGroup>

{error && <FormValidationError message={errorMessage(loginError)} />}
{error && <FormValidationError message={errorMessage(loginError)} />}

<ActionGroup>
<Button type="submit" variant="primary">
{_("Log in")}
</Button>
</ActionGroup>
</Form>
</Stack>
<ActionGroup>
<Button type="submit" variant="primary">
{_("Log in")}
</Button>
</ActionGroup>
</Form>
</EmptyState>
<Flex>
<FlexItem align={{ default: "alignRight" }}>
Expand Down

0 comments on commit 0d3874b

Please sign in to comment.