Skip to content

Commit 8af3665

Browse files
authored
Connect List,Add Tenants (#148)
1 parent 0fa1d4b commit 8af3665

File tree

15 files changed

+305
-185
lines changed

15 files changed

+305
-185
lines changed

pkg/acl/endpoints.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ var (
3535
buckets = "/buckets"
3636
bucketsDetail = "/buckets/:bucketName"
3737
serviceAccounts = "/service-accounts"
38-
clusters = "/clusters"
39-
clustersDetail = "/clusters/:clusterName"
38+
tenants = "/tenants"
39+
tenantsDetail = "/tenants/:tenantName"
4040
heal = "/heal"
4141
)
4242

@@ -192,8 +192,8 @@ var serviceAccountsActionSet = ConfigurationActionSet{
192192
actions: iampolicy.NewActionSet(),
193193
}
194194

195-
// clustersActionSet temporally no actions needed for clusters sections to work
196-
var clustersActionSet = ConfigurationActionSet{
195+
// tenantsActionSet temporally no actions needed for tenants sections to work
196+
var tenantsActionSet = ConfigurationActionSet{
197197
actionTypes: iampolicy.NewActionSet(),
198198
actions: iampolicy.NewActionSet(),
199199
}
@@ -228,8 +228,8 @@ var endpointRules = map[string]ConfigurationActionSet{
228228

229229
// operatorRules contains the mapping between endpoints and ActionSets for operator only mode
230230
var operatorRules = map[string]ConfigurationActionSet{
231-
clusters: clustersActionSet,
232-
clustersDetail: clustersActionSet,
231+
tenants: tenantsActionSet,
232+
tenantsDetail: tenantsActionSet,
233233
}
234234

235235
// operatorOnly ENV variable

portal-ui/bindata_assetfs.go

Lines changed: 121 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

portal-ui/src/common/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const units = [
2525
"ZiB",
2626
"YiB",
2727
];
28+
export const k8sUnits = ["Ki", "Mi", "Gi", "Ti", "Pi", "Ei"];
2829
export const niceBytes = (x: string) => {
2930
let l = 0,
3031
n = parseInt(x, 10) || 0;
@@ -65,6 +66,13 @@ export const factorForDropdown = () => {
6566
});
6667
};
6768

69+
// units to be used in a dropdown
70+
export const k8sfactorForDropdown = () => {
71+
return k8sUnits.map((unit) => {
72+
return { label: unit, value: unit };
73+
});
74+
};
75+
6876
//getBytes, converts from a value and a unit from units array to bytes
6977
export const getBytes = (value: string, unit: string) => {
7078
const vl: number = parseFloat(value);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ import Trace from "./Trace/Trace";
6464
import Logs from "./Logs/Logs";
6565
import Heal from "./Heal/Heal";
6666
import Watch from "./Watch/Watch";
67-
import ListClusters from "./Clusters/ListClusters/ListClusters";
67+
import ListTenants from "./Tenants/ListTenants/ListTenants";
6868
import { ISessionResponse } from "./types";
6969
import { saveSessionResponse } from "./actions";
70-
import ClusterDetails from "./Clusters/ClusterDetails/ClusterDetails";
70+
import TenantDetails from "./Tenants/TenantDetails/TenantDetails";
7171

7272
function Copyright() {
7373
return (
@@ -301,11 +301,11 @@ const Console = ({
301301
path: "/webhook/audit",
302302
},
303303
{
304-
component: ListClusters,
305-
path: "/clusters",
304+
component: ListTenants,
305+
path: "/tenants",
306306
},
307307
{
308-
component: ClusterDetails,
308+
component: TenantDetails,
309309
path: "/clusters/:clusterName",
310310
},
311311
];

portal-ui/src/screens/Console/Menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ class Menu extends React.Component<MenuProps> {
246246
group: "Operator",
247247
type: "item",
248248
component: NavLink,
249-
to: "/clusters",
250-
name: "Clusters",
249+
to: "/tenants",
250+
name: "Tenants",
251251
icon: <StorageIcon />,
252252
},
253253
{

portal-ui/src/screens/Console/Clusters/ListClusters/AddCluster.tsx renamed to portal-ui/src/screens/Console/Tenants/ListTenants/AddTenant.tsx

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
import React, { useState, useEffect } from "react";
17+
import React, { useEffect, useState } from "react";
1818
import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
1919
import Grid from "@material-ui/core/Grid";
2020
import Typography from "@material-ui/core/Typography";
@@ -26,11 +26,11 @@ import { modalBasic } from "../../Common/FormComponents/common/styleLibrary";
2626
import { IVolumeConfiguration, IZone } from "./types";
2727
import CheckboxWrapper from "../../Common/FormComponents/CheckboxWrapper/CheckboxWrapper";
2828
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
29-
import { factorForDropdown, units } from "../../../../common/utils";
29+
import { k8sfactorForDropdown } from "../../../../common/utils";
3030
import ZonesMultiSelector from "./ZonesMultiSelector";
3131
import { storageClasses } from "../utils";
3232

33-
interface IAddClusterProps {
33+
interface IAddTenantProps {
3434
open: boolean;
3535
closeModalAndRefresh: (reloadData: boolean) => any;
3636
classes: any;
@@ -55,14 +55,14 @@ const styles = (theme: Theme) =>
5555
...modalBasic,
5656
});
5757

58-
const AddCluster = ({
58+
const AddTenant = ({
5959
open,
6060
closeModalAndRefresh,
6161
classes,
62-
}: IAddClusterProps) => {
62+
}: IAddTenantProps) => {
6363
const [addSending, setAddSending] = useState<boolean>(false);
6464
const [addError, setAddError] = useState<string>("");
65-
const [clusterName, setClusterName] = useState<string>("");
65+
const [tenantName, setTenantName] = useState<string>("");
6666
const [imageName, setImageName] = useState<string>("");
6767
const [serviceName, setServiceName] = useState<string>("");
6868
const [zones, setZones] = useState<IZone[]>([]);
@@ -75,13 +75,30 @@ const AddCluster = ({
7575
const [secretKey, setSecretKey] = useState<string>("");
7676
const [enableMCS, setEnableMCS] = useState<boolean>(false);
7777
const [enableSSL, setEnableSSL] = useState<boolean>(false);
78-
const [sizeFactor, setSizeFactor] = useState<string>("GiB");
78+
const [sizeFactor, setSizeFactor] = useState<string>("Gi");
7979

8080
useEffect(() => {
8181
if (addSending) {
82+
let cleanZones: IZone[] = [];
83+
for (let zone of zones) {
84+
if (zone.name !== "") {
85+
cleanZones.push(zone);
86+
}
87+
}
88+
8289
api
83-
.invoke("POST", `/api/v1/clusters`, {
84-
name: clusterName,
90+
.invoke("POST", `/api/v1/tenants`, {
91+
name: tenantName,
92+
service_name: tenantName,
93+
enable_ssl: enableSSL,
94+
enable_mcs: enableMCS,
95+
access_key: accessKey,
96+
secret_key: secretKey,
97+
volumes_per_server: volumesPerServer,
98+
volume_configuration: {
99+
size: `${volumeConfiguration.size}${sizeFactor}`,
100+
},
101+
zones: cleanZones,
85102
})
86103
.then(() => {
87104
setAddSending(false);
@@ -107,7 +124,7 @@ const AddCluster = ({
107124

108125
return (
109126
<ModalWrapper
110-
title="Create Cluster"
127+
title="Create Tenant"
111128
modalOpen={open}
112129
onClose={() => {
113130
setAddError("");
@@ -139,13 +156,13 @@ const AddCluster = ({
139156
)}
140157
<Grid item xs={12}>
141158
<InputBoxWrapper
142-
id="cluster-name"
143-
name="cluster-name"
159+
id="tenant-name"
160+
name="tenant-name"
144161
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
145-
setClusterName(e.target.value);
162+
setTenantName(e.target.value);
146163
}}
147-
label="Cluster Name"
148-
value={clusterName}
164+
label="Tenant Name"
165+
value={tenantName}
149166
/>
150167
</Grid>
151168
<Grid item xs={12}>
@@ -155,7 +172,7 @@ const AddCluster = ({
155172
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
156173
setImageName(e.target.value);
157174
}}
158-
label="Image"
175+
label="MinIO Image"
159176
value={imageName}
160177
/>
161178
</Grid>
@@ -175,7 +192,9 @@ const AddCluster = ({
175192
<ZonesMultiSelector
176193
label="Zones"
177194
name="zones_selector"
178-
onChange={() => {}}
195+
onChange={(elements: IZone[]) => {
196+
setZones(elements);
197+
}}
179198
elements={zones}
180199
/>
181200
</div>
@@ -220,7 +239,7 @@ const AddCluster = ({
220239
onChange={(e: React.ChangeEvent<{ value: unknown }>) => {
221240
setSizeFactor(e.target.value as string);
222241
}}
223-
options={factorForDropdown()}
242+
options={k8sfactorForDropdown()}
224243
/>
225244
</div>
226245
</div>
@@ -322,4 +341,4 @@ const AddCluster = ({
322341
);
323342
};
324343

325-
export default withStyles(styles)(AddCluster);
344+
export default withStyles(styles)(AddTenant);

portal-ui/src/screens/Console/Clusters/ListClusters/DeleteCluster.tsx renamed to portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ import Typography from "@material-ui/core/Typography";
2828
import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
2929
import api from "../../../../common/api";
3030

31-
interface IDeleteCluster {
31+
interface IDeleteTenant {
3232
classes: any;
3333
deleteOpen: boolean;
34-
selectedCluster: string;
34+
selectedTenant: string;
3535
closeDeleteModalAndRefresh: (refreshList: boolean) => any;
3636
}
3737

@@ -42,27 +42,29 @@ const styles = (theme: Theme) =>
4242
},
4343
});
4444

45-
const DeleteCluster = ({
45+
const DeleteTenant = ({
4646
classes,
4747
deleteOpen,
48-
selectedCluster,
48+
selectedTenant,
4949
closeDeleteModalAndRefresh,
50-
}: IDeleteCluster) => {
50+
}: IDeleteTenant) => {
5151
const [deleteLoading, setDeleteLoading] = useState(false);
5252
const [deleteError, setDeleteError] = useState("");
5353

5454
useEffect(() => {
55-
api
56-
.invoke("DELETE", `/api/v1/clusters/${selectedCluster}`)
57-
.then(() => {
58-
setDeleteLoading(false);
59-
setDeleteError("");
60-
closeDeleteModalAndRefresh(true);
61-
})
62-
.catch((err) => {
63-
setDeleteLoading(false);
64-
setDeleteError(err);
65-
});
55+
if (deleteLoading) {
56+
api
57+
.invoke("DELETE", `/api/v1/clusters/${selectedTenant}`)
58+
.then(() => {
59+
setDeleteLoading(false);
60+
setDeleteError("");
61+
closeDeleteModalAndRefresh(true);
62+
})
63+
.catch((err) => {
64+
setDeleteLoading(false);
65+
setDeleteError(err);
66+
});
67+
}
6668
}, [deleteLoading]);
6769

6870
const removeRecord = () => {
@@ -79,11 +81,11 @@ const DeleteCluster = ({
7981
aria-labelledby="alert-dialog-title"
8082
aria-describedby="alert-dialog-description"
8183
>
82-
<DialogTitle id="alert-dialog-title">Delete Cluster</DialogTitle>
84+
<DialogTitle id="alert-dialog-title">Delete Tenant</DialogTitle>
8385
<DialogContent>
8486
{deleteLoading && <LinearProgress />}
8587
<DialogContentText id="alert-dialog-description">
86-
Are you sure you want to delete cluster <b>{selectedCluster}</b>?
88+
Are you sure you want to delete tenant <b>{selectedTenant}</b>?
8789
{deleteError !== "" && (
8890
<React.Fragment>
8991
<br />
@@ -117,4 +119,4 @@ const DeleteCluster = ({
117119
);
118120
};
119121

120-
export default withStyles(styles)(DeleteCluster);
122+
export default withStyles(styles)(DeleteTenant);

0 commit comments

Comments
 (0)