Skip to content

Commit

Permalink
fix: address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Jan 7, 2025
1 parent c8071a5 commit 156755b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
5 changes: 3 additions & 2 deletions src/elm/Pages/Org_/Repo_/Build_/Pipeline.elm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import Utils.Ansi
import Utils.Errors as Errors
import Utils.Focus as Focus
import Utils.Helpers as Util
import Utils.Warnings as Warnings
import Vela
import View exposing (View)

Expand Down Expand Up @@ -783,8 +784,8 @@ viewLine expand shiftKeyDown lineNumber line warnings focus =
viewWarningAsLogLine : Model -> Shared.Model -> String -> Html Msg
viewWarningAsLogLine model shared warning =
let
( maybeLineNumber, content ) =
Vela.lineNumberWarningfromWarningString warning
{ maybeLineNumber, content } =
Warnings.fromString warning
in
tr [ class "warning" ]
[ td [ class "annotation", class "-show" ]
Expand Down
32 changes: 32 additions & 0 deletions src/elm/Utils/Warnings.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{--
SPDX-License-Identifier: Apache-2.0
--}


module Utils.Warnings exposing (Warning, fromString)

{-| Warning : an object that represents a point of focus.
-}


type alias Warning =
{ maybeLineNumber : Maybe Int
, content : String
}


{-| fromString : parses a warning string into a line number and a message.
-}
fromString : String -> Warning
fromString warning =
case String.split ":" warning of
prefix :: content ->
case String.toInt prefix of
Just lineNumber ->
{ maybeLineNumber = Just lineNumber, content = String.concat content }

Nothing ->
{ maybeLineNumber = Nothing, content = warning }

_ ->
{ maybeLineNumber = Nothing, content = warning }
23 changes: 6 additions & 17 deletions src/elm/Vela.elm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ module Vela exposing
, encodeSettingsPayload
, encodeUpdateUser
, getAllowEventField
, lineNumberWarningfromWarningString
, platformSettingsFieldUpdateToResponseConfig
, repoFieldUpdateToResponseConfig
, secretToKey
Expand All @@ -120,6 +119,7 @@ import Json.Decode.Extra exposing (dict2)
import Json.Decode.Pipeline exposing (hardcoded, optional, required)
import Json.Encode
import RemoteData exposing (WebData)
import Utils.Warnings as Warnings



Expand Down Expand Up @@ -1149,21 +1149,6 @@ type alias Templates =
Dict String Template


lineNumberWarningfromWarningString : String -> ( Maybe Int, String )
lineNumberWarningfromWarningString warning =
case String.split ":" warning of
prefix :: content ->
case String.toInt prefix of
Just lineNumber ->
( Just lineNumber, String.join "" content )

Nothing ->
( Nothing, warning )

_ ->
( Nothing, warning )


decodePipelineConfig : Json.Decode.Decoder PipelineConfig
decodePipelineConfig =
Json.Decode.succeed
Expand Down Expand Up @@ -1196,7 +1181,11 @@ decodeAndCollapsePipelineWarnings warnings =
Json.Decode.succeed
(List.foldl
(\warning dict ->
case lineNumberWarningfromWarningString warning of
let
{ maybeLineNumber, content } =
Warnings.fromString warning
in
case ( maybeLineNumber, content ) of
( Just line, w ) ->
Dict.update line
(\maybeWarnings ->
Expand Down

0 comments on commit 156755b

Please sign in to comment.