Skip to content

Commit

Permalink
feat: add "timestamp" field to redux storage
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Jul 19, 2024
1 parent a195efc commit c2ed9e2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 8 deletions.
10 changes: 7 additions & 3 deletions lib/report-builder/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ export interface GuiReportBuilderResult {
tree: Tree;
skips: SkipItem[];
config: ConfigForStaticFile & {customGui: ReporterConfig['customGui']};
date: string;
timestamp: number;
apiValues?: HtmlReporterValues;
date: string;
}

export class GuiReportBuilder extends StaticReportBuilder {
Expand Down Expand Up @@ -62,13 +63,16 @@ export class GuiReportBuilder extends StaticReportBuilder {
const config = {...getConfigForStaticFile(this._reporterConfig), customGui};

this._testsTree.sortTree();
const timestamp = Date.now();

return {
tree: this._testsTree.tree,
skips: this._skips,
config,
date: new Date().toString(),
apiValues: this._apiValues
apiValues: this._apiValues,
timestamp,
// TODO: remove in next major (should use timestamp instead)
date: new Date(timestamp).toString()
};
}

Expand Down
7 changes: 6 additions & 1 deletion lib/server-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,20 @@ export interface DataForStaticFile {
skips: object[];
config: ConfigForStaticFile;
apiValues: HtmlReporter['values'];
timestamp: number;
date: string;
}

export function getDataForStaticFile(htmlReporter: HtmlReporter, pluginConfig: ReporterConfig): DataForStaticFile {
const timestamp = Date.now();

return {
skips: [],
config: getConfigForStaticFile(pluginConfig),
apiValues: htmlReporter.values,
date: new Date().toString()
timestamp,
// TODO: remove in next major (should use timestamp instead)
date: new Date(timestamp).toString()
};
}

Expand Down
9 changes: 6 additions & 3 deletions lib/static/components/controls/report-info.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {Label} from '@gravity-ui/uikit';
import {isEmpty} from 'lodash';
import {version} from '../../../../package.json';
import { Label } from '@gravity-ui/uikit';

class ReportInfo extends Component {
render() {
const {gui, date} = this.props;
const {gui, timestamp} = this.props;
const lang = isEmpty(navigator.languages) ? navigator.language : navigator.languages[0];
const date = new Date(timestamp).toLocaleString(lang);

return (
<div className="report-info">
Expand All @@ -23,5 +26,5 @@ class ReportInfo extends Component {
}

export default connect(
({gui, date}) => ({gui, date})
({gui, timestamp}) => ({gui, timestamp})
)(ReportInfo);
1 change: 1 addition & 0 deletions lib/static/modules/reducers/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import actionNames from '../action-names';
import {dateToLocaleString} from '../utils';

// TODO: remove in next major (should use timestamp instead)
export default (state, action) => {
switch (action.type) {
case actionNames.INIT_GUI_REPORT:
Expand Down
4 changes: 3 additions & 1 deletion lib/static/modules/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import running from './running';
import processing from './processing';
import loading from './loading';
import gui from './gui';
import timestamp from './timestamp';
import date from './date';
import autoRun from './auto-run';
import apiValues from './api-values';
Expand Down Expand Up @@ -37,7 +38,8 @@ export default reduceReducers(
stopping,
loading,
gui,
date,
timestamp,
date, // TODO: remove in next major (should use timestamp instead)
autoRun,
apiValues,
modals,
Expand Down
15 changes: 15 additions & 0 deletions lib/static/modules/reducers/timestamp.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import actionNames from '../action-names';

export default (state, action) => {
switch (action.type) {
case actionNames.INIT_GUI_REPORT:
case actionNames.INIT_STATIC_REPORT: {
const {timestamp} = action.payload;

return {...state, timestamp};
}

default:
return state;
}
};

0 comments on commit c2ed9e2

Please sign in to comment.