Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text to loading state cluster details #1510

Merged
merged 7 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions assets/js/components/ClusterDetails/ChecksResultOverview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ function ChecksResultOverview({
}) {
if (loading || pendingStates.includes(data?.status)) {
return (
<div className="flex flex-col items-center mt-2 px-4">
<Spinner />
<div className="flex flex-col items-center px-4">
<h1 className="text-center text-2xl font-bold">Check Summary</h1>
<span className="text-sm text-gray-600">
Checks execution running...
</span>
<Spinner size="xl" className="pt-12" />
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ describe('ChecksResultOverview component', () => {
render(<ChecksResultOverview loading />);

expect(screen.getByRole('alert')).toBeVisible();
expect(screen.queryByText('Check Summary')).toBeInTheDocument();
expect(
screen.queryByText('Checks execution running...')
).toBeInTheDocument();
expect(screen.queryByText('Passing')).not.toBeInTheDocument();
expect(screen.queryByText('Warning')).not.toBeInTheDocument();
expect(screen.queryByText('Critical')).not.toBeInTheDocument();
Expand Down
10 changes: 3 additions & 7 deletions assets/js/components/Spinner.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import React from 'react';
import { computedIconCssClass } from '@lib/icon';

import { EOS_LOADING_ANIMATED } from 'eos-icons-react';

function Spinner({ centered = false }) {
function Spinner({ className = '', size = 'm' }) {
return (
<div role="alert" aria-label="Loading">
<EOS_LOADING_ANIMATED
className={computedIconCssClass('fill-jungle-green-500', centered)}
/>
<div role="alert" aria-label="Loading" className={className}>
<EOS_LOADING_ANIMATED size={size} className="fill-jungle-green-500" />
</div>
);
}
Expand Down
27 changes: 27 additions & 0 deletions assets/js/components/Spinner.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Spinner from './Spinner';

export default {
title: 'Spinner',
component: Spinner,
};

export const Default = {
argTypes: {
className: {
control: 'text',
description: 'Add padding or margin',
table: {
type: { summary: 'string' },
},
},
size: {
control: { type: 'radio' },
options: ['xs', 's', 'base', 'm', 'l', 'xl', 'xxl', 'xxxl'],
description: 'How big should be the spinner?',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'm' },
},
},
},
};
23 changes: 23 additions & 0 deletions assets/js/components/Spinner.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom/extend-expect';
import Spinner from './Spinner';

describe('Spinner', () => {
it('renders the spinner component with default props', () => {
render(<Spinner />);
const spinnerElement = screen.getByRole('alert');
expect(spinnerElement).toBeInTheDocument();
expect(spinnerElement).toHaveAttribute('aria-label', 'Loading');
expect(spinnerElement.firstChild).toHaveClass('fill-jungle-green-500');
});

it('renders the spinner component with custom props', () => {
render(<Spinner className="pt-12" size="xl" />);
const spinnerElement = screen.getByRole('alert');
expect(spinnerElement).toBeInTheDocument();
expect(spinnerElement).toHaveAttribute('aria-label', 'Loading');
expect(spinnerElement).toHaveClass('pt-12');
expect(spinnerElement.firstChild).toHaveAttribute('width', '32');
});
});