Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #26207: Plugin management operations need confirmation popup and license error info #6134

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ package com.normation.plugins

import better.files.File
import com.normation.errors.*
import com.normation.plugins.PluginSystemStatus.Disabled
import com.normation.plugins.PluginSystemStatus.Enabled
import com.normation.plugins.RudderPackageService.*
import com.normation.rudder.domain.logger.ApplicationLoggerPure
import com.normation.rudder.hooks.Cmd
Expand Down Expand Up @@ -660,7 +662,11 @@ class RudderPackageCmdService(configCmdLine: String) extends RudderPackageServic
}

override def changePluginSystemStatus(status: PluginSystemStatus, plugins: Chunk[String]): IOResult[Unit] = {
runCmdOrFail(status.value :: plugins.toList)(
val action = status match {
case Enabled => "enable"
case Disabled => "disable"
}
runCmdOrFail(action :: plugins.toList)(
s"An error occurred while changin plugin status to ${status.value}"
).unit
}
Expand Down
1 change: 1 addition & 0 deletions webapp/sources/rudder/rudder-web/src/main/elm/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"justinmimbs/date": "4.1.0",
"justinmimbs/time-extra": "1.2.0",
"jzxhuang/http-extras": "2.1.0",
"matthewsj/elm-ordering": "2.0.0",
"mcordova47/elm-natural-ordering": "1.1.0",
"mercurymedia/elm-datetime-picker": "8.0.1",
"pablen/toasty": "1.2.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ update msg model =
Err err ->
processApiErrorBytes "Error while fetching information" err model

SetModalState modalState ->
( { model | ui = (\ui -> { ui | modalState = modalState }) model.ui }, Cmd.none )

Copy s ->
( model, copy s )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,19 @@ changePluginStatus requestType plugins model =
, timeout = Nothing
, tracker = Nothing
}


requestTypeAction : RequestType -> Model -> Cmd Msg
requestTypeAction t model =
case t of
Install ->
installPlugins model.ui.selected model

Uninstall ->
removePlugins model.ui.selected model

Enable ->
changePluginStatus Enable model.ui.selected model

Disable ->
changePluginStatus Disable model.ui.selected model
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Http
import Http.Detailed
import Json.Encode exposing (Value)
import List.Extra
import Ordering exposing (Ordering)
import Time.ZonedDateTime exposing (ZonedDateTime)


Expand Down Expand Up @@ -68,10 +69,16 @@ type alias PluginError =

type alias UI =
{ selected : List PluginId
, modalState : ModalState
, settingsError : Maybe ( String, String ) -- message, details
}


type ModalState
= OpenModal RequestType
| NoModal


type alias Model =
{ contextPath : String
, license : LicenseGlobalInfo
Expand All @@ -98,6 +105,7 @@ type Msg
= CallApi (Model -> Cmd Msg)
| ApiGetPlugins (Result (Http.Detailed.Error String) ( Http.Metadata, PluginsInfo ))
| ApiPostPlugins (Result (Http.Detailed.Error Bytes) RequestType)
| SetModalState ModalState
| Copy String
| CopyJson Value
| CheckSelection Select
Expand Down Expand Up @@ -171,3 +179,14 @@ noGlobalLicense =
, endDate = Nothing
, maxNodes = Nothing
}


pluginStatusOrdering : Ordering PluginStatus
pluginStatusOrdering =
Ordering.explicit [ Enabled, Disabled, Uninstalled ]


pluginDefaultOrdering : Ordering PluginInfo
pluginDefaultOrdering =
Ordering.byFieldWith pluginStatusOrdering .status
|> Ordering.breakTiesWith (Ordering.byField .name)
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ init : { contextPath : String } -> ( Model, Cmd Msg )
init flags =
let
initUI =
UI [] Nothing
UI [] NoModal Nothing

initModel =
Model flags.contextPath noGlobalLicense [] initUI
Expand Down
Loading