@@ -22,16 +22,13 @@ import {
2222import type { dh as DhType } from '@deephaven/jsapi-types' ;
2323import {
2424 getApi ,
25- getDefaultDateTimeFormat ,
2625 getDefaultDecimalFormatOptions ,
2726 getDefaultIntegerFormatOptions ,
2827 getFormatter ,
2928 getTimeZone ,
3029 getShowTimeZone ,
3130 getShowTSeparator ,
32- getTruncateNumbersWithPound ,
33- getSettings ,
34- saveSettings as saveSettingsAction ,
31+ updateSettings as updateSettingsAction ,
3532 RootState ,
3633 WorkspaceSettings ,
3734} from '@deephaven/redux' ;
@@ -53,13 +50,10 @@ import DateTimeOptions from './DateTimeOptions';
5350export interface ColumnSpecificSectionContentProps {
5451 dh : DhType ;
5552 formatter : FormatterItem [ ] ;
56- defaultDateTimeFormat : string ;
5753 showTimeZone : boolean ;
5854 showTSeparator : boolean ;
5955 timeZone : string ;
60- truncateNumbersWithPound : boolean ;
61- settings : WorkspaceSettings ;
62- saveSettings : ( settings : WorkspaceSettings ) => void ;
56+ updateSettings : ( settings : Partial < WorkspaceSettings > ) => void ;
6357 scrollTo : ( x : number , y : number ) => void ;
6458 defaultDecimalFormatOptions : FormatOption ;
6559 defaultIntegerFormatOptions : FormatOption ;
@@ -71,7 +65,6 @@ interface ColumnSpecificSectionContentState {
7165 showTimeZone : boolean ;
7266 showTSeparator : boolean ;
7367 timeZone : string ;
74- truncateNumbersWithPound : boolean ;
7568 timestampAtMenuOpen : Date ;
7669}
7770
@@ -81,19 +74,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
8174> {
8275 static defaultProps = {
8376 scrollTo : ( ) : void => undefined ,
84- defaults : {
85- defaultDateTimeFormat :
86- DateTimeColumnFormatter . DEFAULT_DATETIME_FORMAT_STRING ,
87- defaultDecimalFormatOptions : {
88- defaultFormatString : DecimalColumnFormatter . DEFAULT_FORMAT_STRING ,
89- } ,
90- defaultIntegerFormatOptions : {
91- defaultFormatString : IntegerColumnFormatter . DEFAULT_FORMAT_STRING ,
92- } ,
93- showTimeZone : false ,
94- showTSeparator : true ,
95- timeZone : DateTimeColumnFormatter . DEFAULT_TIME_ZONE_ID ,
96- } ,
9777 } ;
9878
9979 static inputDebounceTime = 250 ;
@@ -111,13 +91,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
11191 this . handleFormatRuleCreate = this . handleFormatRuleCreate . bind ( this ) ;
11292 this . handleFormatRuleDelete = this . handleFormatRuleDelete . bind ( this ) ;
11393
114- const {
115- formatter,
116- showTimeZone,
117- showTSeparator,
118- timeZone,
119- truncateNumbersWithPound,
120- } = props ;
94+ const { formatter, showTimeZone, showTSeparator, timeZone } = props ;
12195
12296 const formatSettings = formatter . map ( ( item , i ) => ( {
12397 ...item ,
@@ -135,7 +109,6 @@ export class ColumnSpecificSectionContent extends PureComponent<
135109 showTimeZone,
136110 showTSeparator,
137111 timeZone,
138- truncateNumbersWithPound,
139112 timestampAtMenuOpen : new Date ( ) ,
140113 } ;
141114 }
@@ -273,19 +246,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
273246 }
274247
275248 commitChanges ( ) : void {
276- const {
277- formatSettings,
278- showTimeZone,
279- showTSeparator,
280- timeZone,
281- truncateNumbersWithPound,
282- } = this . state ;
283-
284- const {
285- defaultDateTimeFormat,
286- defaultDecimalFormatOptions,
287- defaultIntegerFormatOptions,
288- } = this . props ;
249+ const { formatSettings } = this . state ;
289250
290251 const { dh } = this . props ;
291252
@@ -296,39 +257,11 @@ export class ColumnSpecificSectionContent extends PureComponent<
296257 )
297258 . map ( removeFormatRuleExtraProps ) ?? [ ] ;
298259
299- const { settings, saveSettings } = this . props ;
300- const newSettings : WorkspaceSettings = {
301- ...settings ,
260+ const { updateSettings } = this . props ;
261+ const newSettings = {
302262 formatter : formatter as FormattingRule [ ] ,
303- defaultDateTimeFormat,
304- showTimeZone,
305- showTSeparator,
306- timeZone,
307- truncateNumbersWithPound,
308263 } ;
309- if (
310- isValidFormat (
311- dh ,
312- TableUtils . dataType . DECIMAL ,
313- DecimalColumnFormatter . makeCustomFormat (
314- defaultDecimalFormatOptions . defaultFormatString
315- )
316- )
317- ) {
318- newSettings . defaultDecimalFormatOptions = defaultDecimalFormatOptions ;
319- }
320- if (
321- isValidFormat (
322- dh ,
323- TableUtils . dataType . INT ,
324- IntegerColumnFormatter . makeCustomFormat (
325- defaultIntegerFormatOptions . defaultFormatString
326- )
327- )
328- ) {
329- newSettings . defaultIntegerFormatOptions = defaultIntegerFormatOptions ;
330- }
331- saveSettings ( newSettings ) ;
264+ updateSettings ( newSettings ) ;
332265 }
333266
334267 scrollToFormatBlockBottom ( ) : void {
@@ -577,6 +510,7 @@ export class ColumnSpecificSectionContent extends PureComponent<
577510 isInvalid : boolean
578511 ) : ReactElement {
579512 const { defaultIntegerFormatOptions } = this . props ;
513+ assertNotNull ( defaultIntegerFormatOptions ) ;
580514 const { defaultFormatString } = defaultIntegerFormatOptions ;
581515 const value = format . formatString ?? '' ;
582516 return (
@@ -688,21 +622,18 @@ export class ColumnSpecificSectionContent extends PureComponent<
688622
689623const mapStateToProps = (
690624 state : RootState
691- ) : Omit < ColumnSpecificSectionContentProps , 'saveSettings ' | 'scrollTo' > => ( {
625+ ) : Omit < ColumnSpecificSectionContentProps , 'updateSettings ' | 'scrollTo' > => ( {
692626 formatter : getFormatter ( state ) ,
693- defaultDateTimeFormat : getDefaultDateTimeFormat ( state ) ,
694627 defaultDecimalFormatOptions : getDefaultDecimalFormatOptions ( state ) ,
695628 defaultIntegerFormatOptions : getDefaultIntegerFormatOptions ( state ) ,
696629 dh : getApi ( state ) ,
697630 showTimeZone : getShowTimeZone ( state ) ,
698631 showTSeparator : getShowTSeparator ( state ) ,
699- truncateNumbersWithPound : getTruncateNumbersWithPound ( state ) ,
700632 timeZone : getTimeZone ( state ) ,
701- settings : getSettings ( state ) ,
702633} ) ;
703634
704635const ConnectedColumnSpecificSectionContent = connect ( mapStateToProps , {
705- saveSettings : saveSettingsAction ,
636+ updateSettings : updateSettingsAction ,
706637} ) ( ColumnSpecificSectionContent ) ;
707638
708639export default ConnectedColumnSpecificSectionContent ;
0 commit comments