@@ -2,30 +2,36 @@ import React from 'react';
22import Joi from 'joi-browser' ;
33import Form from '../../components/Form/Form' ;
44import Header from '../Header' ;
5- import { getUIOptions , setUIOptions } from "../../utils/localstorage" ;
5+ import { SETTINGS_VALUES } from '../../utils/constants' ;
6+ import { getUIOptions , setUIOptions } from '../../utils/localstorage' ;
67import './styles.scss' ;
7- import { toast } from " react-toastify" ;
8+ import { toast } from ' react-toastify' ;
89
910class Settings extends Form {
1011 state = {
1112 clusterId : '' ,
1213 formData : {
1314 topicDefaultView : '' ,
1415 topicDataSort : '' ,
16+ topicDataDateTimeFormat : '' ,
1517 skipConsumerGroups : false ,
1618 skipLastRecord : false ,
1719 showAllConsumerGroups : true
1820 } ,
1921 errors : { }
2022 } ;
2123
22- topicDefaultView = [ { _id : 'ALL' , name : 'ALL' } , { _id : 'HIDE_INTERNAL' , name : 'HIDE_INTERNAL' } ,
23- { _id : 'HIDE_INTERNAL_STREAM' , name : 'HIDE_INTERNAL_STREAM' } , { _id : 'HIDE_STREAM' , name : 'HIDE_STREAM' } ] ;
24- topicDataSort = [ { _id : 'OLDEST' , name : 'OLDEST' } , { _id : 'NEWEST' , name : 'NEWEST' } ] ;
24+ topicDefaultView = Object . entries ( SETTINGS_VALUES . TOPIC . TOPIC_DEFAULT_VIEW )
25+ . map ( ( [ value ] ) => ( { _id : value , name : value } ) ) ;
26+ topicDataSort = Object . entries ( SETTINGS_VALUES . TOPIC_DATA . SORT )
27+ . map ( ( [ value ] ) => ( { _id : value , name : value } ) ) ;
28+ topicDataDateTimeFormat = Object . entries ( SETTINGS_VALUES . TOPIC_DATA . DATE_TIME_FORMAT )
29+ . map ( ( [ value ] ) => ( { _id : value , name : value } ) ) ;
2530
2631 schema = {
2732 topicDefaultView : Joi . string ( ) . optional ( ) ,
2833 topicDataSort : Joi . string ( ) . optional ( ) ,
34+ topicDataDateTimeFormat : Joi . string ( ) . required ( ) ,
2935 skipConsumerGroups : Joi . boolean ( ) . optional ( ) ,
3036 skipLastRecord : Joi . boolean ( ) . optional ( ) ,
3137 showAllConsumerGroups : Joi . boolean ( ) . optional ( )
@@ -39,6 +45,7 @@ class Settings extends Form {
3945 this . setState ( { clusterId, formData : {
4046 topicDefaultView : ( uiOptions && uiOptions . topic ) ? uiOptions . topic . defaultView : '' ,
4147 topicDataSort : ( uiOptions && uiOptions . topicData ) ? uiOptions . topicData . sort : '' ,
48+ topicDataDateTimeFormat : ( uiOptions && uiOptions . topicData ) ? uiOptions . topicData . dateTimeFormat : '' ,
4249 skipConsumerGroups : ( uiOptions && uiOptions . topic ) ? uiOptions . topic . skipConsumerGroups : false ,
4350 skipLastRecord : ( uiOptions && uiOptions . topic ) ? uiOptions . topic . skipLastRecord : false ,
4451 showAllConsumerGroups : ( uiOptions && uiOptions . topic ) ? uiOptions . topic . showAllConsumerGroups : false
@@ -64,7 +71,8 @@ class Settings extends Form {
6471 showAllConsumerGroups : formData . showAllConsumerGroups
6572 } ,
6673 topicData : {
67- sort : formData . topicDataSort
74+ sort : formData . topicDataSort ,
75+ dateTimeFormat : formData . topicDataDateTimeFormat
6876 }
6977 } ) ;
7078 toast . success ( `Settings for cluster '${ clusterId } ' updated successfully.` ) ;
@@ -151,6 +159,20 @@ class Settings extends Form {
151159 true ,
152160 { className : 'form-control' }
153161 ) }
162+ { this . renderSelect (
163+ 'topicDataDateTimeFormat' ,
164+ 'Time Format' ,
165+ this . topicDataDateTimeFormat ,
166+ ( { currentTarget : input } ) => {
167+ const { formData } = this . state ;
168+ formData . topicDataDateTimeFormat = input . value ;
169+ this . setState ( { formData} ) ;
170+ } ,
171+ 'col-sm-10' ,
172+ 'select-wrapper settings-wrapper' ,
173+ true ,
174+ { className : 'form-control' }
175+ ) }
154176 </ fieldset >
155177
156178 { this . renderButton (
0 commit comments