Skip to content

Commit e7380f6

Browse files
committed
ListPage: clean inputText on search
Issue: AAH-2340
1 parent 5b946ab commit e7380f6

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

CHANGES/2340.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Repositories, Remotes - clean filter text on search

src/components/page/list-page.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ export const ListPage = function <T, ExtraState = Record<string, never>>({
205205

206206
const niceValues = {};
207207
(filterConfig || [])
208-
.filter((filter) => filter['options'] && filter['options'].length > 0)
209-
.forEach((item) => {
210-
const obj = (niceValues[item['id']] = {});
211-
item['options'].forEach((option) => {
212-
obj[option.id] = option.title;
208+
.filter(({ options }) => options?.length)
209+
.forEach(({ id: filterId, options }) => {
210+
const obj = (niceValues[filterId] = {});
211+
options.forEach(({ id: optionId, title }) => {
212+
obj[optionId] = title;
213213
});
214214
});
215215

@@ -254,7 +254,10 @@ export const ListPage = function <T, ExtraState = Record<string, never>>({
254254
onChange={(inputText) =>
255255
this.setState({ inputText })
256256
}
257-
updateParams={updateParams}
257+
updateParams={(p) => {
258+
this.setState({ inputText: '' });
259+
updateParams(p);
260+
}}
258261
params={params}
259262
filterConfig={filterConfig}
260263
/>

src/components/patternfly-wrappers/compound-filter.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export class CompoundFilter extends React.Component<IProps, IState> {
5454
constructor(props) {
5555
super(props);
5656

57-
// this is called again in repositories selector, but not in approval page (the same filter is here)...
5857
this.state = {
5958
selectedFilter: props.filterConfig[0],
6059
isExpanded: false,

src/containers/certification-dashboard/certification-dashboard.tsx

+13-15
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,18 @@ class CertificationDashboard extends React.Component<RouteProps, IState> {
143143

144144
const promises = [];
145145

146-
promises.push(this.loadRepo('staging'));
147-
promises.push(this.loadRepo('rejected'));
146+
promises.push(
147+
this.loadRepo('staging').then((stagingRepoNames) =>
148+
this.setState({
149+
stagingRepoNames,
150+
}),
151+
),
152+
);
153+
promises.push(
154+
this.loadRepo('rejected').then(([rejectedRepoName]) =>
155+
this.setState({ rejectedRepoName }),
156+
),
157+
);
148158

149159
promises.push(
150160
RepositoriesUtils.listApproved()
@@ -171,19 +181,7 @@ class CertificationDashboard extends React.Component<RouteProps, IState> {
171181

172182
private loadRepo(pipeline) {
173183
return Repositories.list({ pulp_label_select: `pipeline=${pipeline}` })
174-
.then((data) => {
175-
if (data.data.results.length > 0) {
176-
if (pipeline == 'staging') {
177-
this.setState({
178-
stagingRepoNames: data.data.results.map((res) => res.name),
179-
});
180-
}
181-
182-
if (pipeline == 'rejected') {
183-
this.setState({ rejectedRepoName: data.data.results[0].name });
184-
}
185-
}
186-
})
184+
.then(({ data: { results } }) => (results || []).map(({ name }) => name))
187185
.catch((error) => {
188186
this.addAlert(
189187
t`Error loading repository with label ${pipeline}.`,

0 commit comments

Comments
 (0)