Skip to content

Commit 13ef83c

Browse files
authored
Added Clusters mockups (#133)
1 parent b89b2d0 commit 13ef83c

File tree

19 files changed

+1992
-128
lines changed

19 files changed

+1992
-128
lines changed

pkg/acl/endpoints.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ var (
3131
watch = "/watch"
3232
notifications = "/notification-endpoints"
3333
buckets = "/buckets"
34-
bucketDetails = "/buckets/:bucketName"
34+
bucketsDetail = "/buckets/:bucketName"
3535
serviceAccounts = "/service-accounts"
36+
clusters = "/clusters"
37+
clustersDetail = "/clusters/:clusterName"
3638
)
3739

3840
type ConfigurationActionSet struct {
@@ -181,12 +183,18 @@ var bucketsActionSet = ConfigurationActionSet{
181183
),
182184
}
183185

184-
// serviceAccountsActionSet contains the list of admin actions required for this endpoint to work
186+
// serviceAccountsActionSet no actions needed for this module to work
185187
var serviceAccountsActionSet = ConfigurationActionSet{
186188
actionTypes: iampolicy.NewActionSet(),
187189
actions: iampolicy.NewActionSet(),
188190
}
189191

192+
// clustersActionSet temporally no actions needed for clusters sections to work
193+
var clustersActionSet = ConfigurationActionSet{
194+
actionTypes: iampolicy.NewActionSet(),
195+
actions: iampolicy.NewActionSet(),
196+
}
197+
190198
// endpointRules contains the mapping between endpoints and ActionSets, additional rules can be added here
191199
var endpointRules = map[string]ConfigurationActionSet{
192200
configuration: configurationActionSet,
@@ -200,8 +208,10 @@ var endpointRules = map[string]ConfigurationActionSet{
200208
watch: watchActionSet,
201209
notifications: notificationsActionSet,
202210
buckets: bucketsActionSet,
203-
bucketDetails: bucketsActionSet,
211+
bucketsDetail: bucketsActionSet,
204212
serviceAccounts: serviceAccountsActionSet,
213+
clusters: clustersActionSet,
214+
clustersDetail: clustersActionSet,
205215
}
206216

207217
// GetActionsStringFromPolicy extract the admin/s3 actions from a given policy and return them in []string format

pkg/acl/endpoints_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
3737
args: args{
3838
[]string{"admin:ServerInfo"},
3939
},
40-
want: 2,
40+
want: 4,
4141
},
4242
{
4343
name: "policies endpoint",
@@ -50,7 +50,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
5050
"admin:ListUserPolicies",
5151
},
5252
},
53-
want: 2,
53+
want: 4,
5454
},
5555
{
5656
name: "all admin endpoints",
@@ -59,7 +59,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
5959
"admin:*",
6060
},
6161
},
62-
want: 10,
62+
want: 12,
6363
},
6464
{
6565
name: "all s3 endpoints",
@@ -68,7 +68,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
6868
"s3:*",
6969
},
7070
},
71-
want: 4,
71+
want: 6,
7272
},
7373
{
7474
name: "all admin and s3 endpoints",
@@ -78,7 +78,7 @@ func TestGetAuthorizedEndpoints(t *testing.T) {
7878
"s3:*",
7979
},
8080
},
81-
want: 13,
81+
want: 15,
8282
},
8383
{
8484
name: "no endpoints",

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/common/utils.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,11 @@ export const timeFromDate = (d: Date) => {
5757

5858
return `${h}:${m}:${s}:${d.getMilliseconds()}`;
5959
};
60+
61+
// units to be used in a dropdown
62+
63+
export const factorForDropdown = () => {
64+
return units.map((unit) => {
65+
return { label: unit, value: unit };
66+
});
67+
};
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import React, { useState } from "react";
2+
import ModalWrapper from "../../Common/ModalWrapper/ModalWrapper";
3+
import { createStyles, Theme, withStyles } from "@material-ui/core/styles";
4+
import { modalBasic } from "../../Common/FormComponents/common/styleLibrary";
5+
import InputBoxWrapper from "../../Common/FormComponents/InputBoxWrapper/InputBoxWrapper";
6+
import SelectWrapper from "../../Common/FormComponents/SelectWrapper/SelectWrapper";
7+
import Grid from "@material-ui/core/Grid";
8+
import { factorForDropdown } from "../../../../common/utils";
9+
import { Button, LinearProgress } from "@material-ui/core";
10+
11+
interface IAddZoneProps {
12+
classes: any;
13+
open: boolean;
14+
onCloseZoneAndReload: (shouldReload: boolean) => void;
15+
}
16+
17+
const styles = (theme: Theme) =>
18+
createStyles({
19+
errorBlock: {
20+
color: "red",
21+
},
22+
buttonContainer: {
23+
textAlign: "right",
24+
},
25+
multiContainer: {
26+
display: "flex",
27+
alignItems: "center" as const,
28+
justifyContent: "flex-start" as const,
29+
},
30+
sizeFactorContainer: {
31+
marginLeft: 8,
32+
},
33+
...modalBasic,
34+
});
35+
36+
const AddZoneModal = ({
37+
classes,
38+
open,
39+
onCloseZoneAndReload,
40+
}: IAddZoneProps) => {
41+
const [addSending, setAddSending] = useState<boolean>(false);
42+
const [zoneName, setZoneName] = useState<string>("");
43+
const [numberOfInstances, setNumberOfInstances] = useState<number>(0);
44+
const [volumesPerInstance, setVolumesPerInstance] = useState<number>(0);
45+
const [sizeFactor, setSizeFactor] = useState<string>("GiB");
46+
const [volumeConfiguration, setVolumeConfig] = useState<string>("");
47+
const [storageClass, setStorageClass] = useState<string>("");
48+
return (
49+
<ModalWrapper
50+
onClose={() => onCloseZoneAndReload(false)}
51+
modalOpen={open}
52+
title="Add Zone"
53+
>
54+
<form
55+
noValidate
56+
autoComplete="off"
57+
onSubmit={(e: React.FormEvent<HTMLFormElement>) => {
58+
e.preventDefault();
59+
setAddSending(true);
60+
}}
61+
>
62+
<Grid item xs={12}>
63+
<InputBoxWrapper
64+
id="zone_name"
65+
name="zone_name"
66+
type="string"
67+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
68+
setZoneName(e.target.value);
69+
}}
70+
label="Name"
71+
value={zoneName}
72+
/>
73+
</Grid>
74+
<Grid item xs={12}>
75+
<InputBoxWrapper
76+
id="number_instances"
77+
name="number_instances"
78+
type="number"
79+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
80+
setNumberOfInstances(parseInt(e.target.value));
81+
}}
82+
label="Volumes per Server"
83+
value={numberOfInstances.toString(10)}
84+
/>
85+
</Grid>
86+
<Grid item xs={12}>
87+
<InputBoxWrapper
88+
id="volumes_per_instance"
89+
name="volumes_per_instance"
90+
type="number"
91+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
92+
setVolumesPerInstance(parseInt(e.target.value));
93+
}}
94+
label="Volumes per Instance"
95+
value={volumesPerInstance.toString(10)}
96+
/>
97+
</Grid>
98+
<Grid item xs={12}>
99+
<div className={classes.multiContainer}>
100+
<div>
101+
<InputBoxWrapper
102+
id="volume_size"
103+
name="volume_size"
104+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
105+
setVolumeConfig(e.target.value);
106+
}}
107+
label="Size"
108+
value={volumeConfiguration}
109+
/>
110+
</div>
111+
<div className={classes.sizeFactorContainer}>
112+
<SelectWrapper
113+
label=""
114+
id="size_factor"
115+
name="size_factor"
116+
value={sizeFactor}
117+
onChange={(e: React.ChangeEvent<{ value: unknown }>) => {
118+
setSizeFactor(e.target.value as string);
119+
}}
120+
options={factorForDropdown()}
121+
/>
122+
</div>
123+
</div>
124+
<Grid item xs={12}>
125+
<InputBoxWrapper
126+
id="storage_class"
127+
name="storage_class"
128+
type="string"
129+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
130+
setStorageClass(e.target.value);
131+
}}
132+
label="Volumes per Server"
133+
value={storageClass}
134+
/>
135+
</Grid>
136+
<Grid item xs={12} className={classes.buttonContainer}>
137+
<Button
138+
type="submit"
139+
variant="contained"
140+
color="primary"
141+
disabled={addSending}
142+
>
143+
Save
144+
</Button>
145+
</Grid>
146+
{addSending && (
147+
<Grid item xs={12}>
148+
<LinearProgress />
149+
</Grid>
150+
)}
151+
</Grid>
152+
</form>
153+
</ModalWrapper>
154+
);
155+
};
156+
157+
export default withStyles(styles)(AddZoneModal);

0 commit comments

Comments
 (0)