forked from giranm/pd-live-react
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from PagerDuty/release/0.10.2-beta.0
- Loading branch information
Showing
15 changed files
with
1,061 additions
and
826 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
src/components/IncidentTable/subcomponents/LatestNoteComponent.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import React, { | ||
useRef, | ||
useState, | ||
} from 'react'; | ||
|
||
import { | ||
useDispatch, | ||
} from 'react-redux'; | ||
|
||
import { | ||
Box, | ||
Flex, | ||
IconButton, | ||
Popover, | ||
PopoverTrigger, | ||
PopoverContent, | ||
PopoverBody, | ||
PopoverArrow, | ||
PopoverCloseButton, | ||
Skeleton, | ||
PopoverHeader, | ||
Textarea, | ||
useDisclosure, | ||
} from '@chakra-ui/react'; | ||
|
||
import { | ||
AddIcon, | ||
CheckIcon, | ||
} from '@chakra-ui/icons'; | ||
|
||
import i18next from 'i18next'; | ||
|
||
import Linkify from 'linkify-react'; | ||
|
||
import { | ||
addNote as addNoteConnected, | ||
} from 'src/redux/incident_actions/actions'; | ||
|
||
const linkifyOptions = { target: { url: '_blank' }, rel: 'noopener noreferrer' }; | ||
|
||
const LatestNoteComponent = ({ | ||
incident, | ||
}) => { | ||
const noteRef = useRef(null); | ||
const [note, setNote] = useState(''); | ||
const { | ||
isOpen, | ||
onToggle, | ||
onClose, | ||
} = useDisclosure(); | ||
const dispatch = useDispatch(); | ||
const addNote = (incidents, noteContent) => dispatch(addNoteConnected(incidents, noteContent, true, false)); | ||
|
||
return ( | ||
<Box | ||
position="relative" | ||
width="full" | ||
display="flex" | ||
alignItems="center" | ||
justifyContent="space-between" | ||
> | ||
<Box | ||
className="td-wrapper" | ||
pr={8} | ||
> | ||
<Linkify options={linkifyOptions}> | ||
{incident.notes?.length > 0 && incident.notes.slice(-1)[0].content} | ||
{incident.notes?.length === 0 && '--'} | ||
{incident.notes?.status === 'fetching' && <Skeleton>fetching</Skeleton>} | ||
</Linkify> | ||
</Box> | ||
<Popover | ||
isOpen={isOpen} | ||
onClose={onClose} | ||
initialFocusRef={noteRef} | ||
> | ||
<PopoverTrigger> | ||
<IconButton | ||
size="xs" | ||
position="absolute" | ||
right={0} | ||
top="50%" | ||
transform="translateY(-50%)" | ||
colorScheme="blue" | ||
icon={<AddIcon />} | ||
onClick={() => { | ||
onToggle(); | ||
}} | ||
aria-label={i18next.t('Add Note')} | ||
/> | ||
</PopoverTrigger> | ||
<PopoverContent> | ||
<PopoverArrow /> | ||
<PopoverCloseButton /> | ||
<PopoverHeader> | ||
{i18next.t('Add Note')} | ||
</PopoverHeader> | ||
<PopoverBody> | ||
<Flex> | ||
<Textarea | ||
size="sm" | ||
resize="none" | ||
ref={noteRef} | ||
value={note} | ||
onChange={(e) => { | ||
setNote(e.target.value); | ||
}} | ||
/> | ||
<IconButton | ||
size="sm" | ||
ml={2} | ||
onClick={() => { | ||
addNote([incident], note); | ||
setNote(''); | ||
onClose(); | ||
}} | ||
isDisabled={!note} | ||
colorScheme="blue" | ||
icon={<CheckIcon />} | ||
/> | ||
</Flex> | ||
</PopoverBody> | ||
</PopoverContent> | ||
</Popover> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default LatestNoteComponent; |
Oops, something went wrong.