From 9b83b30b6a5531bdb92c927afbf0688f38e09a83 Mon Sep 17 00:00:00 2001 From: Peter Damoc Date: Thu, 5 Dec 2019 12:21:52 +0200 Subject: [PATCH] Enable "Save" button for compatible versions. Fixes #122 --- assets/src/Elm/Version.elm | 7 ++++++- assets/src/Pages/Editor/Views/Workbench.elm | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/assets/src/Elm/Version.elm b/assets/src/Elm/Version.elm index 16f41f50..0c77e2d7 100644 --- a/assets/src/Elm/Version.elm +++ b/assets/src/Elm/Version.elm @@ -1,4 +1,4 @@ -module Elm.Version exposing (Version, compare, decoder, encoder, eq, fromString, toString) +module Elm.Version exposing (Version, compare, compatible, decoder, encoder, eq, fromString, toString) import Json.Decode as Decode exposing (Decoder) import Json.Encode as Encode exposing (Value) @@ -25,6 +25,11 @@ fromString str = Err "Expecting a version like MAJOR.MINOR.PATCH" +compatible : Version -> Version -> Bool +compatible left right = + ( left.major, left.minor ) == ( left.major, left.minor ) + + eq : Version -> Version -> Bool eq left right = case compare left right of diff --git a/assets/src/Pages/Editor/Views/Workbench.elm b/assets/src/Pages/Editor/Views/Workbench.elm index 27193fbf..818ac567 100644 --- a/assets/src/Pages/Editor/Views/Workbench.elm +++ b/assets/src/Pages/Editor/Views/Workbench.elm @@ -174,7 +174,7 @@ viewErrorsHeader pane config = _ -> Button.none } - , if Version.eq config.compilerVersion Compiler.version then + , if Version.compatible config.compilerVersion Compiler.version then Just { label = if config.saving then @@ -236,7 +236,7 @@ viewFinishedHeader pane canDebug config = _ -> Button.none } - , if Version.eq config.compilerVersion Compiler.version then + , if Version.compatible config.compilerVersion Compiler.version then Just { icon = Just Icon.Upload , label = "Save"