Skip to content

Commit 8949fbe

Browse files
authored
Integrate mkube storageclass api with UI (#156)
1 parent d8e6bd7 commit 8949fbe

File tree

7 files changed

+129
-147
lines changed

7 files changed

+129
-147
lines changed

portal-ui/bindata_assetfs.go

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

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

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import CheckboxWrapper from "../../Common/FormComponents/CheckboxWrapper/Checkbo
2828
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
2929
import { k8sfactorForDropdown } from "../../../../common/utils";
3030
import ZonesMultiSelector from "./ZonesMultiSelector";
31-
import { storageClasses } from "../utils";
3231

3332
interface IAddTenantProps {
3433
open: boolean;
@@ -76,6 +75,11 @@ const AddTenant = ({
7675
const [enableMCS, setEnableMCS] = useState<boolean>(false);
7776
const [enableSSL, setEnableSSL] = useState<boolean>(false);
7877
const [sizeFactor, setSizeFactor] = useState<string>("Gi");
78+
const [storageClasses, setStorageClassesList] = useState<string[]>([]);
79+
80+
useEffect(() => {
81+
fetchStorageClassList();
82+
}, []);
7983

8084
useEffect(() => {
8185
if (addSending) {
@@ -87,7 +91,7 @@ const AddTenant = ({
8791
}
8892

8993
api
90-
.invoke("POST", `/api/v1/tenants`, {
94+
.invoke("POST", `/api/v1/mkube/tenants`, {
9195
name: tenantName,
9296
service_name: tenantName,
9397
image: imageName,
@@ -124,6 +128,26 @@ const AddTenant = ({
124128
setVolumeConfiguration(volumeCopy);
125129
};
126130

131+
const fetchStorageClassList = () => {
132+
api
133+
.invoke("GET", `/api/v1/mkube/storage-classes`)
134+
.then((res: string[]) => {
135+
let classes: string[] = [];
136+
if (res !== null) {
137+
classes = res;
138+
}
139+
setStorageClassesList(classes);
140+
})
141+
.catch((err: any) => {
142+
console.log(err);
143+
});
144+
};
145+
146+
const storageClassesList = storageClasses.map((s: string) => ({
147+
label: s,
148+
value: s,
149+
}));
150+
127151
return (
128152
<ModalWrapper
129153
title="Create Tenant"
@@ -255,7 +279,7 @@ const AddTenant = ({
255279
}}
256280
label="Storage Class"
257281
value={volumeConfiguration.storage_class}
258-
options={storageClasses}
282+
options={storageClassesList}
259283
/>
260284
</Grid>
261285
<Grid item xs={12}>

portal-ui/src/screens/Console/Tenants/ListTenants/DeleteTenant.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const DeleteTenant = ({
5454
useEffect(() => {
5555
if (deleteLoading) {
5656
api
57-
.invoke("DELETE", `/api/v1/tenants/${selectedTenant}`)
57+
.invoke("DELETE", `/api/v1/mkube/tenants/${selectedTenant}`)
5858
.then(() => {
5959
setDeleteLoading(false);
6060
setDeleteError("");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const ListTenants = ({ classes }: ITenantsList) => {
150150
api
151151
.invoke(
152152
"GET",
153-
`/api/v1/tenants?offset=${offset}&limit=${rowsPerPage}`
153+
`/api/v1/mkube/tenants?offset=${offset}&limit=${rowsPerPage}`
154154
)
155155
.then((res: ITenantsResponse) => {
156156
if (res === null) {

portal-ui/src/screens/Console/Tenants/utils.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

restapi/configure_mcs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func FileServerMiddleware(next http.Handler) http.Handler {
164164
switch {
165165
case strings.HasPrefix(r.URL.Path, "/ws"):
166166
serveWS(w, r)
167-
case strings.HasPrefix(r.URL.Path, "/api/v1/tenants"):
167+
case strings.HasPrefix(r.URL.Path, "/api/v1/mkube"):
168168
client := &http.Client{}
169169
serverMkube(client, w, r)
170170
case strings.HasPrefix(r.URL.Path, "/api"):

restapi/mkube.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
// serverMkube handles calls for mkube
3131
func serverMkube(client *http.Client, w http.ResponseWriter, req *http.Request) {
3232
// destination of the request, the mkube server
33+
req.URL.Path = strings.Replace(req.URL.Path, "/mkube", "", 1)
3334
targetURL := fmt.Sprintf("%s%s", getM3Host(), req.URL.String())
3435

3536
// set the HTTP method, url, and m3Req body

0 commit comments

Comments
 (0)