blob: bfa7c01adbaf7ee7e0805c9a1966a9e83b521deb (
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 { PlusIcon } from '@patternfly/react-icons'
import { useNewProject } from '../../data/project'
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 } = useNewProject()
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
|