Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(help): add help button in main space (#1223)
- Loading branch information
Showing
10 changed files
with
149 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { FC, useState } from "react"; | ||
import Box from "@material-ui/core/Box"; | ||
import Button from "@material-ui/core/Button"; | ||
import { ListItemIcon, ListItemText, Menu, MenuItem } from "@material-ui/core"; | ||
import { | ||
FaBook, | ||
FaEnvelope, | ||
FaGrinStars, | ||
FaLightbulb, | ||
FaQuestionCircle, | ||
} from "react-icons/fa"; | ||
import { useStyles } from "../../hooks/use-styles"; | ||
import { | ||
CONTACT_LINK, | ||
DOCUMENTATION_LINK, | ||
FEEDBACK_LINK, | ||
SUGGEST_FEATURE_LINK, | ||
} from "../../constants"; | ||
import { useTranslation } from "react-i18next"; | ||
import { openLink } from "../../util/electron/electron-util"; | ||
|
||
const HelpButton: FC = () => { | ||
const [anchorEl, setAnchorEl] = useState(null); | ||
const { t } = useTranslation(); | ||
const classes = useStyles(); | ||
|
||
const menuItems = [ | ||
{ | ||
label: t("folderDropzone.feedback"), | ||
Icon: FaGrinStars, | ||
link: FEEDBACK_LINK, | ||
}, | ||
{ | ||
label: t("folderDropzone.contactUs"), | ||
Icon: FaEnvelope, | ||
link: CONTACT_LINK, | ||
}, | ||
{ | ||
label: t("folderDropzone.suggestFeature"), | ||
Icon: FaLightbulb, | ||
link: SUGGEST_FEATURE_LINK, | ||
}, | ||
{ | ||
label: t("folderDropzone.documentation"), | ||
Icon: FaBook, | ||
link: DOCUMENTATION_LINK, | ||
}, | ||
]; | ||
|
||
const handleButtonClick = (event): void => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const closeMenu = (): void => setAnchorEl(null); | ||
|
||
const handleItemClick = (link: string): void => { | ||
openLink(link); | ||
closeMenu(); | ||
}; | ||
|
||
return ( | ||
<Box> | ||
<Button | ||
aria-controls="help-menu" | ||
aria-haspopup="true" | ||
onClick={handleButtonClick} | ||
className={classes.headerButton} | ||
> | ||
<FaQuestionCircle /> | ||
</Button> | ||
<Menu | ||
id="help-menu" | ||
getContentAnchorEl={null} | ||
anchorEl={anchorEl} | ||
keepMounted | ||
open={Boolean(anchorEl)} | ||
onClose={closeMenu} | ||
anchorOrigin={{ | ||
vertical: "top", | ||
horizontal: "right", | ||
}} | ||
transformOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "right", | ||
}} | ||
> | ||
{menuItems.map(({ label, link, Icon }) => ( | ||
<MenuItem key={label} onClick={() => handleItemClick(link)}> | ||
<ListItemIcon> | ||
<Icon /> | ||
</ListItemIcon> | ||
<ListItemText>{label}</ListItemText> | ||
</MenuItem> | ||
))} | ||
</Menu> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default HelpButton; |
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,7 @@ | ||
export const FEEDBACK_LINK = | ||
"https://archifiltre.fabrique.social.gouv.fr/questionnaire/"; | ||
export const CONTACT_LINK = "mailto:archifiltre@sg.social.gouv.fr"; | ||
export const DOCUMENTATION_LINK = | ||
"https://github.com/SocialGouv/archifiltre/wiki/Wiki-Archifiltre"; | ||
export const SUGGEST_FEATURE_LINK = | ||
"https://github.com/SocialGouv/archifiltre/issues"; |
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 |
---|---|---|
@@ -1,6 +1,14 @@ | ||
import { remote } from "electron"; | ||
import { remote, shell } from "electron"; | ||
|
||
/** | ||
* Reloads the app. Acts like F5 or CTRL+R | ||
*/ | ||
export const reloadApp = (): void => remote.getCurrentWindow().reload(); | ||
|
||
/** | ||
* Opens a link in the user's browser | ||
* @param link | ||
*/ | ||
export const openLink = (link: string): void => { | ||
shell.openExternal(link); | ||
}; |