@orchestrator-ui/orchestrator-ui-components 2.14.0 → 2.14.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Library of UI Components used to display the workflow orchestrator frontend",
6
6
  "author": {
@@ -14,18 +14,29 @@
14
14
  */
15
15
  import React, { useState } from 'react';
16
16
 
17
- import { useTranslations } from 'next-intl';
18
17
  import { connectField, filterDOMProps } from 'uniforms';
19
18
 
20
- import { EuiCallOut, EuiFormRow, EuiText } from '@elastic/eui';
19
+ import { EuiFormRow, EuiText } from '@elastic/eui';
21
20
 
22
21
  import { getCommonFormFieldStyles } from '@/components/WfoForms/formFields/commonStyles';
23
22
  import SplitPrefix from '@/components/WfoForms/formFields/deprecated/SplitPrefix';
24
23
  import { useWithOrchestratorTheme } from '@/hooks';
25
24
 
26
25
  import { FieldProps } from '../types';
27
- import IpPrefixTableField from './IpPrefixTableField';
28
- import { IpBlock } from './types';
26
+
27
+ export function getUsedPrefixMin(
28
+ netmask: string,
29
+ prefixMin: number | undefined,
30
+ name: string,
31
+ ) {
32
+ const netMaskInt = parseInt(netmask, 10);
33
+ return (
34
+ prefixMin ??
35
+ (netMaskInt < 32 && name === 'ip_sub_prefix'
36
+ ? netMaskInt + 1
37
+ : netMaskInt)
38
+ );
39
+ }
29
40
 
30
41
  export type IPvAnyNetworkFieldProps = FieldProps<
31
42
  string,
@@ -48,17 +59,13 @@ function IpNetwork({
48
59
  }: IPvAnyNetworkFieldProps) {
49
60
  const { formRowStyle } = useWithOrchestratorTheme(getCommonFormFieldStyles);
50
61
 
51
- const t = useTranslations('pydanticForms');
52
- const [selectedPrefix, setSelectedPrefix] = useState<IpBlock | undefined>(
53
- undefined,
54
- );
55
- const [manualOverride, setManualOverride] = useState(false);
62
+ // The state is needed in order to keep the selected prefix in the SplitPrefix component
63
+ const [selectedPrefix] = useState<string | undefined>(value);
56
64
 
57
- const usePrefix = selectedPrefix?.prefix ?? value;
65
+ const usePrefix = selectedPrefix;
58
66
  const [subnet, netmask] = usePrefix?.split('/') ?? ['', ''];
59
- const usedPrefixMin =
60
- prefixMin ??
61
- parseInt(netmask, 10) + (selectedPrefix?.state === 0 ? 0 : 1);
67
+
68
+ const usedPrefixMin = getUsedPrefixMin(netmask, prefixMin, name);
62
69
 
63
70
  return (
64
71
  <section {...filterDOMProps(props)}>
@@ -73,32 +80,7 @@ function IpNetwork({
73
80
  >
74
81
  <section className="ipblock-selector">
75
82
  <div id={id}>
76
- {!prefixMin && (
77
- <IpPrefixTableField
78
- id={id}
79
- name={name}
80
- onChange={(prefix: IpBlock) => {
81
- if (!readOnly) {
82
- if (
83
- prefix.state === 0 ||
84
- prefix.state === 1
85
- ) {
86
- setSelectedPrefix(prefix);
87
- }
88
- setManualOverride(false);
89
- onChange(prefix.prefix);
90
- }
91
- }}
92
- onManualOverride={(prefixString: string) => {
93
- if (!readOnly) {
94
- setManualOverride(true);
95
- onChange(prefixString);
96
- }
97
- }}
98
- selected_prefix_id={selectedPrefix?.id}
99
- />
100
- )}
101
- {usePrefix && !manualOverride && (
83
+ {usePrefix && (
102
84
  <SplitPrefix
103
85
  id={id}
104
86
  name={name}
@@ -113,17 +95,6 @@ function IpNetwork({
113
95
  selectedSubnet={usePrefix}
114
96
  />
115
97
  )}
116
- {usePrefix && manualOverride && (
117
- <EuiCallOut
118
- title={t(
119
- 'widgets.ipvAnyNetworkField.manuallySelectedPrefix',
120
- )}
121
- color="primary"
122
- iconType="check"
123
- >
124
- <p>{value}</p>
125
- </EuiCallOut>
126
- )}
127
98
  </div>
128
99
  </section>
129
100
  </EuiFormRow>
@@ -1 +1 @@
1
- export const ORCHESTRATOR_UI_LIBRARY_VERSION = '2.14.0';
1
+ export const ORCHESTRATOR_UI_LIBRARY_VERSION = '2.14.1';
@@ -5,6 +5,11 @@ describe('getFirstUuidPart()', () => {
5
5
  const result = getFirstUuidPart('12345678-1234-1234-1234-123456789abc');
6
6
  expect(result).toEqual('12345678');
7
7
  });
8
+
9
+ it('returns empty string for empty uuid', () => {
10
+ const result = getFirstUuidPart();
11
+ expect(result).toEqual('');
12
+ });
8
13
  });
9
14
 
10
15
  describe('isUuid4()', () => {
package/src/utils/uuid.ts CHANGED
@@ -1,4 +1,5 @@
1
- export const getFirstUuidPart = (uuid: string): string => uuid.slice(0, 8);
1
+ export const getFirstUuidPart = (uuid?: string): string =>
2
+ uuid ? uuid.slice(0, 8) : '';
2
3
 
3
4
  export const isUuid4 = (value: string): boolean =>
4
5
  !!value.match(