Skip to content

Commit 47712ae

Browse files
committed
Refs #39369 - wizard, Fix bookmark sending logic and position
1 parent 2657a9c commit 47712ae

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

webpack/JobWizard/steps/HostsAndInputs/HostSearch.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ export const HostSearch = ({ value, setValue, onBookmarkMatch }) => {
1010

1111
const handleSearchChange = search => {
1212
setValue(search);
13+
onBookmarkMatch(null);
14+
};
15+
16+
const handleBookmarkSearch = query => {
1317
const matched = bookmarks.find(
14-
bookmark => bookmark.query && bookmark.query.trim() === search.trim()
15-
);
16-
onBookmarkMatch(
17-
matched
18-
? { id: matched.id, name: matched.name, query: matched.query }
19-
: null
18+
bookmark => bookmark.query && bookmark.query.trim() === query.trim()
2019
);
20+
if (matched) {
21+
onBookmarkMatch({
22+
id: matched.id,
23+
name: matched.name,
24+
query: matched.query,
25+
});
26+
} else {
27+
onBookmarkMatch(null);
28+
}
2129
};
2230

2331
return (
@@ -31,8 +39,9 @@ export const HostSearch = ({ value, setValue, onBookmarkMatch }) => {
3139
searchQuery: value,
3240
},
3341
}}
34-
onSearch={null}
42+
onSearch={handleBookmarkSearch}
3543
onSearchChange={handleSearchChange}
44+
bookmarksPosition="right"
3645
/>
3746
</div>
3847
);

webpack/JobWizard/submit.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ import { post } from 'foremanReact/redux/API';
22
import { repeatTypes, JOB_INVOCATION } from './JobWizardConstants';
33
import { buildHostQuery } from './steps/HostsAndInputs/buildHostQuery';
44

5+
const hasExplicitTargets = selectedTargets =>
6+
selectedTargets.hosts.length > 0 ||
7+
selectedTargets.hostCollections.length > 0 ||
8+
selectedTargets.hostGroups.length > 0;
9+
10+
const shouldSendBookmark = (selectedBookmark, selectedTargets) =>
11+
selectedBookmark && !hasExplicitTargets(selectedTargets);
12+
513
export const submit = ({
614
jobTemplateID,
715
templateValues,
@@ -111,8 +119,10 @@ export const submit = ({
111119
concurrency_control: {
112120
concurrency_level: concurrencyLevel,
113121
},
114-
bookmark_id: selectedBookmark ? selectedBookmark.id : null,
115-
search_query: selectedBookmark
122+
bookmark_id: shouldSendBookmark(selectedBookmark, selectedTargets)
123+
? selectedBookmark.id
124+
: null,
125+
search_query: shouldSendBookmark(selectedBookmark, selectedTargets)
116126
? null
117127
: buildHostQuery(selectedTargets, hostsSearchQuery),
118128
description_format: description,

0 commit comments

Comments
 (0)