Skip to content

Commit ce4d931

Browse files
authored
AWS Marketplace Integration Updates (#1740)
Makes the create tenant for MK AWS updated with new recommendations Fixes Back Link icon alignment and color Adds a helpbox for MK AWS Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent 58c53cb commit ce4d931

File tree

10 files changed

+356
-62
lines changed

10 files changed

+356
-62
lines changed

portal-ui/src/common/BackLink.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,43 +19,47 @@ import { Link } from "react-router-dom";
1919
import { Theme } from "@mui/material/styles";
2020
import createStyles from "@mui/styles/createStyles";
2121
import withStyles from "@mui/styles/withStyles";
22-
import { BackIcon } from "../icons";
22+
import { BackSettingsIcon } from "../icons";
2323
import { Box } from "@mui/material";
2424

2525
const styles = (theme: Theme) =>
2626
createStyles({
2727
link: {
28-
display: "inline-block",
29-
alignItems: "center",
30-
justifyContent: "center",
28+
display: "block",
3129
textDecoration: "none",
32-
maxWidth: "40px",
3330
"&:active": {
3431
color: theme.palette.primary.light,
3532
},
3633
},
37-
icon: {
38-
marginRight: "11px",
34+
iconBox: {
3935
display: "flex",
40-
alignItems: "center",
41-
justifyContent: "center",
42-
height: "35px",
43-
width: "35px",
44-
borderRadius: "2px",
36+
flexDirection: "row",
4537
"&:hover": {
4638
background: "rgba(234,237,238)",
4739
},
48-
"& svg.min-icon": {
49-
width: "18px",
50-
height: "12px",
40+
height: "30px",
41+
paddingBottom: 4,
42+
paddingTop: 8,
43+
paddingRight: 16,
44+
paddingLeft: 0,
45+
borderRadius: 4,
46+
},
47+
icon: {
48+
lineHeight: 1,
49+
marginRight: "14px",
50+
alignItems: "center",
51+
width: "22px",
52+
"& .min-icon": {
53+
color: theme.palette.primary.light,
54+
width: "16px",
55+
height: "16px",
5156
},
5257
},
5358
label: {
54-
display: "flex",
59+
lineHeight: 1,
5560
alignItems: "center",
56-
height: "35px",
57-
padding: "0 0px 0 5px",
58-
fontSize: "18px",
61+
paddingTop: 1,
62+
fontSize: "14px",
5963
fontWeight: 600,
6064
color: theme.palette.primary.light,
6165
},
@@ -92,11 +96,13 @@ const BackLink = ({
9296
}
9397
}}
9498
>
95-
<div className={classes.icon}>
96-
<BackIcon />
99+
<div className={classes.iconBox}>
100+
<div className={classes.icon}>
101+
<BackSettingsIcon />
102+
</div>
103+
<div className={classes.label}>{label}</div>
97104
</div>
98105
</Link>
99-
<div className={classes.label}>{label}</div>
100106
</Box>
101107
);
102108
};

portal-ui/src/common/utils.ts

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ import {
2222
IStorageFactors,
2323
} from "./types";
2424
import { IPool } from "../screens/Console/Tenants/ListTenants/types";
25+
import {
26+
IMkEnvs,
27+
IntegrationConfiguration,
28+
mkPanelConfigurations,
29+
} from "../screens/Console/Tenants/AddTenant/Steps/TenantResources/utils";
30+
import get from "lodash/get";
2531

2632
const minStReq = 1073741824; // Minimal Space required for MinIO
2733
const minMemReq = 2147483648; // Minimal Memory required for MinIO in bytes
@@ -114,25 +120,34 @@ export const k8sScalarUnitsExcluding = (exclude?: string[]) => {
114120
});
115121
};
116122

117-
//getBytes, converts from a value and a unit from units array to bytes
123+
//getBytes, converts from a value and a unit from units array to bytes as a string
118124
export const getBytes = (
119125
value: string,
120126
unit: string,
121127
fromk8s: boolean = false
122-
) => {
128+
): string => {
129+
return getBytesNumber(value, unit, fromk8s).toString(10);
130+
};
131+
132+
//getBytesNumber, converts from a value and a unit from units array to bytes
133+
export const getBytesNumber = (
134+
value: string,
135+
unit: string,
136+
fromk8s: boolean = false
137+
): number => {
123138
const vl: number = parseFloat(value);
124139

125140
const unitsTake = fromk8s ? k8sCalcUnits : units;
126141

127142
const powFactor = unitsTake.findIndex((element) => element === unit);
128143

129144
if (powFactor === -1) {
130-
return "0";
145+
return 0;
131146
}
132147
const factor = Math.pow(1024, powFactor);
133148
const total = vl * factor;
134149

135-
return total.toString(10);
150+
return total;
136151
};
137152

138153
//getTotalSize gets the total size of a value & unit
@@ -218,7 +233,9 @@ export const calculateDistribution = (
218233
capacityToUse: ICapacity,
219234
forcedNodes: number = 0,
220235
limitSize: number = 0,
221-
drivesPerServer: number = 0
236+
drivesPerServer: number = 0,
237+
marketplaceIntegration?: IMkEnvs,
238+
selectedStorageType?: string
222239
): IStorageDistribution => {
223240
const requestedSizeBytes = getBytes(
224241
capacityToUse.value,
@@ -250,7 +267,9 @@ export const calculateDistribution = (
250267
requestedSizeBytes,
251268
forcedNodes,
252269
limitSize,
253-
drivesPerServer
270+
drivesPerServer,
271+
marketplaceIntegration,
272+
selectedStorageType
254273
);
255274

256275
return numberOfNodes;
@@ -260,7 +279,9 @@ const calculateStorage = (
260279
requestedBytes: string,
261280
forcedNodes: number,
262281
limitSize: number,
263-
drivesPerServer: number
282+
drivesPerServer: number,
283+
marketplaceIntegration?: IMkEnvs,
284+
selectedStorageType?: string
264285
): IStorageDistribution => {
265286
// Size validation
266287
const intReqBytes = parseInt(requestedBytes, 10);
@@ -272,7 +293,9 @@ const calculateStorage = (
272293
intReqBytes,
273294
maxDiskSize,
274295
limitSize,
275-
drivesPerServer
296+
drivesPerServer,
297+
marketplaceIntegration,
298+
selectedStorageType
276299
);
277300
};
278301

@@ -281,7 +304,9 @@ const structureCalc = (
281304
desiredCapacity: number,
282305
maxDiskSize: number,
283306
maxClusterSize: number,
284-
disksPerNode: number = 0
307+
disksPerNode: number = 0,
308+
marketplaceIntegration?: IMkEnvs,
309+
selectedStorageType?: string
285310
): IStorageDistribution => {
286311
if (
287312
isNaN(nodes) ||
@@ -350,6 +375,48 @@ const structureCalc = (
350375
pvSize: 0,
351376
}; // Cannot allocate this volume size
352377
}
378+
// validate for integrations
379+
if (marketplaceIntegration !== undefined) {
380+
const setConfigs = mkPanelConfigurations[marketplaceIntegration];
381+
const keyCount = Object.keys(setConfigs).length;
382+
383+
//Configuration is filled
384+
if (keyCount > 0) {
385+
const configs: IntegrationConfiguration[] = get(
386+
setConfigs,
387+
"configurations",
388+
[]
389+
);
390+
const mainSelection = configs.find(
391+
(item) => item.typeSelection === selectedStorageType
392+
);
393+
394+
if (mainSelection !== undefined && mainSelection.minimumVolumeSize) {
395+
const minimumPvSize = getBytesNumber(
396+
mainSelection.minimumVolumeSize?.driveSize,
397+
mainSelection.minimumVolumeSize?.sizeUnit,
398+
true
399+
);
400+
const storageTypeLabel = setConfigs.variantSelectorValues!.find(
401+
(item) => item.value === selectedStorageType
402+
);
403+
404+
if (persistentVolumeSize < minimumPvSize) {
405+
return {
406+
error: `For the ${
407+
storageTypeLabel!.label
408+
} storage type the mininum volume size is ${
409+
mainSelection.minimumVolumeSize.driveSize
410+
}${mainSelection.minimumVolumeSize.sizeUnit}`,
411+
nodes: 0,
412+
persistentVolumes: 0,
413+
disks: 0,
414+
pvSize: 0,
415+
};
416+
}
417+
}
418+
}
419+
}
353420

354421
return {
355422
error: "",

portal-ui/src/screens/Console/Tenants/AddTenant/AddTenant.tsx

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ import BackLink from "../../../../common/BackLink";
5555
import TenantResources from "./Steps/TenantResources/TenantResources";
5656
import ConfigLogSearch from "./Steps/ConfigLogSearch";
5757
import ConfigPrometheus from "./Steps/ConfigPrometheus";
58+
import {
59+
IMkEnvs,
60+
resourcesConfigurations,
61+
} from "./Steps/TenantResources/utils";
62+
import HelpBox from "../../../../common/HelpBox";
63+
import { StorageIcon } from "../../../../icons";
5864

5965
interface IAddTenantProps {
6066
setErrorSnackMessage: typeof setErrorSnackMessage;
@@ -66,6 +72,7 @@ interface IAddTenantProps {
6672
namespace: string;
6773
validPages: string[];
6874
classes: any;
75+
features?: string[];
6976
}
7077

7178
const styles = (theme: Theme) =>
@@ -87,6 +94,7 @@ const AddTenant = ({
8794
validPages,
8895
setErrorSnackMessage,
8996
resetAddTenantForm,
97+
features,
9098
}: IAddTenantProps) => {
9199
// Modals
92100
const [showNewCredentials, setShowNewCredentials] = useState<boolean>(false);
@@ -95,6 +103,27 @@ const AddTenant = ({
95103

96104
// Fields
97105
const [addSending, setAddSending] = useState<boolean>(false);
106+
const [formRender, setFormRender] = useState<IMkEnvs | null>(null);
107+
108+
useEffect(() => {
109+
let setConfiguration = IMkEnvs.default;
110+
111+
if (features && features.length !== 0) {
112+
const possibleVariables = Object.keys(resourcesConfigurations);
113+
114+
possibleVariables.forEach((element) => {
115+
if (features.includes(element)) {
116+
setConfiguration = get(
117+
resourcesConfigurations,
118+
element,
119+
IMkEnvs.default
120+
);
121+
}
122+
});
123+
}
124+
125+
setFormRender(setConfiguration);
126+
}, [features]);
98127

99128
/* Send Information to backend */
100129
useEffect(() => {
@@ -764,20 +793,47 @@ const AddTenant = ({
764793
/>
765794
)}
766795
<PageHeader label={"Create New Tenant"} />
767-
<BackLink
768-
to={"/tenants"}
769-
label={"Tenant List"}
770-
executeOnClick={resetAddTenantForm}
771-
/>
796+
772797
<PageLayout>
773798
{addSending && (
774799
<Grid item xs={12}>
775800
<LinearProgress />
776801
</Grid>
777802
)}
803+
804+
<Grid item xs={12}>
805+
<BackLink
806+
to={"/tenants"}
807+
label={"Tenant List"}
808+
executeOnClick={resetAddTenantForm}
809+
/>
810+
</Grid>
778811
<Grid item xs={12} className={classes.pageBox}>
779812
<GenericWizard wizardSteps={filteredWizardSteps} />
780813
</Grid>
814+
{formRender === IMkEnvs.aws && (
815+
<Grid item xs={12} style={{ marginTop: 16 }}>
816+
<HelpBox
817+
title={"EBS Volume Configuration."}
818+
iconComponent={<StorageIcon />}
819+
help={
820+
<Fragment>
821+
<b>Performance Optimized</b>: Uses the <i>gp3</i> EBS storage
822+
class class configured at 1,000Mi/s throughput and 16,000
823+
IOPS, however the minimum volume size for this type of EBS
824+
volume is <b>32Gi</b>.
825+
<br />
826+
<br />
827+
<b>Storage Optimized</b>: Uses the <i>sc1</i> EBS storage
828+
class, however the minimum volume size for this type of EBS
829+
volume is &nbsp;
830+
<b>16Ti</b> to unlock their maximum throughput speed of
831+
250Mi/s.
832+
</Fragment>
833+
}
834+
/>
835+
</Grid>
836+
)}
781837
</PageLayout>
782838
</Fragment>
783839
);
@@ -790,6 +846,7 @@ const mapState = (state: AppState) => ({
790846
certificates: state.tenants.createTenant.certificates,
791847
selectedStorageClass:
792848
state.tenants.createTenant.fields.nameTenant.selectedStorageClass,
849+
features: state.console.session.features,
793850
});
794851

795852
const connector = connect(mapState, {

0 commit comments

Comments
 (0)