Skip to content
Open
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
5 changes: 4 additions & 1 deletion graylog2-web-interface/src/components/bootstrap/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ const StyledButton = styled(MantineButton)<{

type Props = React.PropsWithChildren<{
active?: boolean;
allowClickWhenDisabled?: boolean;
'aria-label'?: string;
bsStyle?: StyleProps;
bsSize?: BsSize;
Expand All @@ -226,6 +227,7 @@ type Props = React.PropsWithChildren<{
const Button = (
{
'aria-label': ariaLabel,
allowClickWhenDisabled = false,
bsStyle = 'default',
bsSize = undefined,
className = undefined,
Expand Down Expand Up @@ -263,7 +265,8 @@ const Button = (
variant: active ? 'outline' : 'filled',
color,
'data-testid': dataTestId,
disabled,
disabled: allowClickWhenDisabled ? false : disabled,
'data-disabled': (allowClickWhenDisabled && disabled) || undefined,
role,
size: sizeForMantine(bsSize),
tabIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('DashboardSearchBar', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).not.toContain('disabled'));
await waitFor(() => expect(searchButton).not.toHaveAttribute('data-disabled'));

await userEvent.click(searchButton);

Expand All @@ -124,7 +124,7 @@ describe('DashboardSearchBar', () => {
name: /perform search \(changes were made after last search execution\)/i,
});

await waitFor(() => expect(searchButton.classList).not.toContain('disabled'));
await waitFor(() => expect(searchButton).not.toHaveAttribute('data-disabled'));

await userEvent.click(searchButton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('SearchBar', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).not.toContain('disabled'));
await waitFor(() => expect(searchButton).not.toHaveAttribute('data-disabled'));

asMock(dispatch).mockClear();

Expand All @@ -121,7 +121,7 @@ describe('SearchBar', () => {
const timeRangePickerButton = await screen.findByLabelText('Open Time Range Selector');
const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).toContain('disabled'));
await waitFor(() => expect(searchButton).toHaveAttribute('data-disabled'));
within(timeRangePickerButton).getByText('warning');
});

Expand Down Expand Up @@ -191,7 +191,7 @@ describe('SearchBar', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).toContain('disabled'));
await waitFor(() => expect(searchButton).toHaveAttribute('data-disabled'));
});

it('does not show warning icon on timerange button when search result timerange check returns false', async () => {
Expand All @@ -211,6 +211,6 @@ describe('SearchBar', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).not.toContain('disabled'));
await waitFor(() => expect(searchButton).not.toHaveAttribute('data-disabled'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('WidgetQueryControls', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).toContain('disabled'));
await waitFor(() => expect(searchButton).toHaveAttribute('data-disabled'));
});

it('does not show warning icon on timerange button when search result timerange check returns false', async () => {
Expand All @@ -230,6 +230,6 @@ describe('WidgetQueryControls', () => {

const searchButton = await screen.findByRole('button', { name: /perform search/i });

await waitFor(() => expect(searchButton.classList).not.toContain('disabled'));
await waitFor(() => expect(searchButton).not.toHaveAttribute('data-disabled'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ const StyledButton = styled(Button)<{ $dirty: boolean }>(
position: relative;
min-width: ${SEARCH_BUTTON_WIDTH}px;

&&&.disabled {
color: ${theme.utils.contrastingColor(theme.colors.variant.success)};
}

${$dirty
? css`
&::after {
Expand Down Expand Up @@ -84,7 +80,6 @@ const SearchButton = ({
onClick = undefined,
}: Props) => {
const sendTelemetry = useSendTelemetry();
const className = disabled ? 'disabled' : '';
const title = dirty ? 'Perform search (changes were made after last search execution)' : 'Perform Search';

const triggerTelemetry = () => {
Expand All @@ -101,7 +96,8 @@ const SearchButton = ({
<StyledButton
onClick={(e) => onButtonClick(e, disabled, triggerTelemetry, onClick)}
title={title}
className={className}
disabled={disabled}
allowClickWhenDisabled
type="submit"
bsStyle="primary"
showOverflow
Expand Down
Loading