@gravity-ui/dashkit 6.7.1 → 6.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -78,19 +78,10 @@ function formQueueData({ items, itemsStateAndParams, }) {
|
|
|
78
78
|
}
|
|
79
79
|
const itemQueueParams = (0, get_1.default)(itemsStateAndParams, [item.id, 'params'], {});
|
|
80
80
|
const filteredParamsByDefaults = (0, pick_1.default)(itemQueueParams, Object.keys(itemDefaultParams));
|
|
81
|
-
/**
|
|
82
|
-
* filtering actionParams without prefixes by defaults params
|
|
83
|
-
* ex.:
|
|
84
|
-
* itemDefaultParams contains 'Country' in defaults
|
|
85
|
-
* and we receive '_ap_Country' and '_ap_City' in itemQueueParams
|
|
86
|
-
* we need to ignore '_ap_City' param because we don't have actionParam without prefix ('City') in defaults
|
|
87
|
-
*/
|
|
88
|
-
const actionParams = pickActionParamsFromParams(itemQueueParams, false) || {};
|
|
89
|
-
const filteredActionParamsByDefaults = (0, pick_1.default)(actionParams, Object.keys(itemDefaultParams));
|
|
90
81
|
/**
|
|
91
82
|
* merging filtered params and filtered actionParams with prefixes
|
|
92
83
|
*/
|
|
93
|
-
const params = Object.assign(Object.assign({}, filteredParamsByDefaults),
|
|
84
|
+
const params = Object.assign(Object.assign({}, filteredParamsByDefaults), (pickActionParamsFromParams(itemQueueParams, true) || {}));
|
|
94
85
|
return {
|
|
95
86
|
id: item.id,
|
|
96
87
|
namespace: item.namespace,
|
|
@@ -574,3 +574,150 @@ describe('getItemsStateAndParams actionParams variants check', () => {
|
|
|
574
574
|
});
|
|
575
575
|
});
|
|
576
576
|
});
|
|
577
|
+
const config = {
|
|
578
|
+
id: '7kw',
|
|
579
|
+
items: [
|
|
580
|
+
{
|
|
581
|
+
id: 'nvp',
|
|
582
|
+
data: {
|
|
583
|
+
tabs: [
|
|
584
|
+
{
|
|
585
|
+
id: 'rkq',
|
|
586
|
+
title: 'test',
|
|
587
|
+
params: {},
|
|
588
|
+
chartId: 'some-chart',
|
|
589
|
+
isDefault: true,
|
|
590
|
+
autoHeight: false,
|
|
591
|
+
description: '',
|
|
592
|
+
enableActionParams: true,
|
|
593
|
+
},
|
|
594
|
+
],
|
|
595
|
+
hideTitle: true,
|
|
596
|
+
},
|
|
597
|
+
type: 'widget',
|
|
598
|
+
layout: {
|
|
599
|
+
h: 12,
|
|
600
|
+
w: 12,
|
|
601
|
+
},
|
|
602
|
+
namespace: 'default',
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
id: 'Q9K',
|
|
606
|
+
data: {
|
|
607
|
+
title: 'Year',
|
|
608
|
+
source: {},
|
|
609
|
+
},
|
|
610
|
+
type: 'control',
|
|
611
|
+
layout: {
|
|
612
|
+
h: 2,
|
|
613
|
+
w: 8,
|
|
614
|
+
},
|
|
615
|
+
defaults: {
|
|
616
|
+
year_some_id: '',
|
|
617
|
+
},
|
|
618
|
+
namespace: 'default',
|
|
619
|
+
},
|
|
620
|
+
],
|
|
621
|
+
title: 'test',
|
|
622
|
+
layout: [
|
|
623
|
+
{
|
|
624
|
+
h: 12,
|
|
625
|
+
i: 'nvp',
|
|
626
|
+
w: 12,
|
|
627
|
+
x: 0,
|
|
628
|
+
y: 0,
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
h: 2,
|
|
632
|
+
i: 'Q9K',
|
|
633
|
+
w: 8,
|
|
634
|
+
x: 12,
|
|
635
|
+
y: 0,
|
|
636
|
+
},
|
|
637
|
+
],
|
|
638
|
+
aliases: {},
|
|
639
|
+
connections: [],
|
|
640
|
+
salt: '123',
|
|
641
|
+
counter: 1,
|
|
642
|
+
};
|
|
643
|
+
const itemsStateAndParamsActionParamTest1 = {
|
|
644
|
+
nvp: {
|
|
645
|
+
params: {
|
|
646
|
+
_ap_year_some_id: ['2022'],
|
|
647
|
+
},
|
|
648
|
+
},
|
|
649
|
+
__meta__: {
|
|
650
|
+
queue: [
|
|
651
|
+
{
|
|
652
|
+
id: 'nvp',
|
|
653
|
+
tabId: 'rkq',
|
|
654
|
+
},
|
|
655
|
+
],
|
|
656
|
+
version: 2,
|
|
657
|
+
},
|
|
658
|
+
};
|
|
659
|
+
const stateAndParamsActionParamsRes1 = {
|
|
660
|
+
Q9K: {
|
|
661
|
+
params: {
|
|
662
|
+
year_some_id: ['2022'],
|
|
663
|
+
},
|
|
664
|
+
state: {},
|
|
665
|
+
},
|
|
666
|
+
nvp: {
|
|
667
|
+
params: {
|
|
668
|
+
_ap_year_some_id: ['2022'],
|
|
669
|
+
year_some_id: '',
|
|
670
|
+
},
|
|
671
|
+
state: {},
|
|
672
|
+
},
|
|
673
|
+
};
|
|
674
|
+
const itemsStateAndParamsActionParamTest2 = {
|
|
675
|
+
nvp: {
|
|
676
|
+
params: {
|
|
677
|
+
_ap_another: ['2022'],
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
__meta__: {
|
|
681
|
+
queue: [
|
|
682
|
+
{
|
|
683
|
+
id: 'nvp',
|
|
684
|
+
tabId: 'rkq',
|
|
685
|
+
},
|
|
686
|
+
],
|
|
687
|
+
version: 2,
|
|
688
|
+
},
|
|
689
|
+
};
|
|
690
|
+
const stateAndParamsActionParamsRes2 = {
|
|
691
|
+
Q9K: {
|
|
692
|
+
params: {
|
|
693
|
+
another: ['2022'],
|
|
694
|
+
year_some_id: '',
|
|
695
|
+
},
|
|
696
|
+
state: {},
|
|
697
|
+
},
|
|
698
|
+
nvp: {
|
|
699
|
+
params: {
|
|
700
|
+
_ap_another: ['2022'],
|
|
701
|
+
year_some_id: '',
|
|
702
|
+
},
|
|
703
|
+
state: {},
|
|
704
|
+
},
|
|
705
|
+
};
|
|
706
|
+
describe('state and params with actionParams', () => {
|
|
707
|
+
it('check state', () => {
|
|
708
|
+
const res1 = (0, datalens_1.getItemsStateAndParamsDL)({
|
|
709
|
+
defaultGlobalParams: {},
|
|
710
|
+
globalParams: {},
|
|
711
|
+
config,
|
|
712
|
+
itemsStateAndParams: itemsStateAndParamsActionParamTest1,
|
|
713
|
+
});
|
|
714
|
+
expect(res1).toEqual(stateAndParamsActionParamsRes1);
|
|
715
|
+
const res2 = (0, datalens_1.getItemsStateAndParamsDL)({
|
|
716
|
+
defaultGlobalParams: {},
|
|
717
|
+
globalParams: {},
|
|
718
|
+
config,
|
|
719
|
+
itemsStateAndParams: itemsStateAndParamsActionParamTest2,
|
|
720
|
+
});
|
|
721
|
+
expect(res2).toEqual(stateAndParamsActionParamsRes2);
|
|
722
|
+
});
|
|
723
|
+
});
|
|
@@ -70,19 +70,10 @@ export function formQueueData({ items, itemsStateAndParams, }) {
|
|
|
70
70
|
}
|
|
71
71
|
const itemQueueParams = get(itemsStateAndParams, [item.id, 'params'], {});
|
|
72
72
|
const filteredParamsByDefaults = pick(itemQueueParams, Object.keys(itemDefaultParams));
|
|
73
|
-
/**
|
|
74
|
-
* filtering actionParams without prefixes by defaults params
|
|
75
|
-
* ex.:
|
|
76
|
-
* itemDefaultParams contains 'Country' in defaults
|
|
77
|
-
* and we receive '_ap_Country' and '_ap_City' in itemQueueParams
|
|
78
|
-
* we need to ignore '_ap_City' param because we don't have actionParam without prefix ('City') in defaults
|
|
79
|
-
*/
|
|
80
|
-
const actionParams = pickActionParamsFromParams(itemQueueParams, false) || {};
|
|
81
|
-
const filteredActionParamsByDefaults = pick(actionParams, Object.keys(itemDefaultParams));
|
|
82
73
|
/**
|
|
83
74
|
* merging filtered params and filtered actionParams with prefixes
|
|
84
75
|
*/
|
|
85
|
-
const params = Object.assign(Object.assign({}, filteredParamsByDefaults),
|
|
76
|
+
const params = Object.assign(Object.assign({}, filteredParamsByDefaults), (pickActionParamsFromParams(itemQueueParams, true) || {}));
|
|
86
77
|
return {
|
|
87
78
|
id: item.id,
|
|
88
79
|
namespace: item.namespace,
|
|
@@ -570,3 +570,150 @@ describe('getItemsStateAndParams actionParams variants check', () => {
|
|
|
570
570
|
});
|
|
571
571
|
});
|
|
572
572
|
});
|
|
573
|
+
const config = {
|
|
574
|
+
id: '7kw',
|
|
575
|
+
items: [
|
|
576
|
+
{
|
|
577
|
+
id: 'nvp',
|
|
578
|
+
data: {
|
|
579
|
+
tabs: [
|
|
580
|
+
{
|
|
581
|
+
id: 'rkq',
|
|
582
|
+
title: 'test',
|
|
583
|
+
params: {},
|
|
584
|
+
chartId: 'some-chart',
|
|
585
|
+
isDefault: true,
|
|
586
|
+
autoHeight: false,
|
|
587
|
+
description: '',
|
|
588
|
+
enableActionParams: true,
|
|
589
|
+
},
|
|
590
|
+
],
|
|
591
|
+
hideTitle: true,
|
|
592
|
+
},
|
|
593
|
+
type: 'widget',
|
|
594
|
+
layout: {
|
|
595
|
+
h: 12,
|
|
596
|
+
w: 12,
|
|
597
|
+
},
|
|
598
|
+
namespace: 'default',
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
id: 'Q9K',
|
|
602
|
+
data: {
|
|
603
|
+
title: 'Year',
|
|
604
|
+
source: {},
|
|
605
|
+
},
|
|
606
|
+
type: 'control',
|
|
607
|
+
layout: {
|
|
608
|
+
h: 2,
|
|
609
|
+
w: 8,
|
|
610
|
+
},
|
|
611
|
+
defaults: {
|
|
612
|
+
year_some_id: '',
|
|
613
|
+
},
|
|
614
|
+
namespace: 'default',
|
|
615
|
+
},
|
|
616
|
+
],
|
|
617
|
+
title: 'test',
|
|
618
|
+
layout: [
|
|
619
|
+
{
|
|
620
|
+
h: 12,
|
|
621
|
+
i: 'nvp',
|
|
622
|
+
w: 12,
|
|
623
|
+
x: 0,
|
|
624
|
+
y: 0,
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
h: 2,
|
|
628
|
+
i: 'Q9K',
|
|
629
|
+
w: 8,
|
|
630
|
+
x: 12,
|
|
631
|
+
y: 0,
|
|
632
|
+
},
|
|
633
|
+
],
|
|
634
|
+
aliases: {},
|
|
635
|
+
connections: [],
|
|
636
|
+
salt: '123',
|
|
637
|
+
counter: 1,
|
|
638
|
+
};
|
|
639
|
+
const itemsStateAndParamsActionParamTest1 = {
|
|
640
|
+
nvp: {
|
|
641
|
+
params: {
|
|
642
|
+
_ap_year_some_id: ['2022'],
|
|
643
|
+
},
|
|
644
|
+
},
|
|
645
|
+
__meta__: {
|
|
646
|
+
queue: [
|
|
647
|
+
{
|
|
648
|
+
id: 'nvp',
|
|
649
|
+
tabId: 'rkq',
|
|
650
|
+
},
|
|
651
|
+
],
|
|
652
|
+
version: 2,
|
|
653
|
+
},
|
|
654
|
+
};
|
|
655
|
+
const stateAndParamsActionParamsRes1 = {
|
|
656
|
+
Q9K: {
|
|
657
|
+
params: {
|
|
658
|
+
year_some_id: ['2022'],
|
|
659
|
+
},
|
|
660
|
+
state: {},
|
|
661
|
+
},
|
|
662
|
+
nvp: {
|
|
663
|
+
params: {
|
|
664
|
+
_ap_year_some_id: ['2022'],
|
|
665
|
+
year_some_id: '',
|
|
666
|
+
},
|
|
667
|
+
state: {},
|
|
668
|
+
},
|
|
669
|
+
};
|
|
670
|
+
const itemsStateAndParamsActionParamTest2 = {
|
|
671
|
+
nvp: {
|
|
672
|
+
params: {
|
|
673
|
+
_ap_another: ['2022'],
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
__meta__: {
|
|
677
|
+
queue: [
|
|
678
|
+
{
|
|
679
|
+
id: 'nvp',
|
|
680
|
+
tabId: 'rkq',
|
|
681
|
+
},
|
|
682
|
+
],
|
|
683
|
+
version: 2,
|
|
684
|
+
},
|
|
685
|
+
};
|
|
686
|
+
const stateAndParamsActionParamsRes2 = {
|
|
687
|
+
Q9K: {
|
|
688
|
+
params: {
|
|
689
|
+
another: ['2022'],
|
|
690
|
+
year_some_id: '',
|
|
691
|
+
},
|
|
692
|
+
state: {},
|
|
693
|
+
},
|
|
694
|
+
nvp: {
|
|
695
|
+
params: {
|
|
696
|
+
_ap_another: ['2022'],
|
|
697
|
+
year_some_id: '',
|
|
698
|
+
},
|
|
699
|
+
state: {},
|
|
700
|
+
},
|
|
701
|
+
};
|
|
702
|
+
describe('state and params with actionParams', () => {
|
|
703
|
+
it('check state', () => {
|
|
704
|
+
const res1 = getItemsStateAndParamsDL({
|
|
705
|
+
defaultGlobalParams: {},
|
|
706
|
+
globalParams: {},
|
|
707
|
+
config,
|
|
708
|
+
itemsStateAndParams: itemsStateAndParamsActionParamTest1,
|
|
709
|
+
});
|
|
710
|
+
expect(res1).toEqual(stateAndParamsActionParamsRes1);
|
|
711
|
+
const res2 = getItemsStateAndParamsDL({
|
|
712
|
+
defaultGlobalParams: {},
|
|
713
|
+
globalParams: {},
|
|
714
|
+
config,
|
|
715
|
+
itemsStateAndParams: itemsStateAndParamsActionParamTest2,
|
|
716
|
+
});
|
|
717
|
+
expect(res2).toEqual(stateAndParamsActionParamsRes2);
|
|
718
|
+
});
|
|
719
|
+
});
|