diff --git a/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm b/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm index b9255b7cb..b070bcb6e 100644 --- a/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm +++ b/src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm @@ -393,13 +393,13 @@ update shared route msg model = case response of Ok ( _, expandedPipeline ) -> let - p = + basePipeline = RemoteData.withDefault Vela.defaultPipelineConfig model.pipeline in ( { model | pipeline = RemoteData.succeed - { p + { basePipeline | rawData = "" , decodedData = expandedPipeline } diff --git a/src/elm/Vela.elm b/src/elm/Vela.elm index c181fe601..83c28e794 100644 --- a/src/elm/Vela.elm +++ b/src/elm/Vela.elm @@ -1132,6 +1132,11 @@ type alias PipelineConfig = } +defaultPipelineConfig : PipelineConfig +defaultPipelineConfig = + PipelineConfig "" "" "" "" "" "" False False False False False False [] "" "" Dict.empty + + type alias Template = { link : String , name : String @@ -1144,27 +1149,6 @@ type alias Templates = Dict String Template -defaultPipelineConfig : PipelineConfig -defaultPipelineConfig = - PipelineConfig - "" - "" - "" - "" - "" - "" - False - False - False - False - False - False - [] - "" - "" - Dict.empty - - lineNumberWarningfromWarningString : String -> ( Maybe Int, String ) lineNumberWarningfromWarningString warning = case String.split ":" warning of @@ -1202,32 +1186,35 @@ decodePipelineConfig = |> optional "warnings" (Json.Decode.list string |> Json.Decode.andThen - (\warnings -> - Json.Decode.succeed - (List.foldl - (\warning dict -> - case lineNumberWarningfromWarningString warning of - ( Just line, w ) -> - Dict.update line - (\maybeWarnings -> - case maybeWarnings of - Just existingWarnings -> - Just (w :: existingWarnings) - - Nothing -> - Just [ w ] - ) - dict - - _ -> - dict - ) - Dict.empty - warnings + decodeAndCollapsePipelineWarnings + ) + Dict.empty + + +decodeAndCollapsePipelineWarnings : List String -> Json.Decode.Decoder (Dict Int (List String)) +decodeAndCollapsePipelineWarnings warnings = + Json.Decode.succeed + (List.foldl + (\warning dict -> + case lineNumberWarningfromWarningString warning of + ( Just line, w ) -> + Dict.update line + (\maybeWarnings -> + case maybeWarnings of + Just existingWarnings -> + Just (w :: existingWarnings) + + Nothing -> + Just [ w ] ) - ) + dict + + _ -> + dict ) Dict.empty + warnings + ) decodePipelineExpand : Json.Decode.Decoder String