Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): repair stale database list in Log Viewer #5683

Merged
merged 3 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
1. [#5678](https://github.com/influxdata/chronograf/pull/5678): Do not log error during line visualization of meta query results.
1. [#5679](https://github.com/influxdata/chronograf/pull/5679): Dispose log stream when tickscript editor page is closed.
1. [#5680](https://github.com/influxdata/chronograf/pull/5680): Generate correct flux property expressions.
1. [#5683](https://github.com/influxdata/chronograf/pull/5683): Repair stale database list in Log Viewer.

### Features

Expand Down
6 changes: 5 additions & 1 deletion ui/src/localStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export const loadLocalStorage = (errorsQueue: any[]): LocalStorage | {} => {
const gitSHAChanged = state.GIT_SHA && state.GIT_SHA !== GIT_SHA
const npmVersionChanged = state.VERSION && state.VERSION !== VERSION

if (npmVersionChanged || gitSHAChanged) {
if (
npmVersionChanged ||
gitSHAChanged ||
window.location.search === '?clearLocalStorage'
) {
window.localStorage.removeItem('state')

if (npmVersionChanged) {
Expand Down
28 changes: 19 additions & 9 deletions ui/src/logs/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,23 +951,33 @@ export const setTimeRangeAsync = () => async (dispatch): Promise<void> => {
}

export const populateNamespacesAsync = (
proxyLink: string,
source: Source = null
source: Source,
currentNamespace: Namespace = undefined
) => async (dispatch): Promise<void> => {
const proxyLink = getDeep<string | null>(source, 'links.proxy', null)
const namespaces = await getDatabasesWithRetentionPolicies(proxyLink)

if (namespaces && namespaces.length > 0) {
dispatch(setNamespaces(namespaces))

let defaultNamespace: Namespace

if (source && source.telegraf) {
defaultNamespace = _.find(
namespaces,
ns => ns.database === source.telegraf
)
if (source) {
if (currentNamespace) {
defaultNamespace = _.find(
namespaces,
ns =>
ns.database === currentNamespace.database &&
ns.retentionPolicy === currentNamespace.retentionPolicy
)
}
if (!defaultNamespace && source.telegraf) {
defaultNamespace = _.find(
namespaces,
ns => ns.database === source.telegraf
)
}
}

const namespace = defaultNamespace || namespaces[0]

await Promise.all([
Expand All @@ -986,7 +996,7 @@ export const getSourceAndPopulateNamespacesAsync = (sourceID: string) => async (

if (proxyLink) {
dispatch(setSource(source))
await dispatch(populateNamespacesAsync(proxyLink, source))
await dispatch(populateNamespacesAsync(source))
}
}

Expand Down
8 changes: 6 additions & 2 deletions ui/src/logs/containers/LogsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import {
clearSearchData,
setSearchStatus,
executeHistogramQueryAsync,
populateNamespacesAsync,
} from 'src/logs/actions'
import {getSourcesAsync} from 'src/shared/actions/sources'

Expand Down Expand Up @@ -140,6 +141,7 @@ interface Props {
fetchNewerChunkAsync: typeof fetchNewerChunkAsync
fetchTailAsync: typeof fetchTailAsync
fetchNamespaceSyslogStatusAsync: typeof fetchNamespaceSyslogStatusAsync
populateNamespacesAsync: typeof populateNamespacesAsync
flushTailBuffer: typeof flushTailBuffer
clearAllTimeBounds: typeof clearAllTimeBounds
setNextTailLowerBound: typeof setNextTailLowerBound
Expand Down Expand Up @@ -340,9 +342,10 @@ class LogsPage extends Component<Props, State> {
return src.default
}) || this.props.sources[0]

return await this.props.getSourceAndPopulateNamespaces(source.id)
return this.props.getSourceAndPopulateNamespaces(source.id)
} else if (this.props.currentNamespace) {
return this.props.fetchNamespaceSyslogStatusAsync(
return this.props.populateNamespacesAsync(
this.props.currentSource,
this.props.currentNamespace
)
}
Expand Down Expand Up @@ -1191,6 +1194,7 @@ const mapDispatchToProps = {
getConfig: getLogConfigAsync,
updateConfig: updateLogConfigAsync,
notify: notifyAction,
populateNamespacesAsync,
}

export default withRouter(
Expand Down