Skip to content

Commit

Permalink
fix query parameter parsing for info pages
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-deboer committed Oct 31, 2017
1 parent 9bef496 commit 268382e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pkg/ui/src/containers/AccessControlsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ class AccessControlsInfo extends React.Component {
let fetching = Object.keys(props.fetching).length > 0
let resourceInfoPage = null
let resourceNotFound = null
let query = queryString.parse(this.props.location.search)
let activeTab = query.view || 'config'

if (!!this.state.resource) {
if (this.state.resource.notFound && !fetching) {
Expand All @@ -196,7 +198,7 @@ class AccessControlsInfo extends React.Component {
resourceGroup={'access'}
resource={this.state.resource}
events={events}
activeTab={(this.props.location.search || 'config').replace('?view=','')}
activeTab={activeTab}
/>
}
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/ui/src/containers/ClusterInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { withRouter } from 'react-router-dom'
import ResourceInfoPage from '../components/ResourceInfoPage'
import LoadingSpinner from '../components/LoadingSpinner'
import LogFollower from '../utils/LogFollower'
import queryString from 'query-string'
import ResourceNotFoundPage from '../components/ResourceNotFoundPage'
import { sameResourceVersion, sameResource, resourceMatchesParams } from '../utils/resource-utils'
import Loadable from 'react-loadable'
Expand Down Expand Up @@ -157,6 +158,8 @@ class ClusterInfo extends React.Component {
let fetching = Object.keys(props.fetching).length > 0
let resourceInfoPage = null
let resourceNotFound = null
let query = queryString.parse(this.props.location.search)
let activeTab = query.view || 'config'

if (!!this.state.resource) {
if (this.state.resource.notFound && !fetching) {
Expand All @@ -175,7 +178,7 @@ class ClusterInfo extends React.Component {
logs={logs}
events={events}
onLogsActivated={this.onLogsActivated.bind(this)}
activeTab={(props.location.search || 'config').replace('?view=','')}
activeTab={activeTab}
/>
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/ui/src/containers/WorkloadInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ class WorkloadInfo extends React.Component {
let fetching = Object.keys(props.fetching).length > 0
let resourceInfoPage = null
let resourceNotFound = null
let query = queryString.parse(this.props.location.search)
let activeTab = query.view || 'config'

if (!!this.state.resource) {
if (this.state.resource.notFound && !fetching) {
Expand All @@ -249,7 +251,7 @@ class WorkloadInfo extends React.Component {
logs={logs}
events={events}
onLogsActivated={this.onLogsActivated.bind(this)}
activeTab={(this.props.location.search || 'config').replace('?view=','')}
activeTab={activeTab}
/>
}
}
Expand Down
8 changes: 6 additions & 2 deletions pkg/ui/src/state/actions/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,12 @@ function updateFilterUrl(dispatch, getState) {
newFilterNames && newFilterNames.sort()

if (!arraysEqual(newFilterNames, currentFilterNames)) {
query.filters = newFilterNames
let filterQuery = newFilterNames && newFilterNames.length > 0 ?
if (newFilterNames.length > 0) {
query.filters = newFilterNames
} else {
delete query.filters
}
let filterQuery = Object.keys(query).length > 0 ?
`?${queryString.stringify(query)}` :
''
dispatch(routerActions.push(`${path}${filterQuery}`))
Expand Down

0 comments on commit 268382e

Please sign in to comment.