Skip to content

Commit 40896c0

Browse files
committed
Integrate mkube storageclass api with UI
1 parent 4edfeb2 commit 40896c0

File tree

7 files changed

+129
-124
lines changed

7 files changed

+129
-124
lines changed

portal-ui/bindata_assetfs.go

Lines changed: 98 additions & 98 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
enable_ssl: enableSSL,
@@ -123,6 +127,26 @@ const AddTenant = ({
123127
setVolumeConfiguration(volumeCopy);
124128
};
125129

130+
const fetchStorageClassList = () => {
131+
api
132+
.invoke("GET", `/api/v1/mkube/storage-classes`)
133+
.then((res: string[]) => {
134+
let classes: string[] = [];
135+
if (res !== null) {
136+
classes = res;
137+
}
138+
setStorageClassesList(classes);
139+
})
140+
.catch((err: any) => {
141+
console.log(err);
142+
});
143+
};
144+
145+
const storageClassesList = storageClasses.map((s: string) => ({
146+
label: s,
147+
value: s,
148+
}));
149+
126150
return (
127151
<ModalWrapper
128152
title="Create Tenant"
@@ -254,7 +278,7 @@ const AddTenant = ({
254278
}}
255279
label="Storage Class"
256280
value={volumeConfiguration.storage_class}
257-
options={storageClasses}
281+
options={storageClassesList}
258282
/>
259283
</Grid>
260284
<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/clusters/${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)