From 77b691ca0b67d91812934442077d57219cd750f0 Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Fri, 19 Jan 2018 17:22:25 +0100 Subject: [PATCH] Change pausedAt format from moment() back to ISO string for easier handling. --- client/app/scripts/components/node-details.js | 3 +-- .../node-details/node-details-health-link-item.js | 3 ++- .../app/scripts/components/time-travel-wrapper.js | 14 ++++---------- client/app/scripts/reducers/root.js | 10 ++++------ .../scripts/utils/__tests__/web-api-utils-test.js | 3 +-- client/app/scripts/utils/router-utils.js | 3 +-- client/app/scripts/utils/time-utils.js | 6 ------ client/app/scripts/utils/web-api-utils.js | 11 +---------- 8 files changed, 14 insertions(+), 39 deletions(-) diff --git a/client/app/scripts/components/node-details.js b/client/app/scripts/components/node-details.js index 4f6bdb4fb..0f8de1209 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/node-details-health-link-item.js b/client/app/scripts/components/node-details/node-details-health-link-item.js index abe08915e..f43b062c6 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'; @@ -23,7 +24,7 @@ export function appendTime(url, time) { const json = decodeURIComponent(url.substr(pos + cloudLinkPathEnd.length)); try { payload = JSON.parse(json); - payload.time = { queryEnd: time.unix() }; + payload.time = { queryEnd: moment(time).unix() }; } catch (e) { return url; } diff --git a/client/app/scripts/components/time-travel-wrapper.js b/client/app/scripts/components/time-travel-wrapper.js index c7c2a9178..5795d1dc9 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 ae0c3a743..2de85b253 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 f2474fb97..c5fb67f12 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 7f9d503b4..1a6462d3f 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) => {