blob: 984264dc4550c9491ea50fe0d4abfed34809d791 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import React, { useState } from 'react'
import { Button } from '@patternfly/react-core'
import { useMutation } from 'react-query'
import { PlusIcon } from '@patternfly/react-icons'
import { buttonContainer } from './NewProject.module.scss'
import TextInputModal from '../util/modals/TextInputModal'
/**
* A container for creating a new project.
*/
const NewProject = () => {
const [isVisible, setVisible] = useState(false)
const { mutate: addProject } = useMutation('addProject')
const onSubmit = (name) => {
if (name) {
addProject({ name })
}
setVisible(false)
}
return (
<>
<div className={buttonContainer}>
<Button
icon={<PlusIcon />}
color="primary"
className="pf-u-float-right"
onClick={() => setVisible(true)}
>
New Project
</Button>
</div>
<TextInputModal title="New Project" label="Project name" isOpen={isVisible} callback={onSubmit} />
</>
)
}
export default NewProject
|