Skip to content

Commit ea6a1af

Browse files
committed
fix/ui: better error message for non member tension creation and invitation button.
1 parent 41c2b66 commit ea6a1af

File tree

7 files changed

+85
-64
lines changed

7 files changed

+85
-64
lines changed

Diff for: i18n/i18n.toml

+14-17
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,6 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr
690690
en="Join"
691691
fr="Rejoignez"
692692

693-
[thisOrgaToParticipate]
694-
en="this organization to participate to this conversation."
695-
fr="cette organisation afin de participer à cette conversation."
696-
697693
[archive]
698694
en="Archive"
699695
fr="Archiver"
@@ -1600,25 +1596,26 @@ Vous pouvez [Explorer](/explore) les organisations publiques ou créer votre [Pr
16001596
en="not implemented"
16011597
fr="non implémenté"
16021598

1603-
[notOrgMember]
1604-
en="You are not a member of this organization."
1605-
fr="Vous n’êtes pas membre de cette organisation."
16061599

16071600
[askCoordo]
16081601
en="Please, ask a coordinator of this circle to perform this action."
16091602
fr="Veuillez demander à un coordinateur de ce cercle d’effectuer cette action."
16101603

1611-
[joinForTension]
1612-
en="Please, Join this organization to be able to create a tension (or retry)."
1613-
fr="Veuillez rejoindre cette organisation pour pouvoir créer une tension (ou réessayer)."
1604+
[onlyMemberCanCreate]
1605+
en="Only member of this organisation can create"
1606+
fr="Seuls les membres de cette organisation peuvent créer des"
16141607

1615-
[joinForComment]
1616-
en="Please, Join this organization to participate to this conversation."
1617-
fr="Veuillez rejoindre cette organisation pour participer à cette conversation (ou réessayer)."
1608+
[onlyMemberCanParticipate]
1609+
en="Only member of this organisation can participate to this conversation."
1610+
fr="Seuls les membres de cette organisation peuvent participer à cette conversation."
16181611

1619-
[joinForCircle]
1620-
en="Please, Join this organization to be able to create a circle (or retry)."
1621-
fr="Veuillez rejoindre cette organisation pour pouvoir créer une cercle (ou réessayer)."
1612+
[joinForTension]
1613+
en="this organization to be able to create"
1614+
fr="cette organization pour pouvoir créer des"
1615+
1616+
[thisOrgaToParticipate]
1617+
en="this organization to participate to this conversation."
1618+
fr="cette organisation pour participer à cette conversation."
16221619

16231620
[nodeNotExist]
16241621
en="Sorry, this circle doesn’t exist."
@@ -2380,7 +2377,7 @@ Checkbox list:
23802377
23812378
Code block:
23822379
\\```
2383-
texte
2380+
text
23842381
\\```
23852382
23862383
Horizontal line:

Diff for: src/Components/ContractsPage.elm

-2
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import ModelCommon.Event exposing (cev2c, cev2p, contractEventToText, contractTy
5353
import ModelCommon.View
5454
exposing
5555
( byAt
56-
, viewJoinNeeded
5756
, viewRole
5857
, viewTensionArrow
5958
, viewTensionDateAndUserC
@@ -912,7 +911,6 @@ viewContractPage c op model =
912911
text ""
913912

914913
LoggedOut ->
915-
--viewJoinNeeded DoJoinOrga model.node_focus
916914
text ""
917915
in
918916
div [ class "comments" ]

Diff for: src/Form/NewTension.elm

+15-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Components.NodeDoc as NodeDoc
3737
)
3838
import Components.UserInput as UserInput
3939
import Dict
40-
import Extra exposing (space_, ternary, textH, textT, upH)
40+
import Extra exposing (space_, ternary, textH, textT, unwrap, unwrap2, upH)
4141
import Extra.Events exposing (onClickPD, onClickPD2, onEnter, onKeydown, onTab)
4242
import Extra.Views exposing (showMsg)
4343
import Form exposing (isPostEmpty, isPostSendable, isUsersSendable)
@@ -78,7 +78,7 @@ import ModelCommon
7878
, tensionToActionForm
7979
)
8080
import ModelCommon.Codecs exposing (DocType(..), FractalBaseRoute(..), getOrgaRoles, hasLazyAdminRole, nearestCircleid, nid2rootid, nid2type, nodeIdCodec, ur2eor, uriFromNameid)
81-
import ModelCommon.Error exposing (viewAuthNeeded, viewGqlErrors, viewRoleNeeded)
81+
import ModelCommon.Error exposing (viewAuthNeeded, viewGqlErrors, viewJoinForTensionNeeded)
8282
import ModelCommon.View exposing (FormText, action2icon, getNodeTextFromNodeType, getTensionText, roleColor, tensionIcon2, tensionType2descr, tensionType2notif, tensionTypeColor, tensionTypeIcon, viewRoleExt)
8383
import ModelSchema exposing (..)
8484
import Ports
@@ -141,7 +141,7 @@ type TensionTab
141141
type TensionStep
142142
= TensionSource
143143
| TensionFinal
144-
| TensionNotAuthorized ErrorData
144+
| TensionNotAuthorized
145145
| AuthNeeded
146146

147147

@@ -729,7 +729,7 @@ update_ apis message model =
729729
( { data | refresh_trial = 1 }, Out [ sendSleep (OnOpen (FromPath p)) 500 ] [ DoUpdateToken ] Nothing )
730730

731731
else if data.sources == [] then
732-
( { data | isActive2 = True } |> setStep (TensionNotAuthorized [ T.notOrgMember, T.joinForTension ])
732+
( { data | isActive2 = True } |> setStep TensionNotAuthorized
733733
, out0 [ sendSleep (SetIsActive2 True) 10 ]
734734
)
735735

@@ -1198,8 +1198,17 @@ viewStep op (State model) =
11981198
NewCircleTab ->
11991199
viewCircle op model
12001200

1201-
TensionNotAuthorized errMsg ->
1202-
viewRoleNeeded errMsg OnClose
1201+
TensionNotAuthorized ->
1202+
let
1203+
userCanJoin =
1204+
withMaybeData model.path_data
1205+
|> Maybe.map
1206+
(\p ->
1207+
unwrap2 False .userCanJoin p.root
1208+
)
1209+
|> withDefault False
1210+
in
1211+
viewJoinForTensionNeeded userCanJoin OnClose
12031212

12041213
AuthNeeded ->
12051214
viewAuthNeeded OnClose

Diff for: src/ModelCommon/Error.elm

+38-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import Extra exposing (ternary, textH, upH)
2626
import Extra.Events exposing (onClickPD)
2727
import Generated.Route as Route exposing (Route, toHref)
2828
import Html exposing (Html, a, button, div, img, p, span, text)
29-
import Html.Attributes exposing (alt, attribute, class, height, href, src, width)
29+
import Html.Attributes exposing (alt, attribute, class, height, href, src, target, width)
3030
import Json.Decode as JD
3131
import Loading
3232
exposing
@@ -42,6 +42,7 @@ import Loading
4242
)
4343
import Markdown exposing (renderMarkdown)
4444
import Maybe exposing (withDefault)
45+
import ModelCommon.Codecs exposing (NodeFocus)
4546
import RemoteData exposing (RemoteData)
4647
import Text as T
4748

@@ -128,19 +129,47 @@ viewAuthNeeded onClose =
128129
]
129130

130131

131-
viewRoleNeeded : ErrorData -> (ModalData -> msg) -> Html msg
132-
viewRoleNeeded errMsg onClose =
132+
viewJoinForTensionNeeded : Bool -> (ModalData -> msg) -> Html msg
133+
viewJoinForTensionNeeded userCanJoin onClose =
133134
div [ class "modal-card" ]
134135
[ div [ class "modal-card-head has-background-warning" ]
135136
[ div [ class "modal-card-title is-size-6 has-text-grey-dark has-text-weight-semibold" ]
136137
[ text T.authorizationNeeded
137138
, button [ class "delete is-pulled-right", onClickPD (onClose { reset = True, link = "" }) ] []
138139
]
139140
]
140-
, div [ class "modal-card-body" ] <|
141-
List.map
142-
(\e ->
143-
p [] [ text e ]
144-
)
145-
errMsg
141+
, div [ class "modal-card-body" ]
142+
[ if userCanJoin then
143+
p []
144+
[ button [ class "button is-small mx-2 joinTrigger" ] [ text T.join2 ]
145+
, text T.joinForTension
146+
, text " "
147+
, a [ href "https://doc.fractale.co/tension", target "_blank" ] [ text T.tensions ]
148+
, text "."
149+
]
150+
151+
else
152+
p []
153+
[ text T.onlyMemberCanCreate
154+
, text " "
155+
, a [ href "https://doc.fractale.co/tension", target "_blank" ] [ text T.tensions ]
156+
, text "."
157+
]
158+
]
159+
]
160+
161+
162+
viewJoinForCommentNeeded : Bool -> Html msg
163+
viewJoinForCommentNeeded userCanJoin =
164+
div [ class "box has-background-primary has-text-light" ]
165+
[ if userCanJoin then
166+
p []
167+
[ button [ class "button is-small mx-2 joinTrigger" ] [ text T.join2 ]
168+
, text T.thisOrgaToParticipate
169+
]
170+
171+
else
172+
p []
173+
[ text T.onlyMemberCanParticipate
174+
]
146175
]

Diff for: src/ModelCommon/View.elm

-10
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,6 @@ mediaTension_ conf focus tension showStatus showRecip size =
190190
]
191191

192192

193-
viewJoinNeeded : NodeFocus -> Html msg
194-
viewJoinNeeded focus =
195-
div [ class "box has-background-primary has-text-light" ]
196-
[ p []
197-
[ button [ class "button is-small mx-2 joinTrigger" ] [ text T.join2 ]
198-
, text T.thisOrgaToParticipate
199-
]
200-
]
201-
202-
203193
viewCircleTarget : String -> EmitterOrReceiver -> Html msg
204194
viewCircleTarget cls er =
205195
case nid2type er.nameid of

Diff for: src/ModelSchema.elm

+7-7
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,6 @@ type alias LocalGraph =
135135
}
136136

137137

138-
type alias RNode =
139-
{ name : String
140-
, nameid : String
141-
, userCanJoin : Maybe Bool
142-
}
143-
144-
145138
type alias FocusNode =
146139
{ name : String
147140
, nameid : String
@@ -153,6 +146,13 @@ type alias FocusNode =
153146
}
154147

155148

149+
type alias RNode =
150+
{ name : String
151+
, nameid : String
152+
, userCanJoin : Maybe Bool
153+
}
154+
155+
156156
{-| From root to focus node (both included)
157157
-}
158158
type alias PNode =

Diff for: src/Org/Tension.elm

+11-13
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import ModelCommon.Codecs
100100
, uriFromNameid
101101
, uriFromUsername
102102
)
103-
import ModelCommon.Error exposing (viewGqlErrors, viewMaybeErrors)
103+
import ModelCommon.Error exposing (viewGqlErrors, viewJoinForCommentNeeded, viewMaybeErrors)
104104
import ModelCommon.View
105105
exposing
106106
( action2icon
@@ -113,7 +113,6 @@ import ModelCommon.View
113113
, tensionStatus2str
114114
, tensionTypeColor
115115
, viewCircleTarget
116-
, viewJoinNeeded
117116
, viewLabel
118117
, viewLabels
119118
, viewNodeDescr
@@ -1922,6 +1921,14 @@ viewTension u t model =
19221921
viewConversation : UserState -> TensionHead -> Model -> Html Msg
19231922
viewConversation u t model =
19241923
let
1924+
userCanJoin =
1925+
withMaybeData model.path_data
1926+
|> Maybe.map
1927+
(\path ->
1928+
path.root |> Maybe.map (\r -> r.userCanJoin == Just True) |> withDefault False
1929+
)
1930+
|> withDefault False
1931+
19251932
userInput =
19261933
case u of
19271934
LoggedIn uctx ->
@@ -1948,20 +1955,11 @@ viewConversation u t model =
19481955
viewCommentInput opNew uctx t model.tension_form model.tension_patch
19491956

19501957
else
1951-
viewJoinNeeded model.node_focus
1958+
viewJoinForCommentNeeded userCanJoin
19521959

19531960
LoggedOut ->
1954-
let
1955-
userCanJoin =
1956-
withMaybeData model.path_data
1957-
|> Maybe.map
1958-
(\path ->
1959-
path.root |> Maybe.map (\r -> r.userCanJoin == Just True) |> withDefault False
1960-
)
1961-
|> withDefault False
1962-
in
19631961
if userCanJoin then
1964-
viewJoinNeeded model.node_focus
1962+
viewJoinForCommentNeeded userCanJoin
19651963

19661964
else
19671965
text ""

0 commit comments

Comments
 (0)