fleet/frontend/pages/admin/TeamManagementPage/components/CreateTeamModal/CreateTeamModal.tsx
Martavis Parker bcfac603f0
Added components to Storybook library (#2768)
* added storybook

* added avatar component

* added button story

* added dropdown button story

* removed unused ellipsis component

* cleaned up modal path

* reorganized enroll secrets table file

* added flash story; removed unused persistent flash

* added fleet ace story

* added checkbox story

* added dropdown story

* added input story

* fixed storybook build

* fixed avatar

* added input with icon story

* added radio button story

* added select targets dropdown story

* added slider story

* added tooltip story

* added info banner story

* removed unused loaders; added spinner story

* added modal story

* removed unused NumberPill

* added pagination story

* lint fixes

* added documentation to run

* modified documentation

* fixed corelayout test

* fixed format for date-fns

* fixed date format that breaks tests

* wait for page
2021-11-06 23:41:09 -07:00

89 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useState, useCallback } from "react";
import Modal from "components/Modal";
import Button from "components/buttons/Button";
import InfoBanner from "components/InfoBanner/InfoBanner";
// @ts-ignore
import InputFieldWithIcon from "components/forms/fields/InputFieldWithIcon";
const baseClass = "create-team-modal";
export interface ICreateTeamFormData {
name: string;
}
interface ICreateTeamModalProps {
onCancel: () => void;
onSubmit: (formData: ICreateTeamFormData) => void;
}
const CreateTeamModal = ({
onCancel,
onSubmit,
}: ICreateTeamModalProps): JSX.Element => {
const [name, setName] = useState("");
const onInputChange = useCallback(
(value: string) => {
setName(value);
},
[setName]
);
const onFormSubmit = useCallback(
(evt) => {
evt.preventDefault();
onSubmit({
name,
});
},
[onSubmit, name]
);
return (
<Modal title={"Create team"} onExit={onCancel} className={baseClass}>
<form
className={`${baseClass}__form`}
onSubmit={onFormSubmit}
autoComplete="off"
>
<InputFieldWithIcon
autofocus
name="name"
onChange={onInputChange}
placeholder="Team name"
value={name}
/>
<InfoBanner className={`${baseClass}__sandbox-info`}>
<p className={`${baseClass}__info-header`}>
Need to test queries and configurations before deploying?
</p>
<p>
A popular pattern is to end a teams name with - Sandbox, then you
can use this to test new queries and configuration with staging
hosts or volunteers acting as canaries.
</p>
</InfoBanner>
<div className={`${baseClass}__btn-wrap`}>
<Button
className={`${baseClass}__btn`}
type="submit"
variant="brand"
disabled={name === ""}
>
Create
</Button>
<Button
className={`${baseClass}__btn`}
onClick={onCancel}
variant="inverse"
>
Cancel
</Button>
</div>
</form>
</Modal>
);
};
export default CreateTeamModal;