Skip to content

Commit 70a4d76

Browse files
Service account ux (#1229)
Co-authored-by: Daniel Valdivia <[email protected]>
1 parent 373bfbf commit 70a4d76

File tree

9 files changed

+548
-253
lines changed

9 files changed

+548
-253
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2021 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React from "react";
18+
import { SvgIcon } from "@mui/material";
19+
const NewAccountIcon = () => {
20+
return (
21+
<SvgIcon>
22+
<svg
23+
id="Account_Icon"
24+
data-name="Account Icon"
25+
xmlns="http://www.w3.org/2000/svg"
26+
viewBox="0 0 16.409 13.096"
27+
>
28+
<path
29+
id="Trazado_391"
30+
data-name="Trazado 391"
31+
d="M-4332.855-1143.481a3.023,3.023,0,0,0,2.958-3.078,3.023,3.023,0,0,0-2.958-3.078,3.023,3.023,0,0,0-2.958,3.078A3.023,3.023,0,0,0-4332.855-1143.481Zm0-5.194a2.078,2.078,0,0,1,2.03,2.116,2.077,2.077,0,0,1-2.03,2.116,2.075,2.075,0,0,1-2.028-2.116A2.076,2.076,0,0,1-4332.855-1148.675Z"
32+
transform="translate(4339.12 1149.637)"
33+
fill="#07193e"
34+
/>
35+
<path
36+
id="Trazado_392"
37+
data-name="Trazado 392"
38+
d="M-4337.952-1130.053a1.374,1.374,0,0,0,1.252.775h4.993a1.354,1.354,0,0,0,1.25-.786,1.675,1.675,0,0,0-.164-1.686,4.521,4.521,0,0,0-1.7-1.405,4.361,4.361,0,0,0-2.125-.438,4.483,4.483,0,0,0-3.318,1.808c-.026.035-.051.071-.075.106A1.641,1.641,0,0,0-4337.952-1130.053Zm6.663-.437a.426.426,0,0,1-.417.25h-4.993a.453.453,0,0,1-.427-.254.64.64,0,0,1,.053-.632h0c.017-.027.037-.054.057-.08a3.539,3.539,0,0,1,2.622-1.424c.056,0,.113,0,.168,0a3.606,3.606,0,0,1,2.864,1.466A.686.686,0,0,1-4331.29-1130.49Z"
39+
transform="translate(4340.467 1140.236)"
40+
fill="#07193e"
41+
/>
42+
<path
43+
id="Trazado_393"
44+
data-name="Trazado 393"
45+
d="M-4329.387-1146.951h-3.506a.476.476,0,0,0-.477.476.477.477,0,0,0,.477.476h3.506a1.047,1.047,0,0,1,1.046,1.045v7.99a1.047,1.047,0,0,1-1.046,1.045H-4341.8a1.047,1.047,0,0,1-1.046-1.045v-7.99A1.048,1.048,0,0,1-4341.8-1146a.476.476,0,0,0,.476-.476.476.476,0,0,0-.476-.476,2,2,0,0,0-2,2v7.99a2,2,0,0,0,2,2h12.412a2,2,0,0,0,2-2v-7.99A2,2,0,0,0-4329.387-1146.951Z"
46+
transform="translate(4343.797 1148.063)"
47+
fill="#07193e"
48+
/>
49+
<rect
50+
id="Rectángulo_809"
51+
data-name="Rectángulo 809"
52+
width="3.266"
53+
height="2.781"
54+
rx="1.024"
55+
transform="translate(11.002 3.376)"
56+
fill="#07193e"
57+
/>
58+
<rect
59+
id="Rectángulo_810"
60+
data-name="Rectángulo 810"
61+
width="3.266"
62+
height="1.336"
63+
rx="0.668"
64+
transform="translate(11.002 7.328)"
65+
fill="#07193e"
66+
/>
67+
<rect
68+
id="Rectángulo_811"
69+
data-name="Rectángulo 811"
70+
width="3.266"
71+
height="1.336"
72+
rx="0.668"
73+
transform="translate(11.002 9.621)"
74+
fill="#07193e"
75+
/>
76+
</svg>
77+
</SvgIcon>
78+
);
79+
};
80+
81+
export default NewAccountIcon;

portal-ui/src/icons/WarnIcon.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2021 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import * as React from "react";
18+
19+
const WarnIcon = () => {
20+
return (
21+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
22+
<circle
23+
cx="8"
24+
cy="8"
25+
r="7"
26+
fill="none"
27+
stroke="#e04006"
28+
stroke-width="2"
29+
/>
30+
<path fill="none" stroke="#e04006" stroke-width="2" d="M8 4v6m0 1v2" />
31+
</svg>
32+
);
33+
};
34+
35+
export default WarnIcon;

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

Lines changed: 66 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import { Button, LinearProgress } from "@mui/material";
2121
import { Theme } from "@mui/material/styles";
2222
import createStyles from "@mui/styles/createStyles";
2323
import withStyles from "@mui/styles/withStyles";
24-
import { modalBasic } from "../Common/FormComponents/common/styleLibrary";
24+
import {
25+
modalBasic,
26+
serviceAccountStyles,
27+
} from "../Common/FormComponents/common/styleLibrary";
2528
import { NewServiceAccount } from "../Common/CredentialsPrompt/types";
2629
import { setModalErrorSnackMessage } from "../../../actions";
2730
import { ErrorResponseHandler } from "../../../common/types";
@@ -33,26 +36,7 @@ import InputBoxWrapper from "../Common/FormComponents/InputBoxWrapper/InputBoxWr
3336

3437
const styles = (theme: Theme) =>
3538
createStyles({
36-
jsonPolicyEditor: {
37-
minHeight: 400,
38-
width: "100%",
39-
},
40-
buttonContainer: {
41-
textAlign: "right",
42-
},
43-
infoDetails: {
44-
color: "#393939",
45-
fontSize: 12,
46-
fontStyle: "italic",
47-
marginBottom: "8px",
48-
},
49-
containerScrollable: {
50-
maxHeight: "calc(100vh - 300px)" as const,
51-
overflowY: "auto" as const,
52-
},
53-
codeMirrorContainer: {
54-
marginBottom: 20,
55-
},
39+
...serviceAccountStyles,
5640
...modalBasic,
5741
});
5842

@@ -157,72 +141,82 @@ const AddServiceAccount = ({
157141
</div>
158142
</Grid>
159143
<Grid item xs={12}>
160-
<FormSwitchWrapper
161-
value="locking"
162-
id="locking"
163-
name="locking"
164-
checked={isRestrictedByPolicy}
165-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
166-
setIsRestrictedByPolicy(event.target.checked);
167-
}}
168-
label={"Restrict with policy"}
169-
/>
170-
<FormSwitchWrapper
171-
value="locking"
172-
id="locking"
173-
name="locking"
174-
checked={addCredentials}
175-
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
176-
setAddCredentials(event.target.checked);
177-
}}
178-
label={"Customize Credentials"}
179-
/>
180-
</Grid>
181-
{isRestrictedByPolicy && (
182-
<Grid item xs={12} className={classes.codeMirrorContainer}>
183-
<CodeMirrorWrapper
184-
value={policyDefinition}
185-
onBeforeChange={(editor, data, value) => {
186-
setPolicyDefinition(value);
144+
<Grid item xs={12}>
145+
<FormSwitchWrapper
146+
value="locking"
147+
classes={classes}
148+
id="locking"
149+
name="locking"
150+
checked={addCredentials}
151+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
152+
setAddCredentials(event.target.checked);
187153
}}
154+
label={"Customize Credentials"}
188155
/>
156+
{addCredentials && (
157+
<Grid item xs={12}>
158+
<div className={classes.stackedInputs}>
159+
<InputBoxWrapper
160+
value={accessKey}
161+
label={"Access Key"}
162+
id={"accessKey"}
163+
name={"accessKey"}
164+
placeholder={"Enter Access Key"}
165+
onChange={(e) => {
166+
setAccessKey(e.target.value);
167+
}}
168+
/>
169+
<InputBoxWrapper
170+
value={secretKey}
171+
label={"Secret Key"}
172+
id={"secretKey"}
173+
name={"secretKey"}
174+
placeholder={"Enter Secret Key"}
175+
onChange={(e) => {
176+
setSecretKey(e.target.value);
177+
}}
178+
/>
179+
</div>
180+
</Grid>
181+
)}
189182
</Grid>
190-
)}
191-
{addCredentials && (
192183
<Grid item xs={12}>
193-
<InputBoxWrapper
194-
value={accessKey}
195-
label={"Access Key"}
196-
id={"accessKey"}
197-
name={"accessKey"}
198-
placeholder={"Enter Access Key"}
199-
onChange={(e) => {
200-
setAccessKey(e.target.value);
201-
}}
202-
/>
203-
<InputBoxWrapper
204-
value={secretKey}
205-
label={"Secret Key"}
206-
id={"secretKey"}
207-
name={"secretKey"}
208-
placeholder={"Enter Secret Key"}
209-
onChange={(e) => {
210-
setSecretKey(e.target.value);
184+
<FormSwitchWrapper
185+
value="locking"
186+
id="locking"
187+
name="locking"
188+
classes={classes}
189+
checked={isRestrictedByPolicy}
190+
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
191+
setIsRestrictedByPolicy(event.target.checked);
211192
}}
193+
label={"Restrict with policy"}
212194
/>
195+
{isRestrictedByPolicy && (
196+
<Grid item xs={12} className={classes.codeMirrorContainer}>
197+
<CodeMirrorWrapper
198+
label={"Policy "}
199+
value={policyDefinition}
200+
onBeforeChange={(editor, data, value) => {
201+
setPolicyDefinition(value);
202+
}}
203+
/>
204+
</Grid>
205+
)}
213206
</Grid>
214-
)}
207+
</Grid>
215208
</Grid>
216209
<Grid container>
217210
<Grid item xs={12} className={classes.buttonContainer}>
218-
<button
211+
<Button
219212
type="button"
220213
color="primary"
221-
className={classes.clearButton}
214+
variant="outlined"
215+
className={classes.buttonSpacer}
222216
onClick={resetForm}
223217
>
224218
Clear
225-
</button>
219+
</Button>
226220
<Button
227221
type="submit"
228222
variant="contained"
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// This file is part of MinIO Console Server
2+
// Copyright (c) 2021 MinIO, Inc.
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
17+
import React from "react";
18+
import { InputAdornment, OutlinedInput } from "@mui/material";
19+
import BoxIconButton from "../BoxIconButton/BoxIconButton";
20+
import withStyles from "@mui/styles/withStyles";
21+
import { Theme } from "@mui/material/styles";
22+
import createStyles from "@mui/styles/createStyles";
23+
import CopyToClipboard from "react-copy-to-clipboard";
24+
import { CopyIcon } from "../../../../icons";
25+
26+
const styles = (theme: Theme) =>
27+
createStyles({
28+
container: {
29+
display: "flex",
30+
flexFlow: "column",
31+
padding: "20px 0 8px 0",
32+
},
33+
inputWithCopy: {
34+
"& .MuiInputBase-root ": {
35+
width: "100%",
36+
background: "#FBFAFA",
37+
"& .MuiInputBase-input": {
38+
height: ".8rem",
39+
},
40+
"& .MuiInputAdornment-positionEnd": {
41+
marginRight: ".5rem",
42+
"& .MuiButtonBase-root": {
43+
height: "2rem",
44+
},
45+
},
46+
},
47+
"& .MuiButtonBase-root .MuiSvgIcon-root": {
48+
fontSize: ".8rem",
49+
},
50+
},
51+
inputLabel: {
52+
fontSize: ".8rem",
53+
fontWeight: 600,
54+
},
55+
});
56+
57+
const CredentialItem = ({
58+
label = "",
59+
value = "",
60+
classes = {},
61+
}: {
62+
label: string;
63+
value: string;
64+
classes: any;
65+
}) => {
66+
return (
67+
<div className={classes.container}>
68+
<div className={classes.inputLabel}>{label}:</div>
69+
<div className={classes.inputWithCopy}>
70+
<OutlinedInput
71+
value={value}
72+
readOnly
73+
endAdornment={
74+
<InputAdornment position="end">
75+
<CopyToClipboard text={value}>
76+
<BoxIconButton
77+
aria-label="copy"
78+
tooltip={"Copy"}
79+
onClick={() => {}}
80+
onMouseDown={() => {}}
81+
edge="end"
82+
>
83+
<CopyIcon />
84+
</BoxIconButton>
85+
</CopyToClipboard>
86+
</InputAdornment>
87+
}
88+
/>
89+
</div>
90+
</div>
91+
);
92+
};
93+
94+
export default withStyles(styles)(CredentialItem);

0 commit comments

Comments
 (0)