Skip to content

Commit e53208c

Browse files
committed
Parse new isSuperAdmin on session
1 parent 2f14fb4 commit e53208c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/UnisonShare/Account.elm

+5-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type alias Account a =
1919
, pronouns : Maybe String
2020
, completedTours : List Tour
2121
, organizationMemberships : List OrganizationMembership
22+
, isSuperAdmin : Bool
2223
}
2324

2425

@@ -88,18 +89,20 @@ isProjectOwner projectRef account =
8889
decodeSummary : Decode.Decoder AccountSummary
8990
decodeSummary =
9091
let
91-
makeSummary handle name_ avatarUrl completedTours organizationMemberships =
92+
makeSummary handle name_ avatarUrl completedTours organizationMemberships isSuperAdmin =
9293
{ handle = handle
9394
, name = name_
9495
, avatarUrl = avatarUrl
9596
, pronouns = Nothing
9697
, completedTours = Maybe.withDefault [] completedTours
9798
, organizationMemberships = organizationMemberships
99+
, isSuperAdmin = isSuperAdmin
98100
}
99101
in
100-
Decode.map5 makeSummary
102+
Decode.map6 makeSummary
101103
(field "handle" UserHandle.decodeUnprefixed)
102104
(maybe (field "name" string))
103105
(maybe (field "avatarUrl" decodeUrl))
104106
(maybe (field "completedTours" (Decode.list Tour.decode)))
105107
(field "organizationMemberships" (Decode.list (Decode.map OrganizationMembership UserHandle.decodeUnprefixed)))
108+
(field "isSuperAdmin" Decode.bool)

src/UnisonShare/Page/ErrorPage.elm

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ view : Session -> Http.Error -> String -> String -> PageLayout msg
1717
view session error entityName className =
1818
let
1919
errorDetails =
20-
if Session.isUnisonMember session then
20+
if Session.isSuperAdmin session then
2121
details [] [ summary [] [ text "Error Details" ], div [] [ text (Util.httpErrorToString error) ] ]
2222

2323
else

src/UnisonShare/Session.elm

+11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module UnisonShare.Session exposing
77
, isOrganizationMember
88
, isProjectOwner
99
, isSignedIn
10+
, isSuperAdmin
1011
, isUnisonMember
1112
)
1213

@@ -41,6 +42,16 @@ isSignedIn session =
4142
True
4243

4344

45+
isSuperAdmin : Session -> Bool
46+
isSuperAdmin session =
47+
case session of
48+
Anonymous ->
49+
False
50+
51+
SignedIn account_ ->
52+
account_.isSuperAdmin
53+
54+
4455
isProjectOwner : ProjectRef -> Session -> Bool
4556
isProjectOwner projectRef session =
4657
isHandle (ProjectRef.handle projectRef) session

0 commit comments

Comments
 (0)