@cloud-ru/uikit-product-calculator 2.3.0 → 2.3.1-preview-4956dd38.0

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.
package/README.md CHANGED
@@ -113,7 +113,7 @@ data-test-id
113
113
  ### Props
114
114
  | name | type | default value | description |
115
115
  |------|------|---------------|-------------|
116
- | __@iterator@1115* | `() => StringIterator<string>` | - | Iterator |
116
+ | __@iterator@1110* | `() => StringIterator<string>` | - | Iterator |
117
117
  | toWellFormed* | `() => string` | - | Returns a string where all lone or out-of-order surrogates have been replaced by the Unicode replacement character (U+FFFD). |
118
118
  | isWellFormed* | `() => boolean` | - | Returns true if all leading surrogates and trailing surrogates appear paired and in order. |
119
119
  | at* | `(index: number) => string` | - | Returns a new String consisting of the single UTF-16 code unit located at the specified index. @param index The zero-based index of the desired code unit. A negative index will count back from the last item. |
@@ -4,19 +4,28 @@ exports.EVOLUTION_MANAGED_REDIS_CONFIG = void 0;
4
4
  const components_1 = require("../../../../components");
5
5
  const utils_1 = require("../../../utils");
6
6
  const constants_1 = require("../constants");
7
- const nodeConfigItems = (0, utils_1.generateInstanceConfigItems)([
8
- [2, 4],
9
- [4, 16],
10
- [8, 32],
11
- ]);
7
+ const CPU = [2, 4, 8, 16];
8
+ const RAM = [4, 8, 16, 32, 64, 128];
9
+ const DISK_CAPACITY_MIN = 10;
10
+ const DISK_CAPACITY_MAX = 16384;
11
+ const cpuToRamMap = {
12
+ '2': [4, 8, 16],
13
+ '4': [16, 32, 64],
14
+ '8': [32, 64, 128],
15
+ '16': [64, 128],
16
+ };
17
+ const ramToMinDisk = {
18
+ '4': DISK_CAPACITY_MIN,
19
+ '8': 40,
20
+ '16': 40,
21
+ '32': 64,
22
+ '64': 128,
23
+ '128': 256,
24
+ };
12
25
  const valueMasterReplica = 'Master/Replica';
13
26
  const valueStandalone = 'Standalone';
14
27
  const hostsByStandalone = [1];
15
28
  const hostsByMasterReplica = [3];
16
- const shardQuantityItemsByInstantType = {
17
- [valueStandalone]: [1],
18
- [valueMasterReplica]: [1],
19
- };
20
29
  const hostsByInstantType = {
21
30
  [valueStandalone]: hostsByStandalone,
22
31
  [valueMasterReplica]: hostsByMasterReplica,
@@ -25,7 +34,7 @@ const instanceTypePartCards = [
25
34
  {
26
35
  value: valueStandalone,
27
36
  label: valueStandalone,
28
- description: 'Одноузловая конфигурация',
37
+ description: 'Конфигурация с одним хостом',
29
38
  },
30
39
  {
31
40
  value: valueMasterReplica,
@@ -33,8 +42,14 @@ const instanceTypePartCards = [
33
42
  description: 'Отказоустойчивый кластер высокой доступности',
34
43
  },
35
44
  ];
45
+ const getMinMaxDiskSize = ({ ramAmount }) => ({
46
+ uiProps: {
47
+ min: ramToMinDisk[ramAmount] || DISK_CAPACITY_MIN,
48
+ max: DISK_CAPACITY_MAX,
49
+ },
50
+ });
36
51
  exports.EVOLUTION_MANAGED_REDIS_CONFIG = {
37
- ui: ['deploymentMode', 'instanceType', 'masterNodeConfig', ['hostsQuantity', 'shardQuantity'], ['systemDisk']],
52
+ ui: ['deploymentMode', 'instanceType', ['vCpuCoreCount', 'ramAmount'], 'hostQuantity', ['systemDisk']],
38
53
  controls: {
39
54
  deploymentMode: {
40
55
  type: components_1.CONTROL.Carousel,
@@ -61,47 +76,47 @@ exports.EVOLUTION_MANAGED_REDIS_CONFIG = {
61
76
  if (value === valueStandalone) {
62
77
  setValue([
63
78
  ['instanceType', value],
64
- ['hostsQuantity', hostsByStandalone[0].toString()],
79
+ ['hostQuantity', hostsByStandalone[0].toString()],
65
80
  ]);
66
81
  }
67
82
  else {
68
83
  setValue([
69
84
  ['instanceType', value],
70
- ['hostsQuantity', hostsByMasterReplica[0].toString()],
85
+ ['hostQuantity', hostsByMasterReplica[0].toString()],
71
86
  ]);
72
87
  }
73
88
  },
74
89
  },
75
- masterNodeConfig: {
76
- type: components_1.CONTROL.SelectSingle,
77
- accessorKey: 'masterNode.nodeConfig',
78
- items: nodeConfigItems,
90
+ vCpuCoreCount: {
91
+ type: components_1.CONTROL.Segmented,
92
+ accessorKey: 'vCpuCoreCount',
93
+ defaultValue: '2',
94
+ items: (0, utils_1.generateCpuItems)(CPU),
79
95
  decoratorProps: {
80
- label: 'Конфигурация',
96
+ label: 'Количество ядер vCPU',
81
97
  },
82
- defaultValue: '2 4',
83
98
  },
84
- shardQuantity: {
99
+ ramAmount: {
85
100
  type: components_1.CONTROL.Segmented,
86
- accessorKey: 'shardQuantity',
87
- defaultValue: '1',
101
+ accessorKey: 'ramAmount',
102
+ watchedControls: { vCpuCoreCount: 'vCpuCoreCount' },
103
+ defaultValue: '4',
104
+ items: (0, utils_1.generateRamItems)(RAM),
88
105
  decoratorProps: {
89
- label: 'Количество шардов',
106
+ label: 'Количество оперативной памяти (RAM)',
90
107
  },
91
- items: (0, utils_1.generateCpuItems)([1]),
92
- watchedControls: { instanceType: 'instanceType' },
93
- relateFn: ({ instanceType }) => {
94
- const items = shardQuantityItemsByInstantType[instanceType];
95
- if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
108
+ relateFn: ({ vCpuCoreCount }) => {
109
+ const itemsByCpu = cpuToRamMap[vCpuCoreCount];
110
+ if ((itemsByCpu === null || itemsByCpu === void 0 ? void 0 : itemsByCpu.length) > 0) {
96
111
  return {
97
- items: (0, utils_1.generateCpuItems)(items),
112
+ items: (0, utils_1.generateRamItems)(itemsByCpu),
98
113
  };
99
114
  }
100
115
  },
101
116
  },
102
- hostsQuantity: {
117
+ hostQuantity: {
103
118
  type: components_1.CONTROL.Segmented,
104
- accessorKey: 'hostsQuantity',
119
+ accessorKey: 'hostQuantity',
105
120
  defaultValue: '1',
106
121
  decoratorProps: {
107
122
  label: 'Количество хостов',
@@ -121,14 +136,16 @@ exports.EVOLUTION_MANAGED_REDIS_CONFIG = {
121
136
  space: {
122
137
  label: 'Диск',
123
138
  accessorKey: 'diskCapacity',
124
- defaultValue: 40,
139
+ defaultValue: DISK_CAPACITY_MIN,
125
140
  uiProps: {
126
- min: 40,
127
- max: 16384,
141
+ min: DISK_CAPACITY_MIN,
142
+ max: DISK_CAPACITY_MAX,
128
143
  },
144
+ watchedControls: { ramAmount: 'ramAmount' },
145
+ relateFn: getMinMaxDiskSize,
129
146
  },
130
147
  specification: {
131
- accessorKey: 'specification',
148
+ accessorKey: 'diskType',
132
149
  defaultValue: 'SSD',
133
150
  uiProps: {
134
151
  disabled: true,
@@ -1,19 +1,28 @@
1
1
  import { CONTROL } from '../../../../components';
2
- import { generateCpuItems, generateInstanceConfigItems, getDisk } from '../../../utils';
2
+ import { generateCpuItems, generateRamItems, getDisk } from '../../../utils';
3
3
  import { DeploymentMode, deploymentModes } from '../constants';
4
- const nodeConfigItems = generateInstanceConfigItems([
5
- [2, 4],
6
- [4, 16],
7
- [8, 32],
8
- ]);
4
+ const CPU = [2, 4, 8, 16];
5
+ const RAM = [4, 8, 16, 32, 64, 128];
6
+ const DISK_CAPACITY_MIN = 10;
7
+ const DISK_CAPACITY_MAX = 16384;
8
+ const cpuToRamMap = {
9
+ '2': [4, 8, 16],
10
+ '4': [16, 32, 64],
11
+ '8': [32, 64, 128],
12
+ '16': [64, 128],
13
+ };
14
+ const ramToMinDisk = {
15
+ '4': DISK_CAPACITY_MIN,
16
+ '8': 40,
17
+ '16': 40,
18
+ '32': 64,
19
+ '64': 128,
20
+ '128': 256,
21
+ };
9
22
  const valueMasterReplica = 'Master/Replica';
10
23
  const valueStandalone = 'Standalone';
11
24
  const hostsByStandalone = [1];
12
25
  const hostsByMasterReplica = [3];
13
- const shardQuantityItemsByInstantType = {
14
- [valueStandalone]: [1],
15
- [valueMasterReplica]: [1],
16
- };
17
26
  const hostsByInstantType = {
18
27
  [valueStandalone]: hostsByStandalone,
19
28
  [valueMasterReplica]: hostsByMasterReplica,
@@ -22,7 +31,7 @@ const instanceTypePartCards = [
22
31
  {
23
32
  value: valueStandalone,
24
33
  label: valueStandalone,
25
- description: 'Одноузловая конфигурация',
34
+ description: 'Конфигурация с одним хостом',
26
35
  },
27
36
  {
28
37
  value: valueMasterReplica,
@@ -30,8 +39,14 @@ const instanceTypePartCards = [
30
39
  description: 'Отказоустойчивый кластер высокой доступности',
31
40
  },
32
41
  ];
42
+ const getMinMaxDiskSize = ({ ramAmount }) => ({
43
+ uiProps: {
44
+ min: ramToMinDisk[ramAmount] || DISK_CAPACITY_MIN,
45
+ max: DISK_CAPACITY_MAX,
46
+ },
47
+ });
33
48
  export const EVOLUTION_MANAGED_REDIS_CONFIG = {
34
- ui: ['deploymentMode', 'instanceType', 'masterNodeConfig', ['hostsQuantity', 'shardQuantity'], ['systemDisk']],
49
+ ui: ['deploymentMode', 'instanceType', ['vCpuCoreCount', 'ramAmount'], 'hostQuantity', ['systemDisk']],
35
50
  controls: {
36
51
  deploymentMode: {
37
52
  type: CONTROL.Carousel,
@@ -58,47 +73,47 @@ export const EVOLUTION_MANAGED_REDIS_CONFIG = {
58
73
  if (value === valueStandalone) {
59
74
  setValue([
60
75
  ['instanceType', value],
61
- ['hostsQuantity', hostsByStandalone[0].toString()],
76
+ ['hostQuantity', hostsByStandalone[0].toString()],
62
77
  ]);
63
78
  }
64
79
  else {
65
80
  setValue([
66
81
  ['instanceType', value],
67
- ['hostsQuantity', hostsByMasterReplica[0].toString()],
82
+ ['hostQuantity', hostsByMasterReplica[0].toString()],
68
83
  ]);
69
84
  }
70
85
  },
71
86
  },
72
- masterNodeConfig: {
73
- type: CONTROL.SelectSingle,
74
- accessorKey: 'masterNode.nodeConfig',
75
- items: nodeConfigItems,
87
+ vCpuCoreCount: {
88
+ type: CONTROL.Segmented,
89
+ accessorKey: 'vCpuCoreCount',
90
+ defaultValue: '2',
91
+ items: generateCpuItems(CPU),
76
92
  decoratorProps: {
77
- label: 'Конфигурация',
93
+ label: 'Количество ядер vCPU',
78
94
  },
79
- defaultValue: '2 4',
80
95
  },
81
- shardQuantity: {
96
+ ramAmount: {
82
97
  type: CONTROL.Segmented,
83
- accessorKey: 'shardQuantity',
84
- defaultValue: '1',
98
+ accessorKey: 'ramAmount',
99
+ watchedControls: { vCpuCoreCount: 'vCpuCoreCount' },
100
+ defaultValue: '4',
101
+ items: generateRamItems(RAM),
85
102
  decoratorProps: {
86
- label: 'Количество шардов',
103
+ label: 'Количество оперативной памяти (RAM)',
87
104
  },
88
- items: generateCpuItems([1]),
89
- watchedControls: { instanceType: 'instanceType' },
90
- relateFn: ({ instanceType }) => {
91
- const items = shardQuantityItemsByInstantType[instanceType];
92
- if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
105
+ relateFn: ({ vCpuCoreCount }) => {
106
+ const itemsByCpu = cpuToRamMap[vCpuCoreCount];
107
+ if ((itemsByCpu === null || itemsByCpu === void 0 ? void 0 : itemsByCpu.length) > 0) {
93
108
  return {
94
- items: generateCpuItems(items),
109
+ items: generateRamItems(itemsByCpu),
95
110
  };
96
111
  }
97
112
  },
98
113
  },
99
- hostsQuantity: {
114
+ hostQuantity: {
100
115
  type: CONTROL.Segmented,
101
- accessorKey: 'hostsQuantity',
116
+ accessorKey: 'hostQuantity',
102
117
  defaultValue: '1',
103
118
  decoratorProps: {
104
119
  label: 'Количество хостов',
@@ -118,14 +133,16 @@ export const EVOLUTION_MANAGED_REDIS_CONFIG = {
118
133
  space: {
119
134
  label: 'Диск',
120
135
  accessorKey: 'diskCapacity',
121
- defaultValue: 40,
136
+ defaultValue: DISK_CAPACITY_MIN,
122
137
  uiProps: {
123
- min: 40,
124
- max: 16384,
138
+ min: DISK_CAPACITY_MIN,
139
+ max: DISK_CAPACITY_MAX,
125
140
  },
141
+ watchedControls: { ramAmount: 'ramAmount' },
142
+ relateFn: getMinMaxDiskSize,
126
143
  },
127
144
  specification: {
128
- accessorKey: 'specification',
145
+ accessorKey: 'diskType',
129
146
  defaultValue: 'SSD',
130
147
  uiProps: {
131
148
  disabled: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloud-ru/uikit-product-calculator",
3
3
  "title": "Calculator",
4
- "version": "2.3.0",
4
+ "version": "2.3.1-preview-4956dd38.0",
5
5
  "sideEffects": [
6
6
  "*.css",
7
7
  "*.woff",
@@ -60,12 +60,12 @@
60
60
  "deepmerge": "^4.3.1",
61
61
  "lodash": "^4.18.1",
62
62
  "swr": "^2.2.5",
63
- "@cloud-ru/uikit-product-icons": "^19.2.0",
64
- "@cloud-ru/uikit-product-mobile-dropdown": "^3.0.2",
65
- "@cloud-ru/uikit-product-mobile-fields": "^3.0.2",
66
- "@cloud-ru/uikit-product-mobile-modal": "^3.0.2",
67
- "@cloud-ru/uikit-product-mobile-accordion": "^2.0.2",
68
- "@cloud-ru/uikit-product-utils": "^10.0.0"
63
+ "@cloud-ru/uikit-product-icons": "19.2.0",
64
+ "@cloud-ru/uikit-product-mobile-accordion": "2.0.2",
65
+ "@cloud-ru/uikit-product-mobile-fields": "3.0.2",
66
+ "@cloud-ru/uikit-product-mobile-modal": "3.0.2",
67
+ "@cloud-ru/uikit-product-utils": "10.0.0",
68
+ "@cloud-ru/uikit-product-mobile-dropdown": "3.0.2"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/lodash": "4.17.24"
@@ -1,12 +1,28 @@
1
1
  import { CONTROL, FormConfig } from '../../../../components';
2
- import { generateCpuItems, generateInstanceConfigItems, getDisk } from '../../../utils';
2
+ import { generateCpuItems, generateRamItems, getDisk } from '../../../utils';
3
3
  import { DeploymentMode, deploymentModes } from '../constants';
4
4
 
5
- const nodeConfigItems = generateInstanceConfigItems([
6
- [2, 4],
7
- [4, 16],
8
- [8, 32],
9
- ]);
5
+ const CPU = [2, 4, 8, 16];
6
+ const RAM = [4, 8, 16, 32, 64, 128];
7
+
8
+ const DISK_CAPACITY_MIN = 10;
9
+ const DISK_CAPACITY_MAX = 16384;
10
+
11
+ const cpuToRamMap: Record<string, number[]> = {
12
+ '2': [4, 8, 16],
13
+ '4': [16, 32, 64],
14
+ '8': [32, 64, 128],
15
+ '16': [64, 128],
16
+ };
17
+
18
+ const ramToMinDisk: Record<string, number> = {
19
+ '4': DISK_CAPACITY_MIN,
20
+ '8': 40,
21
+ '16': 40,
22
+ '32': 64,
23
+ '64': 128,
24
+ '128': 256,
25
+ };
10
26
 
11
27
  const valueMasterReplica = 'Master/Replica';
12
28
  const valueStandalone = 'Standalone';
@@ -14,11 +30,6 @@ const valueStandalone = 'Standalone';
14
30
  const hostsByStandalone = [1];
15
31
  const hostsByMasterReplica = [3];
16
32
 
17
- const shardQuantityItemsByInstantType: { [key: string]: number[] } = {
18
- [valueStandalone]: [1],
19
- [valueMasterReplica]: [1],
20
- };
21
-
22
33
  const hostsByInstantType: { [key: string]: number[] } = {
23
34
  [valueStandalone]: hostsByStandalone,
24
35
  [valueMasterReplica]: hostsByMasterReplica,
@@ -28,7 +39,7 @@ const instanceTypePartCards = [
28
39
  {
29
40
  value: valueStandalone,
30
41
  label: valueStandalone,
31
- description: 'Одноузловая конфигурация',
42
+ description: 'Конфигурация с одним хостом',
32
43
  },
33
44
  {
34
45
  value: valueMasterReplica,
@@ -37,8 +48,15 @@ const instanceTypePartCards = [
37
48
  },
38
49
  ];
39
50
 
51
+ const getMinMaxDiskSize = ({ ramAmount }: { ramAmount: string }) => ({
52
+ uiProps: {
53
+ min: ramToMinDisk[ramAmount] || DISK_CAPACITY_MIN,
54
+ max: DISK_CAPACITY_MAX,
55
+ },
56
+ });
57
+
40
58
  export const EVOLUTION_MANAGED_REDIS_CONFIG: FormConfig = {
41
- ui: ['deploymentMode', 'instanceType', 'masterNodeConfig', ['hostsQuantity', 'shardQuantity'], ['systemDisk']],
59
+ ui: ['deploymentMode', 'instanceType', ['vCpuCoreCount', 'ramAmount'], 'hostQuantity', ['systemDisk']],
42
60
  controls: {
43
61
  deploymentMode: {
44
62
  type: CONTROL.Carousel,
@@ -65,47 +83,48 @@ export const EVOLUTION_MANAGED_REDIS_CONFIG: FormConfig = {
65
83
  if (value === valueStandalone) {
66
84
  setValue([
67
85
  ['instanceType', value],
68
- ['hostsQuantity', hostsByStandalone[0].toString()],
86
+ ['hostQuantity', hostsByStandalone[0].toString()],
69
87
  ]);
70
88
  } else {
71
89
  setValue([
72
90
  ['instanceType', value],
73
- ['hostsQuantity', hostsByMasterReplica[0].toString()],
91
+ ['hostQuantity', hostsByMasterReplica[0].toString()],
74
92
  ]);
75
93
  }
76
94
  },
77
95
  },
78
- masterNodeConfig: {
79
- type: CONTROL.SelectSingle,
80
- accessorKey: 'masterNode.nodeConfig',
81
- items: nodeConfigItems,
96
+ vCpuCoreCount: {
97
+ type: CONTROL.Segmented,
98
+ accessorKey: 'vCpuCoreCount',
99
+ defaultValue: '2',
100
+ items: generateCpuItems(CPU),
82
101
  decoratorProps: {
83
- label: 'Конфигурация',
102
+ label: 'Количество ядер vCPU',
84
103
  },
85
- defaultValue: '2 4',
86
104
  },
87
- shardQuantity: {
105
+
106
+ ramAmount: {
88
107
  type: CONTROL.Segmented,
89
- accessorKey: 'shardQuantity',
90
- defaultValue: '1',
108
+ accessorKey: 'ramAmount',
109
+ watchedControls: { vCpuCoreCount: 'vCpuCoreCount' },
110
+ defaultValue: '4',
111
+ items: generateRamItems(RAM),
91
112
  decoratorProps: {
92
- label: 'Количество шардов',
113
+ label: 'Количество оперативной памяти (RAM)',
93
114
  },
94
- items: generateCpuItems([1]),
95
- watchedControls: { instanceType: 'instanceType' },
96
- relateFn: ({ instanceType }) => {
97
- const items = shardQuantityItemsByInstantType[instanceType];
115
+ relateFn: ({ vCpuCoreCount }: { vCpuCoreCount: string }) => {
116
+ const itemsByCpu = cpuToRamMap[vCpuCoreCount];
98
117
 
99
- if (items?.length > 0) {
118
+ if (itemsByCpu?.length > 0) {
100
119
  return {
101
- items: generateCpuItems(items),
120
+ items: generateRamItems(itemsByCpu),
102
121
  };
103
122
  }
104
123
  },
105
124
  },
106
- hostsQuantity: {
125
+ hostQuantity: {
107
126
  type: CONTROL.Segmented,
108
- accessorKey: 'hostsQuantity',
127
+ accessorKey: 'hostQuantity',
109
128
  defaultValue: '1',
110
129
  decoratorProps: {
111
130
  label: 'Количество хостов',
@@ -126,14 +145,16 @@ export const EVOLUTION_MANAGED_REDIS_CONFIG: FormConfig = {
126
145
  space: {
127
146
  label: 'Диск',
128
147
  accessorKey: 'diskCapacity',
129
- defaultValue: 40,
148
+ defaultValue: DISK_CAPACITY_MIN,
130
149
  uiProps: {
131
- min: 40,
132
- max: 16_384,
150
+ min: DISK_CAPACITY_MIN,
151
+ max: DISK_CAPACITY_MAX,
133
152
  },
153
+ watchedControls: { ramAmount: 'ramAmount' },
154
+ relateFn: getMinMaxDiskSize,
134
155
  },
135
156
  specification: {
136
- accessorKey: 'specification',
157
+ accessorKey: 'diskType',
137
158
  defaultValue: 'SSD',
138
159
  uiProps: {
139
160
  disabled: true,