Skip to content

Commit

Permalink
fix: Fix cluster filter in eventSearch and auditingSearch
Browse files Browse the repository at this point in the history
  • Loading branch information
leoliu committed Jun 29, 2020
1 parent 57281f0 commit 9841001
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ export default class Detail extends React.PureComponent {
})
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
const { searchInputState, clustersOpts } = this.props
return (
Expand All @@ -353,10 +355,10 @@ export default class Detail extends React.PureComponent {
value={searchInputState.cluster}
onChange={this.changeClusterChange}
className={styles.queryModeOptions}
valueRenderer={this.clusterRenderer}
options={clustersOpts}
/>
</span>

<SearchInput
className={styles.searchInput}
placeholder={t('search condition')}
Expand Down
21 changes: 21 additions & 0 deletions src/components/Modals/AuditingSearch/Auditing/Home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* This file is part of KubeSphere Console.
* Copyright (C) 2019 The KubeSphere Console Authors.
*
* KubeSphere Console is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KubeSphere Console is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import React from 'react'
import { action, toJS } from 'mobx'
import { observer } from 'mobx-react'
Expand Down Expand Up @@ -108,6 +126,8 @@ export default class Home extends React.Component {
)
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
const { searchInputState, clustersOpts } = this.props
return (
Expand All @@ -116,6 +136,7 @@ export default class Home extends React.Component {
className={styles.clusterSelector}
value={searchInputState.cluster}
options={clustersOpts}
valueRenderer={this.clusterRenderer}
onChange={this.onClusterChange}
/>
<SearchInput
Expand Down
7 changes: 2 additions & 5 deletions src/components/Modals/AuditingSearch/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ export default class AuditingOperating extends React.Component {
@computed
get clustersOpts() {
return this.clusters.list.data
.filter(item => get(item, 'configz.logging'))
.map(({ name }) => ({
value: name,
label: `${t('Cluster')}: ${name}`,
}))
.filter(item => get(item, 'configz.auditing'))
.map(({ name }) => ({ value: name, label: name }))
}

initStepState() {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Modals/EventSearch/Event/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ export default class Detail extends React.PureComponent {
})
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
const { searchInputState, clustersOpts } = this.props
return (
Expand All @@ -372,10 +374,10 @@ export default class Detail extends React.PureComponent {
value={searchInputState.cluster}
onChange={this.changeClusterChange}
className={styles.queryModeOptions}
valueRenderer={this.clusterRenderer}
options={clustersOpts}
/>
</span>

<SearchInput
className={styles.searchInput}
placeholder={t('search condition')}
Expand Down
21 changes: 21 additions & 0 deletions src/components/Modals/EventSearch/Event/Home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* This file is part of KubeSphere Console.
* Copyright (C) 2019 The KubeSphere Console Authors.
*
* KubeSphere Console is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* KubeSphere Console is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with KubeSphere Console. If not, see <https://www.gnu.org/licenses/>.
*/

import React from 'react'
import { action, toJS } from 'mobx'
import { observer } from 'mobx-react'
Expand Down Expand Up @@ -105,6 +123,8 @@ export default class HomeModal extends React.Component {
)
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
const { searchInputState, clustersOpts } = this.props
return (
Expand All @@ -113,6 +133,7 @@ export default class HomeModal extends React.Component {
className={styles.clusterSelector}
value={searchInputState.cluster}
options={clustersOpts}
valueRenderer={this.clusterRenderer}
onChange={this.onClusterChange}
/>
<SearchInput
Expand Down
4 changes: 4 additions & 0 deletions src/components/Modals/EventSearch/Event/Home/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
border: none;
border-radius: 0;
}
.select-menu-outer {
width: auto !important;
min-width: 130px;
}
}
}
}
7 changes: 2 additions & 5 deletions src/components/Modals/EventSearch/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ export default class EventSearch extends React.Component {
@computed
get clustersOpts() {
return this.clusters.list.data
.filter(item => get(item, 'configz.logging'))
.map(({ name }) => ({
value: name,
label: `${t('Cluster')}: ${name}`,
}))
.filter(item => get(item, 'configz.events'))
.map(({ name }) => ({ value: name, label: name }))
}

initStepState() {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modals/LogSearch/Logging/Home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ export default class HomeModal extends React.Component {
)
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
const { searchInputState, clustersOpts } = this.props
return (
Expand All @@ -173,6 +175,7 @@ export default class HomeModal extends React.Component {
className={styles.clusterSelector}
value={searchInputState.cluster}
options={clustersOpts}
valueRenderer={this.clusterRenderer}
onChange={this.onClusterChange}
/>
<SearchInput
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modals/LogSearch/Logging/Search/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ export default class LogSearchModal extends React.Component {
)
}

clusterRenderer = option => `${t('Cluster')}: ${option.label}`

renderSearchBar() {
return (
<div className={styles.searchBar}>
Expand All @@ -388,6 +390,7 @@ export default class LogSearchModal extends React.Component {
value={this.props.searchInputState.cluster}
onChange={this.changeClusterChange}
className={styles.queryModeOptions}
valueRenderer={this.clusterRenderer}
options={this.props.clustersOpts}
/>
</span>
Expand Down
5 changes: 1 addition & 4 deletions src/components/Modals/LogSearch/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ export default class LogSearchModal extends React.Component {
get clustersOpts() {
return this.clusters.list.data
.filter(item => get(item, 'configz.logging'))
.map(({ name }) => ({
value: name,
label: `${t('Cluster')}: ${name}`,
}))
.map(({ name }) => ({ value: name, label: name }))
}

initStepState() {
Expand Down

0 comments on commit 9841001

Please sign in to comment.