2020-07-31 04:12:40 -07:00
|
|
|
import React, {useState, useEffect} from 'react';
|
|
|
|
|
import {
|
|
|
|
|
Paper,
|
|
|
|
|
IconButton,
|
|
|
|
|
Menu,
|
|
|
|
|
MenuItem,
|
|
|
|
|
Typography,
|
|
|
|
|
Grid,
|
|
|
|
|
Box,
|
|
|
|
|
Link,
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogContentText,
|
|
|
|
|
TextField,
|
|
|
|
|
DialogActions,
|
|
|
|
|
Button,
|
|
|
|
|
FormControl,
|
|
|
|
|
InputLabel,
|
|
|
|
|
Select,
|
|
|
|
|
} from "@material-ui/core";
|
|
|
|
|
import { MoreVert as MoreIcon } from "@material-ui/icons";
|
|
|
|
|
import {useHistory} from "react-router-dom";
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
|
|
|
|
|
// styles
|
|
|
|
|
import useStyles from "./styles";
|
|
|
|
|
|
|
|
|
|
import Widget from "../../components/Widget";
|
|
|
|
|
import SqueakThreadItem from "../../components/SqueakThreadItem";
|
|
|
|
|
|
|
|
|
|
import {
|
2020-10-19 13:08:51 -04:00
|
|
|
createSigningProfileRequest,
|
2020-10-19 11:43:08 -04:00
|
|
|
} from "../../squeakclient/requests"
|
2020-07-31 04:12:40 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
export default function CreateSigningProfileDialog({
|
|
|
|
|
open,
|
|
|
|
|
handleClose,
|
|
|
|
|
...props
|
|
|
|
|
}) {
|
|
|
|
|
var classes = useStyles();
|
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
|
|
var [profileName, setProfileName] = useState('');
|
|
|
|
|
|
2020-08-04 21:46:17 -07:00
|
|
|
const resetFields = () => {
|
|
|
|
|
setProfileName('');
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-31 04:12:40 -07:00
|
|
|
const handleChangeProfileName = (event) => {
|
|
|
|
|
setProfileName(event.target.value);
|
|
|
|
|
};
|
|
|
|
|
|
2020-10-19 13:08:51 -04:00
|
|
|
const handleResponse = (response) => {
|
|
|
|
|
goToProfilePage(response.getProfileId());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleErr = (err) => {
|
2021-01-24 07:20:42 +02:00
|
|
|
alert('Error creating signing profile: ' + err);
|
2020-10-19 13:08:51 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const createSigningProfile = (profileName) => {
|
|
|
|
|
createSigningProfileRequest(profileName, handleResponse, handleErr);
|
2020-07-31 04:12:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const goToProfilePage = (profileId) => {
|
|
|
|
|
history.push("/app/profile/" + profileId);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function handleSubmit(event) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
console.log( 'profileName:', profileName);
|
|
|
|
|
if (!profileName) {
|
|
|
|
|
alert('Profile Name cannot be empty.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-10-19 13:08:51 -04:00
|
|
|
createSigningProfile(profileName);
|
2020-07-31 04:12:40 -07:00
|
|
|
handleClose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CreateSigningProfileNameInput() {
|
|
|
|
|
return (
|
|
|
|
|
<TextField
|
|
|
|
|
id="standard-textarea"
|
|
|
|
|
label="Profile Name"
|
|
|
|
|
required
|
|
|
|
|
autoFocus
|
|
|
|
|
value={profileName}
|
|
|
|
|
onChange={handleChangeProfileName}
|
|
|
|
|
fullWidth
|
|
|
|
|
inputProps={{ maxLength: 64 }}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CancelButton() {
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
onClick={handleClose}
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="secondary"
|
|
|
|
|
>
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CreateSigningProfilButton() {
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="primary"
|
|
|
|
|
className={classes.button}
|
|
|
|
|
>
|
|
|
|
|
Create Signing Profile
|
|
|
|
|
</Button>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2020-08-04 21:46:17 -07:00
|
|
|
<Dialog open={open} onEnter={resetFields} onClose={handleClose} aria-labelledby="form-dialog-title">
|
2020-07-31 04:12:40 -07:00
|
|
|
<DialogTitle id="form-dialog-title">Create Signing Profile</DialogTitle>
|
|
|
|
|
<form className={classes.root} onSubmit={handleSubmit} noValidate autoComplete="off">
|
|
|
|
|
<DialogContent>
|
|
|
|
|
{CreateSigningProfileNameInput()}
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
{CancelButton()}
|
|
|
|
|
{CreateSigningProfilButton()}
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</form>
|
|
|
|
|
</Dialog>
|
|
|
|
|
)
|
|
|
|
|
}
|