Commit e4ccc98d authored by Miguel Rincon's avatar Miguel Rincon

Fix filtering of "Not connected" runners

This change (hack) replaces the space with a special space char in the
"Not connected" option that filters runners.

This change is needed because the version with quotes ("") does not
locate the right value in the options list to pass to the filters
and the URL.

Changelog: fixed
parent 35beab7d
...@@ -10,23 +10,29 @@ import { ...@@ -10,23 +10,29 @@ import {
PARAM_KEY_STATUS, PARAM_KEY_STATUS,
} from '../../constants'; } from '../../constants';
const options = [
{ value: STATUS_ACTIVE, title: s__('Runners|Active') },
{ value: STATUS_PAUSED, title: s__('Runners|Paused') },
{ value: STATUS_ONLINE, title: s__('Runners|Online') },
{ value: STATUS_OFFLINE, title: s__('Runners|Offline') },
{ value: STATUS_NOT_CONNECTED, title: s__('Runners|Not connected') },
];
export const statusTokenConfig = { export const statusTokenConfig = {
icon: 'status', icon: 'status',
title: __('Status'), title: __('Status'),
type: PARAM_KEY_STATUS, type: PARAM_KEY_STATUS,
token: BaseToken, token: BaseToken,
unique: true, unique: true,
options: [ options: options.map(({ value, title }) => ({
{ value: STATUS_ACTIVE, title: s__('Runners|Active') }, value,
{ value: STATUS_PAUSED, title: s__('Runners|Paused') }, // Replace whitespace with a special character to avoid
{ value: STATUS_ONLINE, title: s__('Runners|Online') }, // splitting this value.
{ value: STATUS_OFFLINE, title: s__('Runners|Offline') }, // Replacing in each option, as translations may also
// contain spaces!
// Added extra quotes in this title to avoid splitting this value: // see: https://gitlab.com/gitlab-org/gitlab/-/issues/344142
// see: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1438 // see: https://gitlab.com/gitlab-org/gitlab-ui/-/issues/1438
{ value: STATUS_NOT_CONNECTED, title: `"${s__('Runners|Not connected')}"` }, title: title.replace(' ', '\u00a0'),
], })),
// TODO In principle we could support more complex search rules,
// this can be added to a separate issue.
operators: OPERATOR_IS_ONLY, operators: OPERATOR_IS_ONLY,
}; };
...@@ -137,6 +137,19 @@ RSpec.describe "Admin Runners" do ...@@ -137,6 +137,19 @@ RSpec.describe "Admin Runners" do
expect(page).not_to have_content 'runner-b-1' expect(page).not_to have_content 'runner-b-1'
expect(page).not_to have_content 'runner-a-2' expect(page).not_to have_content 'runner-a-2'
end end
it 'shows correct runner when type is selected and search term is entered' do
create(:ci_runner, :instance, description: 'runner-connected', contacted_at: Time.now)
create(:ci_runner, :instance, description: 'runner-not-connected', contacted_at: nil)
visit admin_runners_path
# use the string "Not" to avoid using space and trigger an early selection
input_filtered_search_filter_is_only('Status', 'Not')
expect(page).not_to have_content 'runner-connected'
expect(page).to have_content 'runner-not-connected'
end
end end
describe 'filter by type' do describe 'filter by type' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment