@openshift-assisted/ui-lib 2.9.9-cim → 2.9.11-cim

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.
Files changed (161) hide show
  1. package/build/@types/cim/components/ClusterDeployment/ScaleUpForm.d.ts +1 -0
  2. package/build/@types/cim/components/ClusterDeployment/ScaleUpForm.d.ts.map +1 -1
  3. package/build/@types/cim/components/InfraEnv/utils.d.ts.map +1 -1
  4. package/build/@types/cim/components/modals/ScaleUpModal.d.ts +1 -0
  5. package/build/@types/cim/components/modals/ScaleUpModal.d.ts.map +1 -1
  6. package/build/@types/cim/index.d.ts +1 -0
  7. package/build/@types/cim/index.d.ts.map +1 -1
  8. package/build/@types/cim/types/k8s/agent-cluster-install.d.ts +1 -1
  9. package/build/@types/cim/types/k8s/agent-cluster-install.d.ts.map +1 -1
  10. package/build/@types/common/api/utils.d.ts +1 -1
  11. package/build/@types/common/api/utils.d.ts.map +1 -1
  12. package/build/@types/common/index.d.ts +1 -0
  13. package/build/@types/common/index.d.ts.map +1 -1
  14. package/build/@types/common/types/index.d.ts +0 -8
  15. package/build/@types/common/types/index.d.ts.map +1 -1
  16. package/build/@types/common/types/resource-ui-state.d.ts +9 -0
  17. package/build/@types/common/types/resource-ui-state.d.ts.map +1 -0
  18. package/build/@types/ocm/components/Routes.d.ts.map +1 -1
  19. package/build/@types/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.d.ts.map +1 -1
  20. package/build/@types/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.d.ts +1 -1
  21. package/build/@types/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.d.ts.map +1 -1
  22. package/build/@types/ocm/components/hosts/DeleteHostModal.d.ts.map +1 -1
  23. package/build/@types/ocm/config/external-features.d.ts +8 -0
  24. package/build/@types/ocm/config/external-features.d.ts.map +1 -0
  25. package/build/@types/ocm/config/index.d.ts +1 -1
  26. package/build/@types/ocm/config/{routeBaseBath.d.ts → routeBasePath.d.ts} +1 -1
  27. package/build/@types/ocm/config/routeBasePath.d.ts.map +1 -0
  28. package/build/@types/ocm/hooks/use-feature-detection.d.ts +3 -0
  29. package/build/@types/ocm/hooks/use-feature-detection.d.ts.map +1 -0
  30. package/build/@types/ocm/services/ClusterDetailsService.d.ts.map +1 -1
  31. package/build/@types/ocm/services/ClustersService.d.ts +3 -3
  32. package/build/@types/ocm/services/ClustersService.d.ts.map +1 -1
  33. package/build/@types/ocm/services/InfraEnvIdsCacheService.d.ts +2 -2
  34. package/build/@types/ocm/services/InfraEnvIdsCacheService.d.ts.map +1 -1
  35. package/build/@types/ocm/store/hooks.d.ts +17 -5
  36. package/build/@types/ocm/store/hooks.d.ts.map +1 -1
  37. package/build/@types/ocm/store/index.d.ts +1 -3
  38. package/build/@types/ocm/store/index.d.ts.map +1 -1
  39. package/build/@types/ocm/store/slices/clusters/selectors.d.ts +6 -3
  40. package/build/@types/ocm/store/slices/clusters/selectors.d.ts.map +1 -1
  41. package/build/@types/ocm/store/slices/clusters/slice.d.ts +2 -2
  42. package/build/@types/ocm/store/slices/clusters/slice.d.ts.map +1 -1
  43. package/build/@types/ocm/store/slices/current-cluster/slice.d.ts +4 -3
  44. package/build/@types/ocm/store/slices/current-cluster/slice.d.ts.map +1 -1
  45. package/build/@types/ocm/store/slices/current-user/slice.d.ts +46 -0
  46. package/build/@types/ocm/store/slices/current-user/slice.d.ts.map +1 -0
  47. package/build/@types/ocm/store/slices/feature-flags/selectors.d.ts +18 -4
  48. package/build/@types/ocm/store/slices/feature-flags/selectors.d.ts.map +1 -1
  49. package/build/@types/ocm/store/slices/feature-flags/slice.d.ts +26 -5
  50. package/build/@types/ocm/store/slices/feature-flags/slice.d.ts.map +1 -1
  51. package/build/@types/ocm/store/slices/infra-envs/selectors.d.ts +2 -1
  52. package/build/@types/ocm/store/slices/infra-envs/selectors.d.ts.map +1 -1
  53. package/build/@types/ocm/store/store-day1.d.ts +4 -2
  54. package/build/@types/ocm/store/store-day1.d.ts.map +1 -1
  55. package/build/@types/ocm/store/types/state-slice.d.ts +16 -0
  56. package/build/@types/ocm/store/types/state-slice.d.ts.map +1 -0
  57. package/build/cjs/cim/components/ClusterDeployment/ScaleUpForm.js +7 -4
  58. package/build/cjs/cim/components/ClusterDeployment/ScaleUpForm.js.map +1 -1
  59. package/build/cjs/cim/components/InfraEnv/utils.js +6 -6
  60. package/build/cjs/cim/components/InfraEnv/utils.js.map +1 -1
  61. package/build/cjs/cim/components/modals/ScaleUpModal.js +2 -2
  62. package/build/cjs/cim/components/modals/ScaleUpModal.js.map +1 -1
  63. package/build/cjs/cim/index.js +3 -1
  64. package/build/cjs/cim/index.js.map +1 -1
  65. package/build/cjs/common/index.js +3 -0
  66. package/build/cjs/common/index.js.map +1 -1
  67. package/build/cjs/common/types/index.js +0 -10
  68. package/build/cjs/common/types/index.js.map +1 -1
  69. package/build/cjs/common/types/resource-ui-state.js +13 -0
  70. package/build/cjs/common/types/resource-ui-state.js.map +1 -0
  71. package/build/cjs/ocm/components/HostsClusterDetailTab/HostsClusterDetailTab.js +2 -2
  72. package/build/cjs/ocm/components/HostsClusterDetailTab/HostsClusterDetailTab.js.map +1 -1
  73. package/build/cjs/ocm/components/Routes.js +3 -5
  74. package/build/cjs/ocm/components/Routes.js.map +1 -1
  75. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.js +4 -1
  76. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.js.map +1 -1
  77. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.js +5 -2
  78. package/build/cjs/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.js.map +1 -1
  79. package/build/cjs/ocm/components/hosts/DeleteHostModal.js +8 -7
  80. package/build/cjs/ocm/components/hosts/DeleteHostModal.js.map +1 -1
  81. package/build/cjs/ocm/config/external-features.js +10 -0
  82. package/build/cjs/ocm/config/external-features.js.map +1 -0
  83. package/build/cjs/ocm/config/index.js +1 -1
  84. package/build/cjs/ocm/config/{routeBaseBath.js → routeBasePath.js} +1 -1
  85. package/build/cjs/ocm/config/routeBasePath.js.map +1 -0
  86. package/build/cjs/ocm/hooks/use-feature-detection.js +14 -0
  87. package/build/cjs/ocm/hooks/use-feature-detection.js.map +1 -0
  88. package/build/cjs/ocm/services/ClusterDetailsService.js +0 -3
  89. package/build/cjs/ocm/services/ClusterDetailsService.js.map +1 -1
  90. package/build/cjs/ocm/services/ClustersService.js +19 -19
  91. package/build/cjs/ocm/services/ClustersService.js.map +1 -1
  92. package/build/cjs/ocm/services/InfraEnvIdsCacheService.js +5 -5
  93. package/build/cjs/ocm/services/InfraEnvIdsCacheService.js.map +1 -1
  94. package/build/cjs/ocm/store/hooks.js +2 -4
  95. package/build/cjs/ocm/store/hooks.js.map +1 -1
  96. package/build/cjs/ocm/store/index.js +1 -5
  97. package/build/cjs/ocm/store/index.js.map +1 -1
  98. package/build/cjs/ocm/store/slices/clusters/slice.js +9 -8
  99. package/build/cjs/ocm/store/slices/clusters/slice.js.map +1 -1
  100. package/build/cjs/ocm/store/slices/current-cluster/slice.js +14 -13
  101. package/build/cjs/ocm/store/slices/current-cluster/slice.js.map +1 -1
  102. package/build/cjs/ocm/store/slices/current-user/slice.js +109 -0
  103. package/build/cjs/ocm/store/slices/current-user/slice.js.map +1 -0
  104. package/build/cjs/ocm/store/slices/feature-flags/selectors.js +1 -4
  105. package/build/cjs/ocm/store/slices/feature-flags/selectors.js.map +1 -1
  106. package/build/cjs/ocm/store/slices/feature-flags/slice.js +79 -6
  107. package/build/cjs/ocm/store/slices/feature-flags/slice.js.map +1 -1
  108. package/build/cjs/ocm/store/slices/infra-envs/thunks.js +1 -1
  109. package/build/cjs/ocm/store/slices/infra-envs/thunks.js.map +1 -1
  110. package/build/cjs/ocm/store/store-day1.js +2 -4
  111. package/build/cjs/ocm/store/store-day1.js.map +1 -1
  112. package/build/cjs/ocm/store/types/state-slice.js +3 -0
  113. package/build/cjs/ocm/store/types/state-slice.js.map +1 -0
  114. package/lib/@types/assets.d.ts +1 -1
  115. package/lib/@types/global.d.ts +1 -0
  116. package/lib/_test-helpers/mock-container.ts +42 -0
  117. package/lib/_test-helpers/mock-server.ts +26 -0
  118. package/lib/_test-helpers/vitest-setup.ts +17 -0
  119. package/lib/cim/components/ClusterDeployment/ScaleUpForm.tsx +11 -5
  120. package/lib/cim/components/InfraEnv/utils.ts +7 -6
  121. package/lib/cim/components/modals/ScaleUpModal.tsx +3 -0
  122. package/lib/cim/index.ts +1 -0
  123. package/lib/cim/types/k8s/agent-cluster-install.ts +4 -7
  124. package/lib/common/api/utils.ts +1 -1
  125. package/lib/common/index.ts +1 -0
  126. package/lib/common/types/index.ts +0 -9
  127. package/lib/common/types/resource-ui-state.ts +8 -0
  128. package/lib/ocm/components/HostsClusterDetailTab/HostsClusterDetailTab.tsx +2 -2
  129. package/lib/ocm/components/Routes.tsx +3 -5
  130. package/lib/ocm/components/clusterConfiguration/networkConfiguration/NetworkConfigurationForm.tsx +7 -2
  131. package/lib/ocm/components/clusterConfiguration/networkConfiguration/networkConfigurationValidation.ts +6 -1
  132. package/lib/ocm/components/hosts/DeleteHostModal.tsx +28 -23
  133. package/lib/ocm/config/external-features.ts +12 -0
  134. package/lib/ocm/config/index.ts +1 -1
  135. package/lib/ocm/hooks/_use-feature-detection.test.tsx +125 -0
  136. package/lib/ocm/hooks/use-feature-detection.ts +17 -0
  137. package/lib/ocm/services/ClusterDetailsService.ts +0 -4
  138. package/lib/ocm/services/ClustersService.ts +9 -9
  139. package/lib/ocm/services/InfraEnvIdsCacheService.ts +2 -2
  140. package/lib/ocm/store/hooks.ts +1 -4
  141. package/lib/ocm/store/index.ts +1 -3
  142. package/lib/ocm/store/slices/clusters/slice.ts +5 -4
  143. package/lib/ocm/store/slices/current-cluster/slice.ts +9 -15
  144. package/lib/ocm/store/slices/current-user/slice.ts +129 -0
  145. package/lib/ocm/store/slices/feature-flags/selectors.ts +6 -7
  146. package/lib/ocm/store/slices/feature-flags/slice.ts +102 -7
  147. package/lib/ocm/store/slices/infra-envs/thunks.ts +1 -1
  148. package/lib/ocm/store/store-day1.ts +2 -4
  149. package/lib/ocm/store/types/state-slice.ts +16 -0
  150. package/package.json +17 -5
  151. package/build/@types/ocm/config/routeBaseBath.d.ts.map +0 -1
  152. package/build/@types/ocm/store/store-day2.d.ts +0 -10
  153. package/build/@types/ocm/store/store-day2.d.ts.map +0 -1
  154. package/build/cjs/ocm/config/routeBaseBath.js.map +0 -1
  155. package/build/cjs/ocm/store/store-day2.js +0 -20
  156. package/build/cjs/ocm/store/store-day2.js.map +0 -1
  157. package/lib/ocm/store/store-day2.ts +0 -19
  158. /package/lib/cim/components/ClusterDeployment/{wizardTransition.test.ts → _wizardTransition.test.ts} +0 -0
  159. /package/lib/common/components/ui/formik/{validationSchemas.test.ts → _validationSchemas.test.ts} +0 -0
  160. /package/lib/ocm/components/clusterWizard/{wizardTransition.test.ts → _wizardTransition.test.ts} +0 -0
  161. /package/lib/ocm/config/{routeBaseBath.ts → routeBasePath.ts} +0 -0
@@ -15,24 +15,30 @@ type ScaleUpFormProps = {
15
15
  agents: AgentK8sResource[];
16
16
  onEditHost: AgentTableActions['onEditHost'];
17
17
  onSetInstallationDiskId: AgentTableActions['onSetInstallationDiskId'];
18
+ isNutanix: boolean;
18
19
  };
19
20
 
20
21
  const ScaleUpForm: React.FC<ScaleUpFormProps> = ({
21
22
  agents,
22
23
  onEditHost,
23
24
  onSetInstallationDiskId,
25
+ isNutanix,
24
26
  }) => {
25
27
  const { values } = useFormikContext<ScaleUpFormValues>();
26
28
  const { autoSelectHosts } = values;
27
29
  const availableAgents = React.useMemo(
28
30
  () =>
29
- getAgentsForSelection(agents).filter(
30
- (agent) =>
31
+ getAgentsForSelection(agents).filter((agent) => {
32
+ if (isNutanix && agent.status?.inventory?.systemVendor?.manufacturer !== 'Nutanix') {
33
+ return false;
34
+ }
35
+ return (
31
36
  !(
32
37
  agent.spec?.clusterDeploymentName?.name || agent.spec?.clusterDeploymentName?.namespace
33
- ) && agent.status?.inventory.cpu?.architecture === values.cpuArchitecture,
34
- ),
35
- [agents, values.cpuArchitecture],
38
+ ) && agent.status?.inventory.cpu?.architecture === values.cpuArchitecture
39
+ );
40
+ }),
41
+ [agents, values.cpuArchitecture, isNutanix],
36
42
  );
37
43
  const { t } = useTranslation();
38
44
  return (
@@ -51,12 +51,6 @@ export const getAgentClusterInstall = ({
51
51
  // @ts-ignore
52
52
  spec: {
53
53
  holdInstallation: true,
54
- clusterDeploymentRef: clusterDeploymentName
55
- ? {
56
- name: clusterDeploymentName,
57
- namespace,
58
- }
59
- : {},
60
54
  networking: {
61
55
  clusterNetwork: [
62
56
  {
@@ -75,6 +69,13 @@ export const getAgentClusterInstall = ({
75
69
  },
76
70
  };
77
71
 
72
+ if (obj.spec && clusterDeploymentName) {
73
+ obj.spec.clusterDeploymentRef = {
74
+ name: clusterDeploymentName,
75
+ namespace,
76
+ };
77
+ }
78
+
78
79
  if (obj.spec && values.sshPublicKey) {
79
80
  obj.spec.sshPublicKey = values.sshPublicKey;
80
81
  }
@@ -58,6 +58,7 @@ type ScaleUpModalProps = {
58
58
  agents: AgentK8sResource[];
59
59
  onChangeHostname: (agent: AgentK8sResource, hostname: string) => Promise<AgentK8sResource>;
60
60
  onSetInstallationDiskId: AgentTableActions['onSetInstallationDiskId'];
61
+ isNutanix: boolean;
61
62
  };
62
63
 
63
64
  const ScaleUpModal: React.FC<ScaleUpModalProps> = ({
@@ -68,6 +69,7 @@ const ScaleUpModal: React.FC<ScaleUpModalProps> = ({
68
69
  agents,
69
70
  onChangeHostname,
70
71
  onSetInstallationDiskId,
72
+ isNutanix,
71
73
  }) => {
72
74
  const [editAgent, setEditAgent] = React.useState<AgentK8sResource | undefined>();
73
75
  const [error, setError] = React.useState<string | undefined>();
@@ -138,6 +140,7 @@ const ScaleUpModal: React.FC<ScaleUpModalProps> = ({
138
140
  agents={agents}
139
141
  onEditHost={setEditAgent}
140
142
  onSetInstallationDiskId={onSetInstallationDiskId}
143
+ isNutanix={isNutanix}
141
144
  />
142
145
  </StackItem>
143
146
  {error && (
package/lib/cim/index.ts CHANGED
@@ -15,3 +15,4 @@ export * from '../common/components/clusterWizard/types';
15
15
  export * from '../common/components/clusterDetail';
16
16
  export * from '../common/components/clusterConfiguration';
17
17
  export * from '../common/types/clusters';
18
+ export { ResourceUIState } from '../common';
@@ -16,13 +16,10 @@ export type AgentClusterInstallStatusCondition =
16
16
 
17
17
  export type AgentClusterInstallK8sResource = K8sResourceCommon & {
18
18
  spec?: {
19
- clusterDeploymentRef?:
20
- | {
21
- name: string;
22
- namespace: string;
23
- }
24
- // eslint-disable-next-line @typescript-eslint/ban-types
25
- | {};
19
+ clusterDeploymentRef?: {
20
+ name: string;
21
+ namespace: string;
22
+ };
26
23
  clusterMetadata?: {
27
24
  adminKubeconfigSecretRef?: {
28
25
  name: string;
@@ -1,7 +1,7 @@
1
1
  import Axios, { AxiosError } from 'axios';
2
2
  import * as Sentry from '@sentry/browser';
3
3
  import pick from 'lodash-es/pick.js';
4
- import {
4
+ import type {
5
5
  Error as APIError,
6
6
  InfraError,
7
7
  } from '@openshift-assisted/types/assisted-installer-service';
@@ -9,3 +9,4 @@ export * from './config';
9
9
  export * from './features';
10
10
  export * from './reducers';
11
11
  export * from './selectors';
12
+ export { ResourceUIState } from './types/resource-ui-state';
@@ -1,12 +1,3 @@
1
- export enum ResourceUIState {
2
- LOADING = 'LOADING',
3
- RELOADING = 'RELOADING',
4
- EMPTY = 'EMPTY',
5
- LOADED = 'LOADED',
6
- POLLING_ERROR = 'POLLING_ERROR',
7
- UPDATE_ERROR = 'UPDATE_ERROR',
8
- }
9
-
10
1
  export type WithTestID = {
11
2
  testId?: string;
12
3
  };
@@ -0,0 +1,8 @@
1
+ export enum ResourceUIState {
2
+ LOADING = 'LOADING',
3
+ RELOADING = 'RELOADING',
4
+ EMPTY = 'EMPTY',
5
+ LOADED = 'LOADED',
6
+ POLLING_ERROR = 'POLLING_ERROR',
7
+ UPDATE_ERROR = 'UPDATE_ERROR',
8
+ }
@@ -5,10 +5,10 @@ import { AlertsContextProvider, FeatureGateContextProvider } from '../../../comm
5
5
  import { HostsClusterDetailTabContent } from './HostsClusterDetailTabContent';
6
6
  import { HostsClusterDetailTabProps } from './types';
7
7
  import { storeDay1 } from '../../store';
8
- import { featureFlagsActions } from '../../store/slices/feature-flags/slice';
8
+ import { useFeatureDetection } from '../../hooks/use-feature-detection';
9
9
 
10
10
  const HostsClusterDetailTab = (props: HostsClusterDetailTabProps) => {
11
- storeDay1.dispatch(featureFlagsActions.setFeatureFlags(props.allEnabledFeatures));
11
+ useFeatureDetection();
12
12
 
13
13
  return (
14
14
  <Provider store={storeDay1}>
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React from 'react';
2
2
  import { Provider } from 'react-redux';
3
3
  import { Switch, Route, Redirect } from 'react-router-dom';
4
4
  import { Clusters, ClusterPage, NewClusterPage } from './clusters';
@@ -7,15 +7,13 @@ import type { FeatureListType } from '../../common/features/featureGate';
7
7
  import { routeBasePath } from '../config';
8
8
  import { AssistedUILibVersion } from './ui';
9
9
  import { storeDay1 } from '../store';
10
- import { featureFlagsActions } from '../store/slices/feature-flags/slice';
10
+ import { useFeatureDetection } from '../hooks/use-feature-detection';
11
11
 
12
12
  export const Routes: React.FC<{ allEnabledFeatures: FeatureListType }> = ({
13
13
  allEnabledFeatures,
14
14
  children,
15
15
  }) => {
16
- useEffect(() => {
17
- storeDay1.dispatch(featureFlagsActions.setFeatureFlags(allEnabledFeatures));
18
- }, [allEnabledFeatures]);
16
+ useFeatureDetection(allEnabledFeatures);
19
17
 
20
18
  return (
21
19
  <Provider store={storeDay1}>
@@ -46,6 +46,7 @@ import {
46
46
  InfraEnv,
47
47
  V2ClusterUpdateParams,
48
48
  } from '@openshift-assisted/types/assisted-installer-service';
49
+ import { useNewFeatureSupportLevel } from '../../../../common/components/newFeatureSupportLevels';
49
50
 
50
51
  const NetworkConfigurationForm: React.FC<{
51
52
  cluster: Cluster;
@@ -157,10 +158,14 @@ const NetworkConfigurationPage = ({ cluster }: { cluster: Cluster }) => {
157
158
  const { addAlert, clearAlerts, alerts } = useAlerts();
158
159
  const dispatch = useDispatch();
159
160
  const { isViewerMode } = useSelector(selectCurrentClusterPermissionsState);
160
-
161
161
  const hostSubnets = React.useMemo(() => getHostSubnets(cluster, true), [cluster]);
162
+ const featureSupportLevelData = useNewFeatureSupportLevel();
163
+ const isClusterManagedNetworkingUnsupported = !featureSupportLevelData.isFeatureSupported(
164
+ 'CLUSTER_MANAGED_NETWORKING',
165
+ );
162
166
  const initialValues = React.useMemo(
163
- () => getNetworkInitialValues(cluster, defaultNetworkValues),
167
+ () =>
168
+ getNetworkInitialValues(cluster, defaultNetworkValues, isClusterManagedNetworkingUnsupported),
164
169
  // eslint-disable-next-line react-hooks/exhaustive-deps
165
170
  [], // just once, Formik does not reinitialize
166
171
  );
@@ -31,6 +31,7 @@ export const getNetworkInitialValues = (
31
31
  | 'serviceNetworksIpv4'
32
32
  | 'serviceNetworksDualstack'
33
33
  >,
34
+ isClusterManagedNetworkingUnsupported: boolean,
34
35
  ): NetworkConfigurationValues => {
35
36
  const isSNOCluster = isSNO(cluster);
36
37
  const isDualStackType = isDualStack(cluster);
@@ -40,7 +41,11 @@ export const getNetworkInitialValues = (
40
41
  ingressVips: cluster.ingressVips,
41
42
  sshPublicKey: cluster.sshPublicKey || '',
42
43
  vipDhcpAllocation: cluster.vipDhcpAllocation,
43
- managedNetworkingType: cluster.userManagedNetworking ? 'userManaged' : 'clusterManaged',
44
+ managedNetworkingType:
45
+ (cluster.apiVips && cluster.apiVips.length === 0 && isClusterManagedNetworkingUnsupported) ||
46
+ isSNOCluster
47
+ ? 'userManaged'
48
+ : 'clusterManaged',
44
49
  networkType: cluster.networkType || getDefaultNetworkType(isSNOCluster, isDualStackType),
45
50
  machineNetworks: cluster.machineNetworks || [],
46
51
  stackType: isDualStackType ? DUAL_STACK : IPV4_STACK,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Modal, ModalVariant, Button, ButtonVariant } from '@patternfly/react-core';
3
+ import { useTranslation } from '../../../common/hooks/use-translation-wrapper';
3
4
 
4
5
  type DeleteHostModalProps = {
5
6
  hostname?: string;
@@ -8,28 +9,32 @@ type DeleteHostModalProps = {
8
9
  onDelete: () => void;
9
10
  };
10
11
 
11
- const DeleteHostModal = ({ isOpen, hostname, onClose, onDelete }: DeleteHostModalProps) => (
12
- <Modal
13
- title="Remove host?"
14
- isOpen={isOpen}
15
- onClose={onClose}
16
- variant={ModalVariant.small}
17
- actions={[
18
- <Button
19
- data-testid="delete-host-submit"
20
- key="confirm"
21
- variant={ButtonVariant.danger}
22
- onClick={onDelete}
23
- >
24
- Remove host
25
- </Button>,
26
- <Button key="cancel" variant={ButtonVariant.link} onClick={onClose}>
27
- Cancel
28
- </Button>,
29
- ]}
30
- >
31
- Host {hostname || ''} will be removed.
32
- </Modal>
33
- );
12
+ const DeleteHostModal = ({ isOpen, hostname, onClose, onDelete }: DeleteHostModalProps) => {
13
+ const { t } = useTranslation();
14
+ return (
15
+ <Modal
16
+ title={t('ai:Remove host?')}
17
+ isOpen={isOpen}
18
+ onClose={onClose}
19
+ variant={ModalVariant.small}
20
+ titleIconVariant="warning"
21
+ actions={[
22
+ <Button
23
+ data-testid="delete-host-submit"
24
+ key="confirm"
25
+ variant={ButtonVariant.danger}
26
+ onClick={onDelete}
27
+ >
28
+ {t('ai:Remove host')}
29
+ </Button>,
30
+ <Button key="cancel" variant={ButtonVariant.link} onClick={onClose}>
31
+ {t('ai:Cancel')}
32
+ </Button>,
33
+ ]}
34
+ >
35
+ {t('ai:Host {{hostname}} will be removed', { hostname: hostname || '' })}
36
+ </Modal>
37
+ );
38
+ };
34
39
 
35
40
  export default DeleteHostModal;
@@ -0,0 +1,12 @@
1
+ import type { FeatureListType } from '../../common/features/featureGate';
2
+
3
+ type FeatureMapping = {
4
+ featureId: keyof FeatureListType;
5
+ capabilityId: string;
6
+ };
7
+ export const externalFeaturesMappings: Array<FeatureMapping> = [
8
+ {
9
+ featureId: 'ASSISTED_INSTALLER_PLATFORM_OCI',
10
+ capabilityId: 'capability.organization.bare_metal_installer_platform_oci',
11
+ },
12
+ ];
@@ -1,2 +1,2 @@
1
- export * from './routeBaseBath';
1
+ export * from './routeBasePath';
2
2
  export * from './constants';
@@ -0,0 +1,125 @@
1
+ import type { Account, Organization } from '@openshift-assisted/types/accounts-management-service';
2
+ import { describe, it, vi, expect } from 'vitest';
3
+ import * as React from 'react';
4
+ import { Provider } from 'react-redux';
5
+ import { render } from 'react-dom';
6
+ import { act } from 'react-dom/test-utils';
7
+ import { featureFlagsActions, FeatureFlagsState } from '../store/slices/feature-flags/slice';
8
+ import { isFeatureEnabled } from '../store/slices/feature-flags/selectors';
9
+ import { RootStateDay1, storeDay1 } from '../store/store-day1';
10
+ import { useFeatureDetection } from './use-feature-detection';
11
+ import { CurrentAccountApi } from '../../common/api/accounts-management-service/current-account-api';
12
+ import { OrganizationsApi } from '../../common/api/accounts-management-service/organizations-api';
13
+ import { getMockContainer } from '../../_test-helpers/mock-container';
14
+
15
+ vi.spyOn(featureFlagsActions, 'setFeatureFlag');
16
+ vi.spyOn(CurrentAccountApi, 'getCurrentAccount').mockImplementation(() => {
17
+ return Promise.resolve({
18
+ username: 'jdoe',
19
+ } as Account);
20
+ });
21
+
22
+ const makeSpyOn$OrganizationsApi$getOrganization = (mockResponse: Organization) =>
23
+ vi.spyOn(OrganizationsApi, 'getOrganization').mockImplementation(() => {
24
+ return Promise.resolve(mockResponse);
25
+ });
26
+
27
+ describe('use-feature-detection.ts', () => {
28
+ it('Sets only external features when no overrides are provided', async () => {
29
+ const DummyComponent: React.FC = () => {
30
+ useFeatureDetection();
31
+ return null;
32
+ };
33
+ makeSpyOn$OrganizationsApi$getOrganization({
34
+ capabilities: [
35
+ {
36
+ name: 'capability.organization.bare_metal_installer_platform_oci',
37
+ value: 'true',
38
+ inherited: true,
39
+ },
40
+ ],
41
+ });
42
+
43
+ await act(() =>
44
+ Promise.resolve(
45
+ render(
46
+ <Provider store={storeDay1}>
47
+ <DummyComponent />
48
+ </Provider>,
49
+ getMockContainer(),
50
+ ),
51
+ ),
52
+ );
53
+
54
+ expect(
55
+ isFeatureEnabled(
56
+ storeDay1.getState() as RootStateDay1 & FeatureFlagsState,
57
+ 'ASSISTED_INSTALLER_PLATFORM_OCI',
58
+ ),
59
+ ).toBe(true);
60
+ });
61
+
62
+ it('Internal features override external features', async () => {
63
+ const featuresOverride = { ASSISTED_INSTALLER_PLATFORM_OCI: true };
64
+ const DummyComponent: React.FC = () => {
65
+ useFeatureDetection(featuresOverride);
66
+ return null;
67
+ };
68
+ makeSpyOn$OrganizationsApi$getOrganization({
69
+ capabilities: [
70
+ {
71
+ name: 'capability.organization.bare_metal_installer_platform_oci',
72
+ value: 'false',
73
+ inherited: true,
74
+ },
75
+ ],
76
+ });
77
+
78
+ await act(() =>
79
+ Promise.resolve(
80
+ render(
81
+ <Provider store={storeDay1}>
82
+ <DummyComponent />
83
+ </Provider>,
84
+ getMockContainer(),
85
+ ),
86
+ ),
87
+ );
88
+
89
+ expect(
90
+ isFeatureEnabled(
91
+ storeDay1.getState() as RootStateDay1 & FeatureFlagsState,
92
+ 'ASSISTED_INSTALLER_PLATFORM_OCI',
93
+ ),
94
+ ).toBe(featuresOverride.ASSISTED_INSTALLER_PLATFORM_OCI);
95
+ });
96
+
97
+ it('Processes only features prefixed with ASSISTED_INSTALLER', async () => {
98
+ const featuresOverride = { NON_ASSISTED_INSTALLER_FEATURE: true };
99
+ const DummyComponent: React.FC = () => {
100
+ useFeatureDetection(featuresOverride);
101
+ return null;
102
+ };
103
+
104
+ await act(() =>
105
+ Promise.resolve(
106
+ render(
107
+ <Provider store={storeDay1}>
108
+ <DummyComponent />
109
+ </Provider>,
110
+ getMockContainer(),
111
+ ),
112
+ ),
113
+ );
114
+
115
+ /* Here we don't mock the call to the user organization API, therefore the
116
+ * capabilities in the currentUser slice should remain undefined, since the list
117
+ * of featuresOverride should get filtered out of features not prefixed with
118
+ * "ASSISTED_INSTALLER" there should be no call to setFeatureFlag.
119
+ */
120
+ expect(featureFlagsActions.setFeatureFlag).not.toHaveBeenCalled();
121
+ expect(
122
+ storeDay1.getState().featureFlags.data['NON_ASSISTED_INSTALLER_FEATURE'],
123
+ ).not.toBeDefined();
124
+ });
125
+ });
@@ -0,0 +1,17 @@
1
+ import type { FeatureListType } from '../../common/features/featureGate';
2
+ import { featureFlagsAsyncActions } from '../store/slices/feature-flags/slice';
3
+ import { storeDay1 } from '../store/store-day1';
4
+ import { useEffect } from 'react';
5
+
6
+ export function useFeatureDetection<T extends Partial<Record<string, boolean> & FeatureListType>>(
7
+ overrides: T | null = null,
8
+ ) {
9
+ useEffect(() => {
10
+ const onlyAssistedInstallerFeatures = Object.fromEntries(
11
+ Object.entries(overrides ?? {}).filter(([k, _v]) => k.startsWith('ASSISTED_INSTALLER')),
12
+ );
13
+ void storeDay1.dispatch(
14
+ featureFlagsAsyncActions.detectFeaturesAsync(onlyAssistedInstallerFeatures),
15
+ );
16
+ }, [overrides]);
17
+ }
@@ -47,10 +47,6 @@ const ClusterDetailsService = {
47
47
  },
48
48
  };
49
49
 
50
- if (!values.isCMNSupported) {
51
- params.userManagedNetworking = true;
52
- }
53
-
54
50
  if (values.hostsNetworkConfigurationType === HostsNetworkConfigurationType.STATIC) {
55
51
  params.staticNetworkConfig = getDummyInfraEnvField();
56
52
  }
@@ -1,21 +1,21 @@
1
- import { ClustersAPI } from '../services/apis';
2
- import HostsService from './HostsService';
3
- import InfraEnvsService from './InfraEnvsService';
4
- import { AI_UI_TAG } from '../../common';
5
- import { isInOcm } from '../api';
6
- import { ClusterCreateParamsWithStaticNetworking } from './types';
7
- import omit from 'lodash-es/omit.js';
8
- import {
1
+ import type { ClusterCreateParamsWithStaticNetworking } from './types';
2
+ import type {
9
3
  CustomManifestValues,
10
4
  ListManifestsExtended,
11
5
  } from '../components/clusterConfiguration/manifestsConfiguration/data/dataTypes';
12
- import {
6
+ import type {
13
7
  Cluster,
14
8
  Host,
15
9
  InfraEnvCreateParams,
16
10
  UpdateManifestParams,
17
11
  V2ClusterUpdateParams,
18
12
  } from '@openshift-assisted/types/assisted-installer-service';
13
+ import omit from 'lodash-es/omit.js';
14
+ import ClustersAPI from '../../common/api/assisted-service/ClustersAPI';
15
+ import HostsService from './HostsService';
16
+ import InfraEnvsService from './InfraEnvsService';
17
+ import { AI_UI_TAG } from '../../common/config/constants';
18
+ import { isInOcm } from '../../common/api/axiosClient';
19
19
 
20
20
  const ClustersService = {
21
21
  findHost(hosts: Cluster['hosts'] = [], hostId: Host['id']) {
@@ -1,5 +1,5 @@
1
- import { CpuArchitecture, getAllCpuArchitectures } from '../../common';
2
- import { Cluster, InfraEnv } from '@openshift-assisted/types/assisted-installer-service';
1
+ import type { Cluster, InfraEnv } from '@openshift-assisted/types/assisted-installer-service';
2
+ import { CpuArchitecture, getAllCpuArchitectures } from '../../common//types/cpuArchitecture';
3
3
 
4
4
  const CACHE_KEY = 'infra-env-ids-cache-v2';
5
5
 
@@ -1,9 +1,6 @@
1
1
  import { useDispatch, useSelector } from 'react-redux';
2
2
  import type { TypedUseSelectorHook } from 'react-redux';
3
3
  import type { DispatchDay1, RootStateDay1 } from './store-day1';
4
- import type { DispatchDay2, RootStateDay2 } from './store-day2';
5
4
 
6
- export const useDispatchDay1: () => DispatchDay1 = useDispatch;
5
+ export const useDispatchDay1 = useDispatch<DispatchDay1>;
7
6
  export const useSelectorDay1: TypedUseSelectorHook<RootStateDay1> = useSelector;
8
- export const useDispatchDay2: () => DispatchDay2 = useDispatch;
9
- export const useSelectorDay2: TypedUseSelectorHook<RootStateDay2> = useSelector;
@@ -1,5 +1,3 @@
1
1
  export { storeDay1 } from './store-day1';
2
- export { storeDay2 } from './store-day2';
3
2
  export type { RootStateDay1, DispatchDay1 } from './store-day1';
4
- export type { RootStateDay2, DispatchDay2 } from './store-day2';
5
- export { useSelectorDay1, useSelectorDay2, useDispatchDay1, useDispatchDay2 } from './hooks';
3
+ export { useSelectorDay1, useDispatchDay1 } from './hooks';
@@ -6,10 +6,11 @@ import {
6
6
  AnyAction,
7
7
  Dispatch,
8
8
  } from '@reduxjs/toolkit';
9
- import { ResourceUIState } from '../../../../common';
10
- import { ClustersAPI } from '../../../services/apis';
11
- import { handleApiError, isInOcm } from '../../../api';
12
- import { Cluster } from '@openshift-assisted/types/assisted-installer-service';
9
+ import { ResourceUIState } from '../../../../common/types/resource-ui-state';
10
+ import ClustersAPI from '../../../../common/api/assisted-service/ClustersAPI';
11
+ import { isInOcm } from '../../../../common/api/axiosClient';
12
+ import type { Cluster } from '@openshift-assisted/types/assisted-installer-service';
13
+ import { handleApiError } from '../../../../common/api/utils';
13
14
 
14
15
  export const fetchClustersAsync = createAsyncThunk<Cluster[] | void>(
15
16
  'clusters/fetchClustersAsync',
@@ -1,23 +1,17 @@
1
1
  import findIndex from 'lodash-es/findIndex.js';
2
2
  import set from 'lodash-es/set.js';
3
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
4
  import { AxiosError } from 'axios';
5
+ import type { AnyAction, Dispatch, PayloadAction, ThunkDispatch } from '@reduxjs/toolkit';
6
+ import type { Cluster, Host } from '@openshift-assisted/types/assisted-installer-service';
7
+ import type { AssistedInstallerPermissionTypesListType } from '../../../../common/features/featureGate';
4
8
  import {
5
- AnyAction,
6
- createAsyncThunk,
7
- createSlice,
8
- Dispatch,
9
- PayloadAction,
10
- ThunkDispatch,
11
- } from '@reduxjs/toolkit';
12
- import { Cluster, Host } from '@openshift-assisted/types/assisted-installer-service';
13
- import {
14
- AssistedInstallerPermissionTypesListType,
15
- FETCH_ABORTED_ERROR_CODE,
16
- getApiErrorCode,
17
- getApiErrorMessage,
18
9
  handleApiError,
19
- ResourceUIState,
20
- } from '../../../../common';
10
+ getApiErrorMessage,
11
+ getApiErrorCode,
12
+ FETCH_ABORTED_ERROR_CODE,
13
+ } from '../../../../common/api/utils';
14
+ import { ResourceUIState } from '../../../../common/types/resource-ui-state';
21
15
  import ClustersService from '../../../services/ClustersService';
22
16
 
23
17
  export type FetchErrorType = {