Skip to content

Commit 6fed1a3

Browse files
Merge pull request #3730 from RedisInsight/feature/RI-5934-format-timestamps-across-entire-application
Feature/ri 5934 format timestamps across entire application
2 parents d8eff52 + 67df570 commit 6fed1a3

File tree

49 files changed

+1094
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1094
-87
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@
222222
"classnames": "^2.3.1",
223223
"connection-string": "^4.3.2",
224224
"d3": "^7.6.1",
225-
"date-fns": "^2.16.1",
225+
"date-fns": "^3.6.0",
226+
"date-fns-tz": "^3.1.3",
226227
"electron-context-menu": "^3.1.0",
227228
"electron-log": "^4.2.4",
228229
"electron-store": "^8.0.0",

redisinsight/api/src/__mocks__/app-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export const mockSettings = Object.assign(new Settings(), {
1111
theme: 'DARK',
1212
scanThreshold: 500,
1313
batchSize: 10,
14+
dateFormat: null,
15+
timezone: null,
1416
},
1517
});
1618

redisinsight/api/src/modules/settings/dto/settings.dto.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import { IAgreementSpec } from 'src/modules/settings/models/agreements.interface
1818
const REDIS_SCAN_CONFIG = config.get('redis_scan');
1919
const WORKBENCH_CONFIG = config.get('workbench');
2020

21+
export enum TimezoneOption {
22+
Local = 'local',
23+
UTC = 'UTC',
24+
}
25+
2126
export class GetAgreementsSpecResponse {
2227
@ApiProperty({
2328
description: 'Version of agreements specification.',
@@ -70,6 +75,24 @@ export class GetAppSettingsResponse {
7075
@Default(null)
7176
theme: string = null;
7277

78+
@ApiProperty({
79+
description: 'Applied application date format',
80+
type: String,
81+
example: 'yyyy-mm-dd',
82+
})
83+
@Expose()
84+
@Default(null)
85+
dateFormat: string = null;
86+
87+
@ApiProperty({
88+
description: 'Applied application timezone',
89+
enum: TimezoneOption,
90+
example: 'local',
91+
})
92+
@Expose()
93+
@Default(null)
94+
timezone: TimezoneOption = null;
95+
7396
@ApiProperty({
7497
description: 'Applied the threshold for scan operation.',
7598
type: Number,
@@ -113,6 +136,24 @@ export class UpdateSettingsDto {
113136
@IsString()
114137
theme?: string;
115138

139+
@ApiPropertyOptional({
140+
description: 'Application date format.',
141+
type: String,
142+
example: 'yyyy-mm-dd',
143+
})
144+
@IsOptional()
145+
@IsString()
146+
dateFormat?: string;
147+
148+
@ApiPropertyOptional({
149+
description: 'Application timezone.',
150+
type: String,
151+
example: 'local',
152+
})
153+
@IsOptional()
154+
@IsString()
155+
timezone?: string;
156+
116157
@ApiPropertyOptional({
117158
description: 'Threshold for scan operation.',
118159
type: Number,

redisinsight/api/src/modules/settings/settings.analytics.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ describe('SettingsAnalytics', () => {
8585
agreements: null,
8686
scanThreshold: 10000,
8787
batchSize: 5,
88+
dateFormat: null,
89+
timezone: null,
8890
theme: null,
8991
};
9092
it('should emit [SETTINGS_KEYS_TO_SCAN_CHANGED] event', async () => {

redisinsight/api/src/modules/settings/settings.service.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ describe('SettingsService', () => {
9393
theme: null,
9494
scanThreshold: REDIS_SCAN_CONFIG.scanThreshold,
9595
batchSize: WORKBENCH_CONFIG.countBatch,
96+
dateFormat: null,
97+
timezone: null,
9698
agreements: null,
9799
});
98100

99101
expect(eventEmitter.emit).not.toHaveBeenCalled();
100102
});
103+
101104
it('should return some application settings already defined by user', async () => {
102105
agreementsRepository.getOrCreate.mockResolvedValue(mockAgreements);
103106
settingsRepository.getOrCreate.mockResolvedValue(mockSettings);
@@ -112,6 +115,7 @@ describe('SettingsService', () => {
112115
},
113116
});
114117
});
118+
115119
it('should throw InternalServerError', async () => {
116120
agreementsRepository.getOrCreate.mockRejectedValue(new Error('some error'));
117121

@@ -185,6 +189,8 @@ describe('SettingsService', () => {
185189

186190
const dto: UpdateSettingsDto = {
187191
batchSize: 6,
192+
dateFormat: 'hh-mmm-ss',
193+
timezone: 'UTC',
188194
agreements: new Map(Object.entries({
189195
notifications: false,
190196
})),
@@ -195,6 +201,8 @@ describe('SettingsService', () => {
195201
...mockSettings,
196202
data: {
197203
batchSize: 6,
204+
dateFormat: 'hh-mmm-ss',
205+
timezone: 'UTC',
198206
},
199207

200208
});

redisinsight/api/test/api/settings/GET-settings.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const responseSchema = Joi.object().keys({
1717
theme: Joi.string().allow(null).required(),
1818
scanThreshold: Joi.number().required(),
1919
batchSize: Joi.number().required(),
20+
dateFormat: Joi.string().allow(null),
21+
timezone: Joi.string().allow(null),
2022
agreements: Joi.object().keys({
2123
version: Joi.string().required(),
2224
eula: Joi.bool().required(),

redisinsight/api/test/api/settings/PATCH-settings.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const responseSchema = Joi.object().keys({
2121
theme: Joi.string().allow(null).required(),
2222
scanThreshold: Joi.number().required(),
2323
batchSize: Joi.number().required(),
24+
dateFormat: Joi.string().allow(null),
25+
timezone: Joi.string().allow(null),
2426
agreements: Joi.object().keys({
2527
version: Joi.string().required(),
2628
eula: Joi.bool().required(),
@@ -32,6 +34,8 @@ const responseSchema = Joi.object().keys({
3234
const dataSchema = Joi.object({
3335
theme: Joi.string().allow(null).optional(),
3436
scanThreshold: Joi.number().allow(null).min(500).optional(),
37+
dateFormat: Joi.string().allow(null),
38+
timezone: Joi.string().allow(null),
3539
agreements: Joi.object().keys({
3640
eula: Joi.boolean().label('.eula').optional(),
3741
encryption: Joi.boolean().label('.encryption').optional(),
@@ -45,6 +49,8 @@ const validInputData = {
4549
theme: 'DARK',
4650
scanThreshold: 100000,
4751
batchSize: 5,
52+
dateFormat: null,
53+
timezone: null,
4854
agreements: {
4955
eula: true,
5056
analytics: false,

redisinsight/api/test/helpers/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const APP_DEFAULT_SETTINGS = {
1919
scanThreshold: 10000,
2020
batchSize: 5,
2121
theme: null,
22+
dateFormat: null,
23+
timezone: null,
2224
agreements: null,
2325
};
2426
const TEST_LIBRARY_NAME = 'lib';
118 KB
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)