Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rodolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
Rodolf
Commits
8338eb6ceaef
Commit
8338eb6ceaef
authored
1 year ago
by
Olivier Giorgis
Browse files
Options
Downloads
Patches
Plain Diff
feat: display an “account” button at the top right instead of the “logout” button
parent
0e57e360a70c
No related branches found
No related tags found
1 merge request
!25
feat: display an “account” button at the top right instead of the “logout” button
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/Header.tsx
+42
-4
42 additions, 4 deletions
frontend/src/components/Header.tsx
with
42 additions
and
4 deletions
frontend/src/components/Header.tsx
+
42
−
4
View file @
8338eb6c
import
{
AppBar
,
Box
,
Button
,
Stack
,
Toolbar
,
Typography
}
from
"
@mui/material
"
;
import
{
useState
}
from
"
react
"
;
import
{
AppBar
,
Box
,
IconButton
,
Menu
,
MenuItem
,
Stack
,
Toolbar
,
Typography
,
}
from
"
@mui/material
"
;
import
AccountCircle
from
"
@mui/icons-material/AccountCircle
"
;
import
Link
from
"
next/link
"
;
import
Image
from
"
next/image
"
;
import
{
usePathname
}
from
"
next/navigation
"
;
...
...
@@ -8,6 +19,15 @@
const
pathname
=
usePathname
();
const
loggedIn
=
pathname
!==
"
/login
"
;
const
logout
=
useApiLogout
();
const
[
anchorEl
,
setAnchorEl
]
=
useState
<
null
|
HTMLElement
>
(
null
);
const
handleMenu
=
(
event
:
React
.
MouseEvent
<
HTMLElement
>
)
=>
{
setAnchorEl
(
event
.
currentTarget
);
};
const
handleClose
=
()
=>
{
setAnchorEl
(
null
);
};
return
(
<
AppBar
position
=
"static"
>
...
...
@@ -44,9 +64,27 @@
</
Link
>
<
Box
flex
=
{
1
}
/>
{
loggedIn
?
(
<
Button
onClick
=
{
logout
}
variant
=
{
"
contained
"
}
color
=
{
"
error
"
}
>
{
"
Déconnexion
"
}
</
Button
>
<>
<
IconButton
size
=
"large"
aria-label
=
"account of current user"
aria-controls
=
"menu-appbar"
aria-haspopup
=
"true"
onClick
=
{
handleMenu
}
color
=
"inherit"
>
<
AccountCircle
/>
</
IconButton
>
<
Menu
id
=
"current-user-menu"
anchorEl
=
{
anchorEl
}
keepMounted
open
=
{
Boolean
(
anchorEl
)
}
onClose
=
{
handleClose
}
>
<
MenuItem
onClick
=
{
logout
}
>
Déconnexion
</
MenuItem
>
</
Menu
>
</>
)
:
null
}
</
Toolbar
>
</
AppBar
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment