@@ -143,6 +143,38 @@ export interface DehydratedIrisGridState {
143143 columnHeaderGroups ?: readonly ColumnGroup [ ] ;
144144}
145145
146+ export interface DehydratedIrisGridPanelStateV1 {
147+ isSelectingPartition : boolean ;
148+ partition : string | null ;
149+ partitionColumn : ColumnName ;
150+ advancedSettings : [ AdvancedSettingsType , boolean ] [ ] ;
151+ }
152+
153+ export interface DehydratedIrisGridPanelStateV2 {
154+ isSelectingPartition : boolean ;
155+ partitions : ( string | null ) [ ] ;
156+ partitionColumns : ColumnName [ ] ;
157+ advancedSettings : [ AdvancedSettingsType , boolean ] [ ] ;
158+ }
159+
160+ export type DehydratedIrisGridPanelState =
161+ | DehydratedIrisGridPanelStateV1
162+ | DehydratedIrisGridPanelStateV2 ;
163+
164+ export function isPanelStateV1 (
165+ state : DehydratedIrisGridPanelState
166+ ) : state is DehydratedIrisGridPanelStateV1 {
167+ return ( state as DehydratedIrisGridPanelStateV1 ) . partitionColumn != null ;
168+ }
169+
170+ export function isPanelStateV2 (
171+ state : DehydratedIrisGridPanelState
172+ ) : state is DehydratedIrisGridPanelStateV2 {
173+ return Array . isArray (
174+ ( state as DehydratedIrisGridPanelStateV2 ) . partitionColumns
175+ ) ;
176+ }
177+
146178/**
147179 * Checks if an index is valid for the given array
148180 * @param x The index to check
@@ -279,12 +311,7 @@ class IrisGridUtils {
279311 partitionColumns : Column [ ] ;
280312 advancedSettings : Map < AdvancedSettingsType , boolean > ;
281313 }
282- ) : {
283- isSelectingPartition : boolean ;
284- partitions : ( string | null ) [ ] ;
285- partitionColumns : ColumnName [ ] ;
286- advancedSettings : [ AdvancedSettingsType , boolean ] [ ] ;
287- } {
314+ ) : DehydratedIrisGridPanelState {
288315 const {
289316 isSelectingPartition,
290317 partitions,
@@ -311,25 +338,21 @@ class IrisGridUtils {
311338 */
312339 static hydrateIrisGridPanelState (
313340 model : IrisGridModel ,
314- irisGridPanelState : {
315- // This needs to be changed after IrisGridPanel is done
316- isSelectingPartition : boolean ;
317- partitions : ( string | null ) [ ] ;
318- partitionColumns : ColumnName [ ] ;
319- advancedSettings : [ AdvancedSettingsType , boolean ] [ ] ;
320- }
341+ irisGridPanelState : DehydratedIrisGridPanelState
321342 ) : {
322343 isSelectingPartition : boolean ;
323344 partitions : ( string | null ) [ ] ;
324345 partitionColumns : Column [ ] ;
325346 advancedSettings : Map < AdvancedSettingsType , boolean > ;
326347 } {
327- const {
328- isSelectingPartition,
329- partitions,
330- partitionColumns,
331- advancedSettings,
332- } = irisGridPanelState ;
348+ const { isSelectingPartition, advancedSettings } = irisGridPanelState ;
349+
350+ const { partitionColumns, partitions } = isPanelStateV2 ( irisGridPanelState )
351+ ? irisGridPanelState
352+ : {
353+ partitionColumns : [ irisGridPanelState . partitionColumn ] ,
354+ partitions : [ irisGridPanelState . partition ] ,
355+ } ;
333356
334357 const { columns } = model ;
335358 return {
@@ -391,10 +414,7 @@ class IrisGridUtils {
391414 static extractTableSettings < AF , QF , S > (
392415 panelState : {
393416 irisGridState : { advancedFilters : AF ; quickFilters : QF ; sorts : S } ;
394- irisGridPanelState : {
395- partitionColumns : ColumnName [ ] ;
396- partitions : unknown [ ] ;
397- } ;
417+ irisGridPanelState : DehydratedIrisGridPanelState ;
398418 } ,
399419 inputFilters : InputFilter [ ] = [ ]
400420 ) : {
@@ -406,7 +426,12 @@ class IrisGridUtils {
406426 sorts : S ;
407427 } {
408428 const { irisGridPanelState, irisGridState } = panelState ;
409- const { partitionColumns, partitions } = irisGridPanelState ;
429+ const { partitionColumns, partitions } = isPanelStateV2 ( irisGridPanelState )
430+ ? irisGridPanelState
431+ : {
432+ partitionColumns : [ irisGridPanelState . partitionColumn ] ,
433+ partitions : [ irisGridPanelState . partition ] ,
434+ } ;
410435 const { advancedFilters, quickFilters, sorts } = irisGridState ;
411436
412437 return {
0 commit comments