diff --git a/client/app/scripts/components/node-details.js b/client/app/scripts/components/node-details.js index 4f6bdb4fba..0f8de12092 100644 --- a/client/app/scripts/components/node-details.js +++ b/client/app/scripts/components/node-details.js @@ -8,7 +8,6 @@ import { clickCloseDetails, clickShowTopologyForNode } from '../actions/app-acti import { brightenColor, getNeutralColor, getNodeColorDark } from '../utils/color-utils'; import { isGenericTable, isPropertyList } from '../utils/node-details-utils'; import { resetDocumentTitle, setDocumentTitle } from '../utils/title-utils'; -import { timestampsEqual } from '../utils/time-utils'; import Overlay from './overlay'; import MatchedText from './matched-text'; @@ -307,7 +306,7 @@ class NodeDetails extends React.Component { function mapStateToProps(state, ownProps) { const currentTopologyId = state.get('currentTopologyId'); return { - transitioning: !timestampsEqual(state.get('pausedAt'), ownProps.timestamp), + transitioning: state.get('pausedAt') !== ownProps.timestamp, nodeMatches: state.getIn(['searchNodeMatches', currentTopologyId, ownProps.id]), nodes: state.get('nodes'), selectedNodeId: state.get('selectedNodeId'), diff --git a/client/app/scripts/components/node-details/__tests__/node-details-health-link-item-test.js b/client/app/scripts/components/node-details/__tests__/node-details-health-link-item-test.js index f379b2f307..bb29dc11b1 100644 --- a/client/app/scripts/components/node-details/__tests__/node-details-health-link-item-test.js +++ b/client/app/scripts/components/node-details/__tests__/node-details-health-link-item-test.js @@ -5,7 +5,8 @@ import { appendTime } from '../node-details-health-link-item'; describe('NodeDetailsHealthLinkItem', () => { describe('appendTime', () => { - const time = moment.unix(1496275200); + const time = '2017-06-01T00:00:00Z'; + const timeUnix = moment(time).unix(); it('returns url for empty url or time', () => { expect(appendTime('', time)).toEqual(''); @@ -15,10 +16,10 @@ describe('NodeDetailsHealthLinkItem', () => { it('appends as json for cloud link', () => { const url = appendTime('/prom/:orgid/notebook/new/%7B%22cells%22%3A%5B%7B%22queries%22%3A%5B%22go_goroutines%22%5D%7D%5D%7D', time); - expect(url).toContain(time.unix()); + expect(url).toContain(timeUnix); const payload = JSON.parse(decodeURIComponent(url.substr(url.indexOf('new/') + 4))); - expect(payload.time.queryEnd).toEqual(time.unix()); + expect(payload.time.queryEnd).toEqual(timeUnix); }); it('appends as GET parameter', () => { diff --git a/client/app/scripts/components/node-details/node-details-health-link-item.js b/client/app/scripts/components/node-details/node-details-health-link-item.js index abe08915e9..e0c45b47a1 100644 --- a/client/app/scripts/components/node-details/node-details-health-link-item.js +++ b/client/app/scripts/components/node-details/node-details-health-link-item.js @@ -1,4 +1,5 @@ import React from 'react'; +import moment from 'moment'; import { connect } from 'react-redux'; import NodeDetailsHealthItem from './node-details-health-item'; @@ -9,7 +10,7 @@ import { trackAnalyticsEvent } from '../../utils/tracking-utils'; /** * @param {string} url - * @param {Moment} time + * @param {string} time * @returns {string} */ export function appendTime(url, time) { @@ -18,12 +19,13 @@ export function appendTime(url, time) { // rudimentary check whether we have a cloud link const cloudLinkPathEnd = 'notebook/new/'; const pos = url.indexOf(cloudLinkPathEnd); + const timeUnix = moment(time).unix(); if (pos !== -1) { let payload; const json = decodeURIComponent(url.substr(pos + cloudLinkPathEnd.length)); try { payload = JSON.parse(json); - payload.time = { queryEnd: time.unix() }; + payload.time = { queryEnd: timeUnix }; } catch (e) { return url; } @@ -32,9 +34,9 @@ export function appendTime(url, time) { } if (url.indexOf('?') !== -1) { - return `${url}&time=${time.unix()}`; + return `${url}&time=${timeUnix}`; } - return `${url}?time=${time.unix()}`; + return `${url}?time=${timeUnix}`; } class NodeDetailsHealthLinkItem extends React.Component { diff --git a/client/app/scripts/components/time-travel-wrapper.js b/client/app/scripts/components/time-travel-wrapper.js index c7c2a9178a..5795d1dc91 100644 --- a/client/app/scripts/components/time-travel-wrapper.js +++ b/client/app/scripts/components/time-travel-wrapper.js @@ -23,7 +23,6 @@ class TimeTravelWrapper extends React.Component { constructor(props, context) { super(props, context); - this.changeTimestamp = this.changeTimestamp.bind(this); this.trackTimestampEdit = this.trackTimestampEdit.bind(this); this.trackTimelinePanButtonClick = this.trackTimelinePanButtonClick.bind(this); this.trackTimelineLabelClick = this.trackTimelineLabelClick.bind(this); @@ -31,10 +30,6 @@ class TimeTravelWrapper extends React.Component { this.trackTimelinePan = this.trackTimelinePan.bind(this); } - changeTimestamp(timestamp) { - this.props.jumpToTime(moment(timestamp).utc()); - } - trackTimestampEdit() { trackAnalyticsEvent('scope.time.timestamp.edit', { layout: this.props.topologyViewMode, @@ -82,7 +77,7 @@ class TimeTravelWrapper extends React.Component { { }); it('should combine multiple options with a timestamp', () => { - state = state.set('pausedAt', moment('2015-06-14T21:12:05.275Z')); + state = state.set('pausedAt', '2015-06-14T21:12:05.275Z'); expect(buildUrlQuery(makeOrderedMap([ ['foo', 2], ['bar', 4] diff --git a/client/app/scripts/utils/router-utils.js b/client/app/scripts/utils/router-utils.js index ae0c3a7430..2de85b253f 100644 --- a/client/app/scripts/utils/router-utils.js +++ b/client/app/scripts/utils/router-utils.js @@ -3,7 +3,6 @@ import { each } from 'lodash'; import { route } from '../actions/app-actions'; import { storageGet, storageSet } from './storage-utils'; -import { serializeTimestamp } from './web-api-utils'; // // page.js won't match the routes below if ":state" has a slash in it, so replace those before we @@ -51,7 +50,7 @@ export function getUrlState(state) { const urlState = { controlPipe: cp ? cp.toJS() : null, nodeDetails: nodeDetails.toJS(), - pausedAt: serializeTimestamp(state.get('pausedAt')), + pausedAt: state.get('pausedAt'), topologyViewMode: state.get('topologyViewMode'), pinnedMetricType: state.get('pinnedMetricType'), pinnedSearches: state.get('pinnedSearches').toJS(), diff --git a/client/app/scripts/utils/time-utils.js b/client/app/scripts/utils/time-utils.js index f2474fb970..c5fb67f127 100644 --- a/client/app/scripts/utils/time-utils.js +++ b/client/app/scripts/utils/time-utils.js @@ -9,9 +9,3 @@ export function timer(fn) { }; return timedFn; } - -export function timestampsEqual(timestampA, timestampB) { - const stringifiedTimestampA = timestampA ? timestampA.toISOString() : ''; - const stringifiedTimestampB = timestampB ? timestampB.toISOString() : ''; - return stringifiedTimestampA === stringifiedTimestampB; -} diff --git a/client/app/scripts/utils/web-api-utils.js b/client/app/scripts/utils/web-api-utils.js index 7f9d503b45..1a6462d3fd 100644 --- a/client/app/scripts/utils/web-api-utils.js +++ b/client/app/scripts/utils/web-api-utils.js @@ -1,5 +1,4 @@ import debug from 'debug'; -import moment from 'moment'; import reqwest from 'reqwest'; import { defaults } from 'lodash'; import { Map as makeMap, List } from 'immutable'; @@ -50,17 +49,9 @@ let firstMessageOnWebsocketAt = null; let continuePolling = true; -export function serializeTimestamp(timestamp) { - return timestamp ? timestamp.toISOString() : null; -} - -export function deserializeTimestamp(str) { - return str ? moment(str) : null; -} - export function buildUrlQuery(params = makeMap(), state) { // Attach the time travel timestamp to every request to the backend. - params = params.set('timestamp', serializeTimestamp(state.get('pausedAt'))); + params = params.set('timestamp', state.get('pausedAt')); // Ignore the entries with values `null` or `undefined`. return params.map((value, param) => {