Skip to content

Commit 80c8170

Browse files
authored
Merge pull request #89 from unisoncomputing/notifications-button-app-header
Add app header notifications button
2 parents 7669b63 + fa1c21b commit 80c8170

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/UnisonShare/AppHeader.elm

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import UI.Sizing as Sizing
1919
import UnisonShare.Account as Account
2020
import UnisonShare.Link as Link
2121
import UnisonShare.Session exposing (Session(..))
22+
import UnisonShare.Util as Util
2223
import Url exposing (Url)
2324
import WhatsNew exposing (WhatsNew)
2425

@@ -275,6 +276,21 @@ view ctx appHeader_ =
275276
|> Button.positive
276277
|> Button.view
277278

279+
notifications =
280+
if account.hasUnreadNotifications then
281+
div [ class "notifications" ]
282+
[ Button.icon_ Link.notifications Icon.bellRing
283+
|> Button.small
284+
|> Button.view
285+
, Nudge.nudge
286+
|> Nudge.view
287+
]
288+
289+
else
290+
Button.icon_ Link.notifications Icon.bell
291+
|> Button.small
292+
|> Button.view
293+
278294
orgs_ =
279295
account.organizationMemberships
280296
|> List.map (\(Account.OrganizationMembership h) -> h)
@@ -302,10 +318,16 @@ view ctx appHeader_ =
302318
in
303319
[ div [ class "signed-in-nav signed-in-nav_desktop" ]
304320
[ newOrgButton
321+
, Util.privateBeta account notifications
305322
, helpAndResources False
306323
, accountMenu
307324
]
308-
, div [ class "signed-in-nav signed-in-nav_mobile" ] [ newOrgButton, helpAndResources True, accountMenu ]
325+
, div [ class "signed-in-nav signed-in-nav_mobile" ]
326+
[ newOrgButton
327+
, Util.privateBeta account notifications
328+
, helpAndResources True
329+
, accountMenu
330+
]
309331
]
310332
in
311333
UI.AppHeader.appHeader (appTitle (Click.href "/"))

src/UnisonShare/Link.elm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Lib.UserHandle as UserHandle exposing (UserHandle)
1111
import UI.Click as Click exposing (Click)
1212
import UnisonShare.BranchDiff.ChangeLineId exposing (ChangeLineId)
1313
import UnisonShare.Contribution.ContributionRef exposing (ContributionRef)
14-
import UnisonShare.Paginated exposing (PageCursorParam)
14+
import UnisonShare.Paginated as Paginated exposing (PageCursorParam)
1515
import UnisonShare.Project.ProjectRef exposing (ProjectRef)
1616
import UnisonShare.Route as Route exposing (Route)
1717
import UnisonShare.Ticket.TicketRef exposing (TicketRef)
@@ -189,6 +189,11 @@ account =
189189
toClick Route.account
190190

191191

192+
notifications : Click msg
193+
notifications =
194+
toClick (Route.notificationsAll Paginated.NoPageCursor)
195+
196+
192197
notificationsAll : PageCursorParam -> Click msg
193198
notificationsAll cursor =
194199
toClick (Route.notificationsAll cursor)

src/UnisonShare/Util.elm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module UnisonShare.Util exposing (..)
2+
3+
import Html exposing (Html)
4+
import UI
5+
import UnisonShare.Account exposing (Account)
6+
7+
8+
privateBeta : Account a -> Html msg -> Html msg
9+
privateBeta account content =
10+
if account.isSuperAdmin then
11+
content
12+
13+
else
14+
UI.nothing

src/css/unison-share/app.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,20 @@ body:has(#modal-overlay) {
158158
margin-top: 1rem;
159159
}
160160

161+
#app-header .notifications {
162+
position: relative;
163+
}
164+
165+
#app-header .notifications .nudge {
166+
position: absolute;
167+
right: -0.25rem;
168+
top: -0.25rem;
169+
170+
& .nudge_circle {
171+
box-shadow: 0 0 0 4px var(--color-app-header-bg);
172+
}
173+
}
174+
161175
/* -- App Footer ----------------------------------------------------------- */
162176

163177
#app-footer {

0 commit comments

Comments
 (0)