@@ -24,6 +24,28 @@ export type ConfigFieldState = {
2424export const ConfigField : React . FC < ConfigFieldProps > = props => {
2525 const { configChange, effectiveDate, pendingFieldInfo } = props ;
2626 const field = useFieldContext < ConfigFieldState > ( ) ;
27+
28+ const isSynchronizerUpgradeTime =
29+ field . state . value ?. fieldName === 'nextScheduledSynchronizerUpgradeTime' ;
30+ const isSynchronizerUpgradeMigrationId =
31+ field . state . value ?. fieldName === 'nextScheduledSynchronizerUpgradeMigrationId' ;
32+
33+ // We disable the field if it is pending and the value is the default value.
34+ // The default value check is to handle the case where the user made a change
35+ // to the field before it became a field with pending changes.
36+ // This gives them the chance to revert that change.
37+ const isPendingAndDefaultValue =
38+ pendingFieldInfo !== undefined && field . state . meta . isDefaultValue ;
39+
40+ const isEffectiveAtThreshold = ! effectiveDate ;
41+
42+ // When effective at Threshold, we disable the upgrade time and migrationId config fields
43+ const isEffectiveAtThresholdAndSyncUpgradeTimeOrMigrationId =
44+ isEffectiveAtThreshold && ( isSynchronizerUpgradeTime || isSynchronizerUpgradeMigrationId ) ;
45+
46+ const isDisabled =
47+ isPendingAndDefaultValue || isEffectiveAtThresholdAndSyncUpgradeTimeOrMigrationId ;
48+
2749 const textFieldProps = {
2850 variant : 'outlined' as const ,
2951 size : 'small' as const ,
@@ -34,11 +56,7 @@ export const ConfigField: React.FC<ConfigFieldProps> = props => {
3456 sx : { textAlign : 'right' } ,
3557 'data-testid' : `config-field-${ configChange . fieldName } ` ,
3658 } ,
37- // We disable the field if it is pending and the value is the default value.
38- // The default value check is to handle the case where the user made a change
39- // to the field before it became a field with pending changes.
40- // This gives them the chance to revert that change.
41- disabled : pendingFieldInfo !== undefined && field . state . meta . isDefaultValue ,
59+ disabled : isDisabled ,
4260 } ;
4361
4462 return (
@@ -79,8 +97,8 @@ export const ConfigField: React.FC<ConfigFieldProps> = props => {
7997 </ Typography >
8098 ) }
8199
82- { field . state . value ?. fieldName === 'nextScheduledSynchronizerUpgradeTime' && (
83- < NextScheduledSynchronizerUpgradeDisplay
100+ { isSynchronizerUpgradeTime && (
101+ < SynchronizerUpgradeTimeDisplay
84102 effectiveDate = { effectiveDate }
85103 configChange = { configChange }
86104 />
@@ -116,13 +134,13 @@ export const PendingConfigDisplay: React.FC<PendingConfigDisplayProps> = ({ pend
116134 ) ;
117135} ;
118136
119- interface NextScheduledSynchronizerUpgradeDisplayProps {
137+ interface SynchronizerUpgradeTimeDisplayProps {
120138 effectiveDate : string | undefined ;
121139 configChange : ConfigChange ;
122140}
123141
124- export const NextScheduledSynchronizerUpgradeDisplay : React . FC <
125- NextScheduledSynchronizerUpgradeDisplayProps
142+ export const SynchronizerUpgradeTimeDisplay : React . FC <
143+ SynchronizerUpgradeTimeDisplayProps
126144> = props => {
127145 const { effectiveDate } = props ;
128146 const defaultMigrationTime = dayjs ( effectiveDate )
0 commit comments