2021-04-14 16:52:15 +00:00
|
|
|
|
import React, { useState, useCallback } from "react";
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
2021-11-07 06:41:09 +00:00
|
|
|
|
import Modal from "components/Modal";
|
2021-04-14 16:52:15 +00:00
|
|
|
|
import Button from "components/buttons/Button";
|
|
|
|
|
|
import InfoBanner from "components/InfoBanner/InfoBanner";
|
2021-04-29 13:47:33 +00:00
|
|
|
|
// @ts-ignore
|
|
|
|
|
|
import InputFieldWithIcon from "components/forms/fields/InputFieldWithIcon";
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
2021-04-14 16:52:15 +00:00
|
|
|
|
const baseClass = "create-team-modal";
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
|
|
|
|
|
export interface ICreateTeamFormData {
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
interface ICreateTeamModalProps {
|
|
|
|
|
|
onCancel: () => void;
|
|
|
|
|
|
onSubmit: (formData: ICreateTeamFormData) => void;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-10-22 15:34:45 +00:00
|
|
|
|
const CreateTeamModal = ({
|
|
|
|
|
|
onCancel,
|
|
|
|
|
|
onSubmit,
|
|
|
|
|
|
}: ICreateTeamModalProps): JSX.Element => {
|
2021-04-14 16:52:15 +00:00
|
|
|
|
const [name, setName] = useState("");
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
2021-04-14 16:52:15 +00:00
|
|
|
|
const onInputChange = useCallback(
|
|
|
|
|
|
(value: string) => {
|
|
|
|
|
|
setName(value);
|
|
|
|
|
|
},
|
|
|
|
|
|
[setName]
|
|
|
|
|
|
);
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
2021-04-30 19:13:04 +00:00
|
|
|
|
const onFormSubmit = useCallback(
|
|
|
|
|
|
(evt) => {
|
|
|
|
|
|
evt.preventDefault();
|
|
|
|
|
|
onSubmit({
|
|
|
|
|
|
name,
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
[onSubmit, name]
|
|
|
|
|
|
);
|
2021-04-14 09:20:56 +00:00
|
|
|
|
|
|
|
|
|
|
return (
|
2021-04-14 16:52:15 +00:00
|
|
|
|
<Modal title={"Create team"} onExit={onCancel} className={baseClass}>
|
2021-10-27 17:31:45 +00:00
|
|
|
|
<form
|
|
|
|
|
|
className={`${baseClass}__form`}
|
|
|
|
|
|
onSubmit={onFormSubmit}
|
|
|
|
|
|
autoComplete="off"
|
|
|
|
|
|
>
|
2021-04-14 09:20:56 +00:00
|
|
|
|
<InputFieldWithIcon
|
|
|
|
|
|
autofocus
|
|
|
|
|
|
name="name"
|
|
|
|
|
|
onChange={onInputChange}
|
|
|
|
|
|
placeholder="Team name"
|
|
|
|
|
|
value={name}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<InfoBanner className={`${baseClass}__sandbox-info`}>
|
2021-04-14 16:52:15 +00:00
|
|
|
|
<p className={`${baseClass}__info-header`}>
|
|
|
|
|
|
Need to test queries and configurations before deploying?
|
|
|
|
|
|
</p>
|
|
|
|
|
|
<p>
|
|
|
|
|
|
A popular pattern is to end a team’s name with “- Sandbox”, then you
|
|
|
|
|
|
can use this to test new queries and configuration with staging
|
|
|
|
|
|
hosts or volunteers acting as canaries.
|
|
|
|
|
|
</p>
|
2021-04-14 09:20:56 +00:00
|
|
|
|
</InfoBanner>
|
|
|
|
|
|
<div className={`${baseClass}__btn-wrap`}>
|
2021-10-27 17:52:49 +00:00
|
|
|
|
<Button
|
|
|
|
|
|
className={`${baseClass}__btn`}
|
|
|
|
|
|
type="submit"
|
|
|
|
|
|
variant="brand"
|
|
|
|
|
|
disabled={name === ""}
|
|
|
|
|
|
>
|
2021-04-14 09:20:56 +00:00
|
|
|
|
Create
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
className={`${baseClass}__btn`}
|
|
|
|
|
|
onClick={onCancel}
|
|
|
|
|
|
variant="inverse"
|
|
|
|
|
|
>
|
|
|
|
|
|
Cancel
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</form>
|
|
|
|
|
|
</Modal>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default CreateTeamModal;
|