Merge "web: store status filter in the location hash"
This commit is contained in:
commit
213b1867f5
|
@ -16,6 +16,11 @@ import * as React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { ExternalLinkAltIcon } from '@patternfly/react-icons'
|
import { ExternalLinkAltIcon } from '@patternfly/react-icons'
|
||||||
|
|
||||||
|
function removeHash() {
|
||||||
|
// Remove location hash from url
|
||||||
|
window.history.pushState('', document.title, window.location.pathname)
|
||||||
|
}
|
||||||
|
|
||||||
function ExternalLink(props) {
|
function ExternalLink(props) {
|
||||||
const { target } = props
|
const { target } = props
|
||||||
|
|
||||||
|
@ -87,4 +92,4 @@ function buildExternalTableLink(buildish) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
export { ExternalLink, buildExternalLink, buildExternalTableLink }
|
export { removeHash, ExternalLink, buildExternalLink, buildExternalTableLink }
|
||||||
|
|
|
@ -28,6 +28,7 @@ import { PageSection, PageSectionVariants } from '@patternfly/react-core'
|
||||||
import { fetchStatusIfNeeded } from '../actions/status'
|
import { fetchStatusIfNeeded } from '../actions/status'
|
||||||
import Pipeline from '../containers/status/Pipeline'
|
import Pipeline from '../containers/status/Pipeline'
|
||||||
import { Fetchable } from '../containers/Fetching'
|
import { Fetchable } from '../containers/Fetching'
|
||||||
|
import { removeHash } from '../Misc'
|
||||||
|
|
||||||
|
|
||||||
class StatusPage extends React.Component {
|
class StatusPage extends React.Component {
|
||||||
|
@ -57,7 +58,6 @@ class StatusPage extends React.Component {
|
||||||
constructor () {
|
constructor () {
|
||||||
super()
|
super()
|
||||||
|
|
||||||
this.filterLoaded = false
|
|
||||||
this.timer = null
|
this.timer = null
|
||||||
this.visible = true
|
this.visible = true
|
||||||
|
|
||||||
|
@ -125,9 +125,15 @@ class StatusPage extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
setFilter = (filter) => {
|
setFilter = (filter) => {
|
||||||
|
// Update form ref value
|
||||||
this.filter.value = filter
|
this.filter.value = filter
|
||||||
|
// Store value in location
|
||||||
|
if (filter) {
|
||||||
|
window.location.hash = '#' + filter
|
||||||
|
} else {
|
||||||
|
removeHash()
|
||||||
|
}
|
||||||
this.setState({filter: filter})
|
this.setState({filter: filter})
|
||||||
localStorage.setItem('zuul_filter_string', filter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleKeyPress = (e) => {
|
handleKeyPress = (e) => {
|
||||||
|
@ -144,15 +150,11 @@ class StatusPage extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadState = () => {
|
loadState = () => {
|
||||||
let filter = localStorage.getItem('zuul_filter_string') || ''
|
const filter = this.props.location.hash ? this.props.location.hash.slice(1) : null
|
||||||
let expanded = localStorage.getItem('zuul_expand_by_default') || false
|
let expanded = localStorage.getItem('zuul_expand_by_default') || false
|
||||||
if (typeof expanded === 'string') {
|
if (typeof expanded === 'string') {
|
||||||
expanded = (expanded === 'true')
|
expanded = (expanded === 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.location.hash) {
|
|
||||||
filter = this.props.location.hash.slice(1)
|
|
||||||
}
|
|
||||||
if (filter || expanded) {
|
if (filter || expanded) {
|
||||||
this.setState({
|
this.setState({
|
||||||
filter: filter,
|
filter: filter,
|
||||||
|
@ -193,10 +195,6 @@ class StatusPage extends React.Component {
|
||||||
const { remoteData } = this.props
|
const { remoteData } = this.props
|
||||||
const { filter, expanded } = this.state
|
const { filter, expanded } = this.state
|
||||||
const status = remoteData.status
|
const status = remoteData.status
|
||||||
if (this.filter && !this.filterLoaded && filter) {
|
|
||||||
this.filterLoaded = true
|
|
||||||
this.filter.value = filter
|
|
||||||
}
|
|
||||||
const statusControl = (
|
const statusControl = (
|
||||||
<Form inline>
|
<Form inline>
|
||||||
<FormGroup controlId='status'>
|
<FormGroup controlId='status'>
|
||||||
|
|
Loading…
Reference in New Issue