-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add load connections form * add async functions to better handle loading status * new connection dropdown, fix preserving connection settings, set source in edit, style fixes * lint * lint * lint * lint
- Loading branch information
1 parent
b5b827a
commit 9191c58
Showing
21 changed files
with
3,061 additions
and
1,546 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Typography, | ||
} from '@mui/material'; | ||
import React, { FC } from 'react'; | ||
import { ChevronDown } from 'react-feather'; | ||
|
||
export type AdvancedSettingsAccordionProps = React.PropsWithChildren; | ||
const AdvancedSettingsAccordion: FC<AdvancedSettingsAccordionProps> = ({ | ||
children, | ||
}) => { | ||
return ( | ||
<Accordion | ||
sx={{ | ||
backgroundColor: 'background.paper', | ||
marginTop: 2, | ||
paddingLeft: 2, | ||
paddingRight: 2, | ||
borderRadius: 4, | ||
'&:before': { | ||
display: 'none', | ||
}, | ||
}} | ||
square={false} | ||
> | ||
<AccordionSummary | ||
expandIcon={<ChevronDown />} | ||
aria-controls="advanced-settings-content" | ||
id="advanced-settings-header" | ||
> | ||
<Typography variant="h5">Advanced Settings</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails>{children}</AccordionDetails> | ||
</Accordion> | ||
); | ||
}; | ||
export default AdvancedSettingsAccordion; |
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,120 @@ | ||
/* eslint-disable react/jsx-props-no-spreading */ | ||
import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline'; | ||
import { | ||
Button, | ||
ClickAwayListener, | ||
Grow, | ||
MenuItem, | ||
MenuList, | ||
Paper, | ||
Popper, | ||
Stack, | ||
Typography, | ||
} from '@mui/material'; | ||
import React, { FC, useRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import usePopover from '../hooks/use-popover'; | ||
|
||
const NewConnectionButton: FC = () => { | ||
const popover = usePopover<HTMLButtonElement>(); | ||
const navigate = useNavigate(); | ||
const anchorRef = useRef<HTMLDivElement>(null); | ||
|
||
const handleClose = (event: Event) => { | ||
if ( | ||
anchorRef.current && | ||
anchorRef.current.contains(event.target as HTMLElement) | ||
) { | ||
return; | ||
} | ||
popover.handleClose(); | ||
}; | ||
|
||
const handleMenuItemClick = (key: string) => { | ||
popover.handleClose(); | ||
switch (key) { | ||
case 'load': | ||
navigate(`/loadForm`, { | ||
replace: true, | ||
}); | ||
break; | ||
case 'add': | ||
navigate(`/connectForm`, { | ||
replace: true, | ||
}); | ||
break; | ||
default: | ||
break; | ||
} | ||
}; | ||
|
||
const options = [ | ||
{ | ||
key: 'load', | ||
title: 'Load Connections', | ||
}, | ||
{ | ||
key: 'add', | ||
title: 'Add Connecton', | ||
}, | ||
]; | ||
|
||
return ( | ||
<> | ||
<Button | ||
variant="contained" | ||
color="primary" | ||
ref={popover.anchorRef} | ||
onClick={popover.handleOpen} | ||
startIcon={<AddCircleOutlineIcon />} | ||
> | ||
<Typography variant="button">New Connection</Typography> | ||
</Button> | ||
<Popper | ||
sx={{ zIndex: 1 }} | ||
open={popover.open} | ||
anchorEl={popover.anchorRef.current} | ||
role={undefined} | ||
transition | ||
disablePortal | ||
placement="bottom-end" | ||
> | ||
{({ TransitionProps, placement }) => ( | ||
<Grow | ||
{...TransitionProps} | ||
style={{ | ||
transformOrigin: | ||
placement === 'bottom' ? 'center top' : 'center bottom', | ||
}} | ||
> | ||
<Paper> | ||
<ClickAwayListener onClickAway={handleClose}> | ||
<MenuList id="split-button-menu" autoFocusItem disablePadding> | ||
{options.map((option) => ( | ||
<MenuItem | ||
key={option.key} | ||
onClick={() => handleMenuItemClick(option.key)} | ||
sx={{ borderRadius: 1 }} | ||
divider | ||
> | ||
<Stack | ||
direction="row" | ||
spacing={1} | ||
justifyContent="center" | ||
> | ||
<Typography variant="button">{option.title}</Typography> | ||
</Stack> | ||
</MenuItem> | ||
))} | ||
</MenuList> | ||
</ClickAwayListener> | ||
</Paper> | ||
</Grow> | ||
)} | ||
</Popper> | ||
</> | ||
); | ||
}; | ||
|
||
export default NewConnectionButton; |
Oops, something went wrong.