Skip to content

Commit

Permalink
Bug 1796116: fix duplicate badge on dev console list pages
Browse files Browse the repository at this point in the history
  • Loading branch information
spadgett committed Feb 7, 2020
1 parent 2a76e9e commit 4543b2b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions frontend/public/components/factory/list-page.jsx
Expand Up @@ -208,6 +208,7 @@ export const FireMan_ = connect(null, { filterList })(
hideTextFilter,
textFilter,
badge,
filterBarBadge,
title,
} = this.props;

Expand Down Expand Up @@ -284,7 +285,8 @@ export const FireMan_ = connect(null, { filterList })(
/>
</div>
)}
{!title && badge && (
{/* Show the badge in the filter bar if `filterBarBadge` and there's a no title. */}
{!title && filterBarBadge && badge && (
<div className="co-m-pane__filter-bar-group co-m-pane__filter-bar-group--badge">
{badge}
</div>
Expand Down Expand Up @@ -338,7 +340,7 @@ FireMan_.propTypes = {
title: PropTypes.string,
};

/** @type {React.SFC<{ListComponent: React.ComponentType<any>, kind: string, helpText?: any, namespace?: string, filterLabel?: string, textFilter?: string, title?: string, showTitle?: boolean, rowFilters?: any[], selector?: any, fieldSelector?: string, canCreate?: boolean, createButtonText?: string, createProps?: any, mock?: boolean, badge?: React.ReactNode, createHandler?: any} >} */
/** @type {React.SFC<{ListComponent: React.ComponentType<any>, kind: string, helpText?: any, namespace?: string, filterLabel?: string, textFilter?: string, title?: string, showTitle?: boolean, rowFilters?: any[], selector?: any, fieldSelector?: string, canCreate?: boolean, createButtonText?: string, createProps?: any, mock?: boolean, badge?: React.ReactNode, filterBarBadge?: boolean, createHandler?: any} >} */
export const ListPage = withFallback((props) => {
const {
autoFocus,
Expand All @@ -363,6 +365,7 @@ export const ListPage = withFallback((props) => {
textFilter,
match,
badge,
filterBarBadge,
} = props;
let { createProps } = props;
const ko = kindObj(kind);
Expand Down Expand Up @@ -427,13 +430,14 @@ export const ListPage = withFallback((props) => {
textFilter={textFilter}
title={title}
badge={badge || getBadgeFromType(ko.badge)}
filterBarBadge={filterBarBadge}
/>
);
}, ErrorBoundaryFallback);

ListPage.displayName = 'ListPage';

/** @type {React.SFC<{canCreate?: boolean, createButtonText?: string, createProps?: any, createAccessReview?: Object, flatten?: Function, title?: string, label?: string, hideTextFilter?: boolean, showTitle?: boolean, helpText?: any, filterLabel?: string, textFilter?: string, rowFilters?: any[], resources: any[], ListComponent: React.ComponentType<any>, namespace?: string, customData?: any, badge?: React.ReactNode >} */
/** @type {React.SFC<{canCreate?: boolean, createButtonText?: string, createProps?: any, createAccessReview?: Object, flatten?: Function, title?: string, label?: string, hideTextFilter?: boolean, showTitle?: boolean, helpText?: any, filterLabel?: string, textFilter?: string, rowFilters?: any[], resources: any[], ListComponent: React.ComponentType<any>, namespace?: string, customData?: any, badge?: React.ReactNode, filterBarBadge?: boolean >} */
export const MultiListPage = (props) => {
const {
autoFocus,
Expand All @@ -456,6 +460,7 @@ export const MultiListPage = (props) => {
title,
customData,
badge,
filterBarBadge,
} = props;

const resources = _.map(props.resources, (r) => ({
Expand All @@ -480,6 +485,7 @@ export const MultiListPage = (props) => {
textFilter={textFilter}
title={showTitle ? title : undefined}
badge={badge}
filterBarBadge={filterBarBadge}
>
<Firehose resources={mock ? [] : resources}>
<ListPageWrapper_
Expand Down
3 changes: 1 addition & 2 deletions frontend/public/components/search.tsx
Expand Up @@ -13,7 +13,6 @@ import {
} from '@patternfly/react-core';
import { CloseIcon } from '@patternfly/react-icons';

import { getBadgeFromType } from '@console/shared';
import { AsyncComponent } from './utils/async';
import { connectToModel } from '../kinds';
import { DefaultPage } from './default-resource';
Expand Down Expand Up @@ -48,7 +47,7 @@ const ResourceList = connectToModel(({ kindObj, mock, namespace, selector, nameF
hideTextFilter
autoFocus={false}
mock={mock}
badge={getBadgeFromType(kindObj.badge)}
filterBarBadge
/>
);
});
Expand Down

0 comments on commit 4543b2b

Please sign in to comment.