@@ -13,6 +13,8 @@ module Pages.Settings exposing
13
13
, timeout
14
14
, timeoutInput
15
15
, timeoutWarning
16
+ , validAccessUpdate
17
+ , validEventsUpdate
16
18
, view
17
19
)
18
20
@@ -21,6 +23,7 @@ import Html
21
23
( Html
22
24
, button
23
25
, div
26
+ , em
24
27
, input
25
28
, label
26
29
, p
@@ -43,7 +46,7 @@ import Html.Events exposing (onCheck, onClick, onInput)
43
46
import RemoteData exposing (RemoteData (..) , WebData )
44
47
import SvgBuilder
45
48
import Util
46
- import Vela exposing (Field , Repository )
49
+ import Vela exposing (Field , Repository , UpdateRepositoryPayload )
47
50
48
51
49
52
@@ -110,7 +113,7 @@ access : Repository -> RadioUpdate msg -> Html msg
110
113
access repo msg =
111
114
div [ class " category" , Util . testAttribute " repo-settings-access" ]
112
115
[ div [ class " header" ] [ span [ class " text" ] [ text " Access" ] ]
113
- , div [ class " description" ] [ text " Change who can access build information" ]
116
+ , div [ class " description" ] [ text " Change who can access build information. " ]
114
117
, div [ class " inputs" , class " radios" ]
115
118
[ radio repo. visibility " private" " Private" <| msg repo. org repo. name " visibility" " private"
116
119
, radio repo. visibility " public" " Any" <| msg repo. org repo. name " visibility" " public"
@@ -124,7 +127,8 @@ events : Repository -> CheckboxUpdate msg -> Html msg
124
127
events repo msg =
125
128
div [ class " category" , Util . testAttribute " repo-settings-events" ]
126
129
[ div [ class " header" ] [ span [ class " text" ] [ text " Webhook Events" ] ]
127
- , div [ class " description" ] [ text " Control which events on Git will trigger Vela pipelines" ]
130
+ , div [ class " description" ] [ text " Control which events on Git will trigger Vela pipelines." ]
131
+ , div [ class " description" ] [ em [] [ text " Active repositories must have at least one event enabled." ] ]
128
132
, div [ class " inputs" ]
129
133
[ checkbox " Push"
130
134
" allow_push"
@@ -156,7 +160,7 @@ timeout : Maybe Int -> Repository -> NumberInputChange msg -> (String -> msg) ->
156
160
timeout inTimeout repo clickMsg inputMsg =
157
161
div [ class " category" , Util . testAttribute " repo-settings-timeout" ]
158
162
[ div [ class " header" ] [ span [ class " text" ] [ text " Build Timeout" ] ]
159
- , div [ class " description" ] [ text " Builds that reach this timeout setting will be stopped" ]
163
+ , div [ class " description" ] [ text " Builds that reach this timeout setting will be stopped. " ]
160
164
, timeoutInput repo
161
165
inTimeout
162
166
inputMsg
@@ -300,6 +304,42 @@ validTimeout inTimeout repoTimeout =
300
304
True
301
305
302
306
307
+ {- | validAccessUpdate : takes model webdata repo and repo visibility update and determines if an update is necessary
308
+ -}
309
+ validAccessUpdate : WebData Repository -> UpdateRepositoryPayload -> Bool
310
+ validAccessUpdate originalRepo repoUpdate =
311
+ case originalRepo of
312
+ RemoteData . Success repo ->
313
+ case repoUpdate. visibility of
314
+ Just visibility ->
315
+ if repo. visibility /= visibility then
316
+ True
317
+
318
+ else
319
+ False
320
+
321
+ Nothing ->
322
+ False
323
+
324
+ _ ->
325
+ False
326
+
327
+
328
+ {- | validEventsUpdate : takes model webdata repo and repo events update and determines if an update is necessary
329
+ -}
330
+ validEventsUpdate : WebData Repository -> UpdateRepositoryPayload -> Bool
331
+ validEventsUpdate originalRepo repoUpdate =
332
+ case originalRepo of
333
+ RemoteData . Success repo ->
334
+ Maybe . withDefault repo. allow_push repoUpdate. allow_push
335
+ || Maybe . withDefault repo. allow_pull repoUpdate. allow_pull
336
+ || Maybe . withDefault repo. allow_deploy repoUpdate. allow_deploy
337
+ || Maybe . withDefault repo. allow_tag repoUpdate. allow_tag
338
+
339
+ _ ->
340
+ False
341
+
342
+
303
343
{- | updateTip : takes field and returns the tip to display after the label.
304
344
-}
305
345
updateTip : Field -> Html msg
0 commit comments