Skip to content

Commit 795ca0c

Browse files
authored
fix: display projects menu (#254)
1 parent e6582d1 commit 795ca0c

File tree

5 files changed

+30
-18
lines changed

5 files changed

+30
-18
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [1.2.1] — 2021-04-16
11+
12+
- [Bugfix]: Correctly display projects and account menus (@fargito)
13+
1014
## [1.2.0] — 2021-04-16
1115

1216
- [Security] : Bump Python version to 3.8 (@fargito)
@@ -78,7 +82,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7882

7983
🎉Initial release! 🎉
8084

81-
[unreleased]: https://github.com/theodo/falco/compare/1.2.0...HEAD
85+
[unreleased]: https://github.com/theodo/falco/compare/1.2.1...HEAD
86+
[1.2.1]: https://github.com/theodo/falco/compare/1.2.1...1.2.0
8287
[1.2.0]: https://github.com/theodo/falco/compare/1.2.0...1.1.5
8388
[1.1.5]: https://github.com/theodo/falco/compare/1.1.5...1.1.4
8489
[1.1.4]: https://github.com/theodo/falco/compare/1.1.4...1.1.3

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ You can try a demo version by logging in to https://falco.theo.do with the crede
3737

3838
You can deploy Falco on Heroku by clicking on the following button:
3939

40-
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.0)
40+
[![Deploy to Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.1)
4141

4242
You will need to provide your credit card details to Heroku, but you will be under the free tier by default. You can find more details on why they are needed and Heroku’s pricing policy [in the docs](https://getfal.co).
4343

docs/docs/getting-started/installation.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import Link from "@docusaurus/Link";
4343
<Link
4444
className="button button--primary button--lg"
4545
href={
46-
"https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.0"
46+
"https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.1"
4747
}
4848
style={{ marginBottom: "20px" }}
4949
>

docs/src/pages/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function Home() {
106106
"button button--primary button--lg",
107107
styles.addFocus
108108
)}
109-
href="https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.0"
109+
href="https://heroku.com/deploy?template=https://github.com/theodo/falco/tree/1.2.1"
110110
target="_blank"
111111
>
112112
Deploy to Heroku

frontend/src/components/Root/components/Header/Header.tsx

+21-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { MouseEvent, useState } from 'react';
1+
import { MouseEvent, useEffect, useState } from 'react';
22

33
import Logo from 'components/Logo';
44
import { FormattedMessage, useIntl } from 'react-intl';
@@ -31,58 +31,65 @@ interface Props {
3131
fetchUserRequest: () => void;
3232
}
3333

34-
export const Header: React.FunctionComponent<Props> = ({
34+
enum HeaderMenuState {
35+
DEFAULT = 'DEFAULT',
36+
ACCOUNT_MENU_OPEN = 'ACCOUNT_MENU_OPEN',
37+
PROJECTS_MENU_OPEN = 'PROJECTS_MENU_OPEN',
38+
}
39+
40+
export const Header = ({
3541
currentURL,
3642
fetchUserRequest,
3743
isUserAuthenticated,
3844
isMenuDisplayed,
39-
}) => {
45+
}: Props): JSX.Element => {
4046
const intl = useIntl();
4147

42-
const [isAccountMenuVisible, setIsAccountMenuVisible] = React.useState(false);
43-
const [isProjectsMenuVisible, setIsProjectsMenuVisible] = React.useState(false);
48+
const [headerMenuState, setHeaderMenuState] = useState<HeaderMenuState>(HeaderMenuState.DEFAULT);
4449

45-
React.useEffect(() => {
50+
useEffect(() => {
4651
if (isUserAuthenticated) {
4752
fetchUserRequest();
4853
}
4954
}, [isUserAuthenticated, fetchUserRequest]);
5055

5156
const toggleAccountMenuVisibility = (event: MouseEvent) => {
5257
event.preventDefault();
53-
if (isAccountMenuVisible) {
58+
event.stopPropagation();
59+
if (headerMenuState === HeaderMenuState.ACCOUNT_MENU_OPEN) {
5460
hideAccountMenu();
5561
} else {
5662
showAccountMenu();
5763
}
5864
};
5965

6066
const showAccountMenu = () => {
61-
setIsAccountMenuVisible(true);
67+
setHeaderMenuState(HeaderMenuState.ACCOUNT_MENU_OPEN);
6268
document.addEventListener('click', hideAccountMenu);
6369
};
6470

6571
const hideAccountMenu = () => {
66-
setIsAccountMenuVisible(false);
72+
setHeaderMenuState(HeaderMenuState.DEFAULT);
6773
document.removeEventListener('click', hideAccountMenu);
6874
};
6975

7076
const toggleProjectsMenuVisibility = (event: MouseEvent) => {
7177
event.preventDefault();
72-
if (isProjectsMenuVisible) {
78+
event.stopPropagation();
79+
if (headerMenuState === HeaderMenuState.PROJECTS_MENU_OPEN) {
7380
hideProjectsMenu();
7481
} else {
7582
showProjectsMenu();
7683
}
7784
};
7885

7986
const showProjectsMenu = () => {
80-
setIsProjectsMenuVisible(true);
87+
setHeaderMenuState(HeaderMenuState.PROJECTS_MENU_OPEN);
8188
document.addEventListener('click', hideProjectsMenu);
8289
};
8390

8491
const hideProjectsMenu = () => {
85-
setIsProjectsMenuVisible(false);
92+
setHeaderMenuState(HeaderMenuState.DEFAULT);
8693
document.removeEventListener('click', hideProjectsMenu);
8794
};
8895

@@ -127,7 +134,7 @@ export const Header: React.FunctionComponent<Props> = ({
127134
<HeaderButtonArrow />
128135
</HeaderMenuItem>
129136
<HeaderMenuItemContent right="270">
130-
{isProjectsMenuVisible && <ProjectsMenu />}
137+
{headerMenuState === HeaderMenuState.PROJECTS_MENU_OPEN && <ProjectsMenu />}
131138
</HeaderMenuItemContent>
132139
<HeaderMenuItem onClick={toggleAccountMenuVisibility} role="menu">
133140
<HeaderButton>
@@ -136,7 +143,7 @@ export const Header: React.FunctionComponent<Props> = ({
136143
<HeaderButtonArrow />
137144
</HeaderMenuItem>
138145
<HeaderMenuItemContent right="100">
139-
{isAccountMenuVisible && <AccountMenu />}
146+
{headerMenuState === HeaderMenuState.ACCOUNT_MENU_OPEN && <AccountMenu />}
140147
</HeaderMenuItemContent>
141148
</HeaderButtonsBlock>
142149
</Nav>

0 commit comments

Comments
 (0)