Skip to content

Commit

Permalink
Merge pull request #1091 from ds-wizard/release/4.4.0
Browse files Browse the repository at this point in the history
Release 4.4.0
  • Loading branch information
janslifka committed Mar 5, 2024
2 parents 5aeed37 + d56af80 commit f9d9c7a
Show file tree
Hide file tree
Showing 64 changed files with 2,104 additions and 1,504 deletions.
18 changes: 18 additions & 0 deletions engine-shared/elm/Shared/Api/AppKeys.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Shared.Api.AppKeys exposing (deleteAppKey, getAppKeys)

import Json.Decode as D
import Registry.Common.Requests exposing (ToMsg)
import Shared.AbstractAppState exposing (AbstractAppState)
import Shared.Api exposing (jwtDelete, jwtGet)
import Shared.Data.AppKey as AppKey exposing (AppKey)
import Uuid exposing (Uuid)


getAppKeys : AbstractAppState a -> ToMsg (List AppKey) msg -> Cmd msg
getAppKeys =
jwtGet "/app-keys" (D.list AppKey.decoder)


deleteAppKey : Uuid -> AbstractAppState a -> ToMsg () msg -> Cmd msg
deleteAppKey uuid =
jwtDelete ("/app-keys/" ++ Uuid.toString uuid)
22 changes: 22 additions & 0 deletions engine-shared/elm/Shared/Data/AppKey.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module Shared.Data.AppKey exposing (AppKey, decoder)

import Json.Decode as D exposing (Decoder)
import Json.Decode.Extra as D
import Json.Decode.Pipeline as D
import Time
import Uuid exposing (Uuid)


type alias AppKey =
{ uuid : Uuid
, name : String
, createdAt : Time.Posix
}


decoder : Decoder AppKey
decoder =
D.succeed AppKey
|> D.required "uuid" Uuid.decoder
|> D.required "name" D.string
|> D.required "createdAt" D.datetime
4 changes: 0 additions & 4 deletions engine-shared/elm/Shared/Data/Questionnaire.elm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ type alias Questionnaire =
, permissions : List Permission
, state : QuestionnaireState
, updatedAt : Time.Posix
, answeredQuestions : Int
, unansweredQuestions : Int
}


Expand Down Expand Up @@ -72,8 +70,6 @@ decoder =
|> D.required "permissions" (D.list Permission.decoder)
|> D.required "state" QuestionnaireState.decoder
|> D.required "updatedAt" D.datetime
|> D.required "answeredQuestions" D.int
|> D.required "unansweredQuestions" D.int


matchMember : Questionnaire -> Maybe UserInfo -> Bool
Expand Down
6 changes: 6 additions & 0 deletions engine-shared/elm/Shared/Setters.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Shared.Setters exposing
( setApiKey
, setApiKeys
, setAppKeys
, setAssets
, setBookReference
, setDropdownState
Expand Down Expand Up @@ -37,6 +38,11 @@ setApiKeys value record =
{ record | apiKeys = value }


setAppKeys : a -> { b | appKeys : a } -> { b | appKeys : a }
setAppKeys value record =
{ record | appKeys = value }


setAssets : a -> { b | assets : a } -> { b | assets : a }
setAssets value record =
{ record | assets = value }
Expand Down
24 changes: 0 additions & 24 deletions engine-wizard/elm/Wizard/Common/Api.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Wizard.Common.Api exposing
( applyResult
, applyResultCmd
, applyResultTransform
, applyResultTransformCmd
, getResultCmd
Expand Down Expand Up @@ -71,29 +70,6 @@ applyResultTransform appState { setResult, defaultError, model, result, logoutMs
}


applyResultCmd :
{ a | locale : Gettext.Locale }
->
{ setResult : ActionResult data -> model -> model
, defaultError : String
, model : model
, result : Result ApiError data
, logoutMsg : msg
, cmd : Cmd msg
}
-> ( model, Cmd msg )
applyResultCmd appState { setResult, defaultError, model, result, logoutMsg, cmd } =
applyResultTransformCmd appState
{ setResult = setResult
, defaultError = defaultError
, model = model
, result = result
, logoutMsg = logoutMsg
, transform = identity
, cmd = cmd
}


applyResultTransformCmd :
{ a | locale : Gettext.Locale }
->
Expand Down
13 changes: 13 additions & 0 deletions engine-wizard/elm/Wizard/Common/Feature.elm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module Wizard.Common.Feature exposing
, projectCommentThreadReopen
, projectCommentThreadResolve
, projectContinueMigration
, projectCreateFromTemplate
, projectCreateMigration
, projectDelete
, projectDocumentsView
Expand All @@ -66,6 +67,7 @@ module Wizard.Common.Feature exposing
, userEdit
, userEditActiveSessions
, userEditApiKeys
, userEditAppKeys
, userEditSubmissionSettings
, usersCreate
, usersView
Expand Down Expand Up @@ -250,6 +252,11 @@ projectOpen _ questionnaire =
questionnaire.state /= QuestionnaireState.Migrating


projectCreateFromTemplate : AppState -> Questionnaire -> Bool
projectCreateFromTemplate appState questionnaire =
projectsCreateFromTemplate appState && questionnaire.isTemplate && questionnaire.state /= QuestionnaireState.Migrating


projectClone : AppState -> Questionnaire -> Bool
projectClone _ questionnaire =
questionnaire.state /= QuestionnaireState.Migrating
Expand Down Expand Up @@ -432,6 +439,12 @@ userEditApiKeys appState uuidOrCurrent =
UuidOrCurrent.isCurrent uuidOrCurrent || UuidOrCurrent.matchUuid uuidOrCurrent (Maybe.unwrap Uuid.nil .uuid appState.config.user)


userEditAppKeys : AppState -> UuidOrCurrent -> Bool
userEditAppKeys appState uuidOrCurrent =
Admin.isEnabled appState.config.admin
&& (UuidOrCurrent.isCurrent uuidOrCurrent || UuidOrCurrent.matchUuid uuidOrCurrent (Maybe.unwrap Uuid.nil .uuid appState.config.user))


userEditActiveSessions : AppState -> UuidOrCurrent -> Bool
userEditActiveSessions appState uuidOrCurrent =
UuidOrCurrent.isCurrent uuidOrCurrent || UuidOrCurrent.matchUuid uuidOrCurrent (Maybe.unwrap Uuid.nil .uuid appState.config.user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ iconSet =
, ( "_global.export", "fas fa-download" )
, ( "_global.externalLink", "fas fa-external-link-alt" )
, ( "_global.info", "fas fa-info-circle" )
, ( "_global.knowledgeModel", "fas fa-sitemap" )
, ( "_global.open", "far fa-folder-open" )
, ( "_global.preview", "fas fa-eye" )
, ( "_global.questionnaire", "far fa-list-alt" )
Expand Down Expand Up @@ -150,6 +151,7 @@ iconSet =
, ( "questionnaire.urlReferences", "fas fa-external-link-alt" )
, ( "questionnaireList.clone", "far fa-copy" )
, ( "questionnaireList.createMigration", "fas fa-random" )
, ( "questionnaireList.createProjectFromTemplate", "far fa-list-alt" )
, ( "questionnaireMigration.resolve", "fas fa-check" )
, ( "questionnaireMigration.resolveAll", "fas fa-check-double" )
, ( "questionnaireMigration.undo", "fas fa-undo-alt" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ locale =
, ( "__routing.projectImporters", "project-importers" )
, ( "__routing.projects", "projects" )
, ( "__routing.projects.create", "create" )
, ( "__routing.projects.create.custom", "custom" )
, ( "__routing.projects.create.selected", "selected" )
, ( "__routing.projects.create.template", "from-template" )
, ( "__routing.projects.create.selectedProjectTemplate", "selectedProjectTemplate" )
, ( "__routing.projects.create.selectedKnowledgeModel", "selectedKnowledgeModel" )
, ( "__routing.projects.createMigration", "create-migration" )
, ( "__routing.projects.migration", "migration" )
, ( "__routing.projects.migration", "migration" )
Expand Down
22 changes: 21 additions & 1 deletion engine-wizard/elm/Wizard/Common/View/ActionResultBlock.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module Wizard.Common.View.ActionResultBlock exposing (view)
module Wizard.Common.View.ActionResultBlock exposing
( inlineView
, view
)

import ActionResult exposing (ActionResult(..))
import Html exposing (Html, div, text)
import Html.Attributes exposing (class)
import Shared.Html exposing (emptyNode)
import Wizard.Common.AppState exposing (AppState)
import Wizard.Common.View.Flash as Flash
import Wizard.Common.View.Page as Page


Expand All @@ -22,3 +26,19 @@ view appState viewContent actionResult =

Success result ->
viewContent result


inlineView : AppState -> (a -> Html msg) -> ActionResult a -> Html msg
inlineView appState viewContent actionResult =
case actionResult of
Unset ->
emptyNode

Loading ->
Flash.loader appState

Error err ->
Flash.error appState err

Success result ->
viewContent result
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ view appState =
{ title = gettext "Create Project Template" appState.locale
, text = gettext "Project template is a special type of project that can be used as a starting point for new projects. You can select a knowledge model, set up a document template and format, or prefill some answers to make it easier to start for researchers." appState.locale
, action =
{ route = Routes.projectsCreateCustom Nothing
{ route = Routes.projectsCreate
, label = gettext "Create" appState.locale
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ view appState =
{ title = gettext "Create Project" appState.locale
, text = gettext "Project is a workspace where you create your DMP. It is based on a knowledge model, which contains knowledge about what should be asked and how based on the research field or organization's needs. You can use document templates to transform the answers into a document. This document can be anything, from PDF to machine-actionable JSON.\n\nYou can create a new project from a project template that data stewards prepare for you to have an easier start or from scratch where you set up everything yourself." appState.locale
, action =
{ route = Routes.projectsCreate appState
{ route = Routes.projectsCreate
, label = gettext "Create" appState.locale
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Wizard.Dashboard.Widgets.RecentProjectsWidget exposing (view)
import ActionResult exposing (ActionResult(..))
import Gettext exposing (gettext)
import Html exposing (Html, br, div, h2, p, strong, text)
import Html.Attributes exposing (class, style)
import Html.Attributes exposing (class)
import Shared.Data.Questionnaire exposing (Questionnaire)
import Shared.Html exposing (faSet)
import String.Format as String
Expand Down Expand Up @@ -51,14 +51,6 @@ viewRecentProjects appState questionnaires =
viewProject : AppState -> Questionnaire -> Html msg
viewProject appState questionnaire =
let
projectProgressView =
let
pctg =
(toFloat questionnaire.answeredQuestions / toFloat (questionnaire.answeredQuestions + questionnaire.unansweredQuestions)) * 100
in
div [ class "progress mt-1 flex-grow-1", style "height" "7px" ]
[ div [ class "progress-bar bg-info", style "width" (String.fromFloat pctg ++ "%") ] [] ]

updatedText =
inWordsWithConfig { withAffix = True } (locale appState) questionnaire.updatedAt appState.currentTime
in
Expand All @@ -69,8 +61,7 @@ viewProject appState questionnaire =
, div [ class "ms-2 flex-grow-1 content" ]
[ strong [] [ text questionnaire.name ]
, div [ class "d-flex align-items-center" ]
[ projectProgressView
, div [ class "flex-grow-1 ps-4 text-lighter fst-italic" ] [ text (String.format (gettext "Updated %s" appState.locale) [ updatedText ]) ]
[ div [ class "flex-grow-1 ps-4 text-lighter fst-italic" ] [ text (String.format (gettext "Updated %s" appState.locale) [ updatedText ]) ]
]
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ import Wizard.KMEditor.Editor.Components.KMEditor.Breadcrumbs as Breadcrumbs
import Wizard.KMEditor.Editor.Components.KMEditor.Input as Input
import Wizard.KMEditor.Editor.Components.KMEditor.Tree as Tree
import Wizard.KMEditor.Editor.Components.KMEditor.TreeInput as TreeInput
import Wizard.Ports as Ports
import Wizard.Routes as Routes


Expand Down Expand Up @@ -205,6 +206,10 @@ update setFullscreenMsg msg model editorBranch =
( editorBranch, { model | deleteModalState = deleteModalState }, Cmd.none )

OpenMoveModal movingEntity movingUuid ->
let
scrollCmd =
Ports.scrollIntoViewCenter "[data-km-editor_move-modal_item_current]"
in
( editorBranch
, { model
| moveModalState =
Expand All @@ -214,7 +219,7 @@ update setFullscreenMsg msg model editorBranch =
, treeInputModel = TreeInput.initialModel (Set.fromList editorBranch.openNodeUuids)
}
}
, Cmd.none
, scrollCmd
)

MoveModalMsg moveModalMsg ->
Expand Down

0 comments on commit f9d9c7a

Please sign in to comment.