Skip to content

Commit

Permalink
Merge branch 'master' into feature/agent-connect
Browse files Browse the repository at this point in the history
  • Loading branch information
niladic committed Sep 11, 2024
2 parents 46279aa + 9946a9e commit 1e73a93
Show file tree
Hide file tree
Showing 50 changed files with 645 additions and 521 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
if: ${{ env.CODACY_PROJECT_TOKEN }}
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: target/scala-2.13/coverage-report/cobertura.xml
coverage-reports: 'target/scala-*/coverage-report/cobertura.xml'

ts-build:
name: TypeScript Build
Expand Down
17 changes: 9 additions & 8 deletions .scala-steward.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ pullRequests.frequency = "1 day"
updatePullRequests = "always"
updates.limit = 20
updates.pin = [
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-core", version="2.13." },
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-annotations", version="2.13." },
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-databind", version="2.13." },
{ groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jdk8", version="2.13." },
{ groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jsr310", version="2.13." },
{ groupId = "com.fasterxml.jackson.dataformat", artifactId = "jackson-dataformat-cbor", version="2.13." },
{ groupId = "com.fasterxml.jackson.module", artifactId = "jackson-module-parameter-names", version="2.13." },
{ groupId = "com.fasterxml.jackson.module", artifactId = "jackson-module-scala", version="2.13." }
{ groupId = "org.specs2", artifactId = "specs2-scalacheck", version="4." },
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-core", version="2.14." },
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-annotations", version="2.14." },
{ groupId = "com.fasterxml.jackson.core", artifactId = "jackson-databind", version="2.14." },
{ groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jdk8", version="2.14." },
{ groupId = "com.fasterxml.jackson.datatype", artifactId = "jackson-datatype-jsr310", version="2.14." },
{ groupId = "com.fasterxml.jackson.dataformat", artifactId = "jackson-dataformat-cbor", version="2.14." },
{ groupId = "com.fasterxml.jackson.module", artifactId = "jackson-module-parameter-names", version="2.14." },
{ groupId = "com.fasterxml.jackson.module", artifactId = "jackson-module-scala", version="2.14." }
]
2 changes: 2 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ OrganizeImports {
"*"
]
importsOrder = SymbolsFirst
# TODO: "OrganizeImports.removeUnused"is not supported on 3.3.3 as the compiler is not providing enough information. Please upgrade the Scala compiler to 3.4.0 or greater. Otherwise, run the rule with "OrganizeImports.removeUnused" set to false to organize imports while keeping potentially unused imports.
removeUnused = false
}
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version = "3.8.3"
runner.dialect = scala213source3
runner.dialect = scala3
maxColumn = 100
spaces.afterKeywordBeforeParen = true
newlines.topLevelStatements = [before, after]
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/ApiController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.UUID
import javax.inject.{Inject, Singleton}
import models.{Area, Authorization, Error, EventType, Organisation, User, UserGroup}
import play.api.libs.json.{JsValue, Json}
import play.api.mvc._
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents, Result}
import scala.concurrent.{ExecutionContext, Future}
import serializers.ApiModel._
import serializers.Keys
Expand All @@ -24,13 +24,14 @@ import services.{
@Singleton
case class ApiController @Inject() (
anonymizedDataService: AnonymizedDataService,
val controllerComponents: ControllerComponents,
loginAction: LoginAction,
eventService: EventService,
organisationService: OrganisationService,
userService: UserService,
userGroupService: UserGroupService
)(implicit val ec: ExecutionContext)
extends InjectedController
extends BaseController
with UserOperators {
import OrganisationService.FranceServiceInstance

Expand Down
32 changes: 25 additions & 7 deletions app/controllers/ApplicationController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ import play.api.data._
import play.api.i18n.I18nSupport
import play.api.libs.json.Json
import play.api.libs.ws.WSClient
import play.api.mvc.{Action, AnyContent, Call, InjectedController, RequestHeader, Result, Session}
import play.api.mvc.{
Action,
AnyContent,
BaseController,
Call,
ControllerComponents,
RequestHeader,
Result,
Session
}
import play.twirl.api.Html
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}
Expand All @@ -69,6 +78,7 @@ import services.{
}
import views.applications.myApplications.MyApplicationInfos
import views.dashboard.DashboardInfos
import views.helpers.forms.flashSuccessRawHtmlKey

/** This controller creates an `Action` to handle HTTP requests to the application's home page.
*/
Expand All @@ -77,6 +87,7 @@ case class ApplicationController @Inject() (
applicationService: ApplicationService,
businessDaysService: BusinessDaysService,
config: AppConfig,
val controllerComponents: ControllerComponents,
dependencies: ServicesDependencies,
eventService: EventService,
fileService: FileService,
Expand All @@ -88,7 +99,7 @@ case class ApplicationController @Inject() (
userService: UserService,
ws: WSClient,
)(implicit ec: ExecutionContext, webJarsUtil: WebJarsUtil)
extends InjectedController
extends BaseController
with I18nSupport
with Operators.Common
with Operators.ApplicationOperators
Expand Down Expand Up @@ -415,7 +426,11 @@ case class ApplicationController @Inject() (
removeSharedAccountUserSignature(request.session)
)(signature => saveSharedAccountUserSignature(request.session, signature))
)
.flashing(success -> "Votre demande a bien été envoyée")
.flashing(
flashSuccessRawHtmlKey -> views.application
.applicationSentSuccessMessage(applicationId)
.toString
)
} else {
eventService.log(
EventType.ApplicationCreationError,
Expand Down Expand Up @@ -616,7 +631,8 @@ case class ApplicationController @Inject() (
views.applications.myApplicationsLegacy
.page(user, userRights, filteredByStatus.map(_.application), userGroups, infos)
)
).withHeaders(CACHE_CONTROL -> "no-store")
)
.withHeaders(CACHE_CONTROL -> "no-store")
}

private def applicationBoardInfos(
Expand Down Expand Up @@ -1125,7 +1141,8 @@ case class ApplicationController @Inject() (
}
}
coworkers.combine(instructorsCoworkers)
}).map(
})
.map(
_.filterNot(user =>
user.id === request.currentUser.id || application.invitedUsers.contains(user.id)
)
Expand Down Expand Up @@ -1796,8 +1813,9 @@ case class ApplicationController @Inject() (
applicationId = application.id.some
)
val successMessage =
s"""|La demande "${application.subject}" a bien été archivée.
|Bravo et merci pour la résolution de cette demande !""".stripMargin
s"""La demande « ${application.subject} » a bien été archivée. """ +
"Bravo et merci pour la résolution de cette demande ! " +
"Cette demande sera encore consultable un mois à partir de maintenant dans la colonne « Archivées »"
Future(
Redirect(routes.ApplicationController.myApplications)
.flashing(success -> successMessage)
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/AreaController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@ import models._
import models.EventType.{AllAreaUnauthorized, DeploymentDashboardUnauthorized}
import modules.AppConfig
import org.webjars.play.WebJarsUtil
import play.api.mvc.{Action, AnyContent, InjectedController}
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
import scala.concurrent.{ExecutionContext, Future}
import services.{EventService, UserGroupService, UserService}

@Singleton
case class AreaController @Inject() (
config: AppConfig,
val controllerComponents: ControllerComponents,
loginAction: LoginAction,
eventService: EventService,
userService: UserService,
userGroupService: UserGroupService,
)(implicit ec: ExecutionContext, val webJarsUtil: WebJarsUtil)
extends InjectedController
extends BaseController
with Operators.Common
with UserOperators {

Expand Down
19 changes: 11 additions & 8 deletions app/controllers/CSVImportController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import actions.LoginAction
import cats.syntax.all._
import controllers.Operators.{GroupOperators, UserOperators}
import helper.MiscHelpers.toTupleOpt
import helper.PlayFormHelpers.{inOption, normalizedOptionalText, normalizedText}
import helper.StringHelper._
import helper.Time
Expand Down Expand Up @@ -33,22 +34,24 @@ import org.webjars.play.WebJarsUtil
import play.api.data.{Form, Mapping}
import play.api.data.Forms._
import play.api.data.validation.Constraints.{maxLength, nonEmpty}
import play.api.mvc.{Action, AnyContent, InjectedController}
import play.api.i18n.I18nSupport
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
import scala.concurrent.{ExecutionContext, Future}
import serializers.UserAndGroupCsvSerializer
import serializers.UserAndGroupCsvSerializer.UserGroupBlock
import services.{EventService, NotificationService, UserGroupService, UserService}

case class CSVImportController @Inject() (
config: AppConfig,
val controllerComponents: ControllerComponents,
loginAction: LoginAction,
userService: UserService,
groupService: UserGroupService,
notificationsService: NotificationService,
eventService: EventService
)(implicit ec: ExecutionContext, webJarsUtil: WebJarsUtil)
extends InjectedController
with play.api.i18n.I18nSupport
extends BaseController
with I18nSupport
with Operators.Common
with UserOperators
with GroupOperators {
Expand Down Expand Up @@ -171,7 +174,7 @@ case class CSVImportController @Inject() (
"instructor" -> boolean,
"groupAdmin" -> boolean,
"phoneNumber" -> normalizedOptionalText
)(CSVReviewUserFormData.apply)(CSVReviewUserFormData.unapply)
)(CSVReviewUserFormData.apply)(toTupleOpt)

private def groupImportMapping(date: ZonedDateTime): Mapping[UserGroup] =
mapping(
Expand All @@ -195,7 +198,7 @@ case class CSVImportController @Inject() (
"email" -> optional(email),
"publicNote" -> ignored(Option.empty[String]),
"internalSupportComment" -> ignored(Option.empty[String])
)(UserGroup.apply)(UserGroup.unapply)
)(UserGroup.apply)(toTupleOpt)

private def importUsersAfterReviewForm(date: ZonedDateTime): Form[List[CSVUserGroupFormData]] =
Form(
Expand All @@ -210,12 +213,12 @@ case class CSVImportController @Inject() (
"alreadyExists" -> boolean,
"alreadyExistingUser" -> ignored(Option.empty[User]),
"isInMoreThanOneGroup" -> optional(boolean)
)(CSVUserFormData.apply)(CSVUserFormData.unapply)
)(CSVUserFormData.apply)(toTupleOpt)
),
"alreadyExistsOrAllUsersAlreadyExist" -> boolean,
"doNotInsert" -> boolean,
"alreadyExistingGroup" -> ignored(Option.empty[UserGroup])
)(CSVUserGroupFormData.apply)(CSVUserGroupFormData.unapply)
)(CSVUserGroupFormData.apply)(toTupleOpt)
)
)
)
Expand Down Expand Up @@ -438,7 +441,7 @@ case class CSVImportController @Inject() (
},
{ _ =>
usersToInsert.foreach { user =>
notificationsService.newUser(user)
val _ = notificationsService.newUser(user)
eventService.log(
UserCreated,
"Utilisateur ajouté",
Expand Down
15 changes: 12 additions & 3 deletions app/controllers/GroupController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ import modules.AppConfig
import org.webjars.play.WebJarsUtil
import play.api.data.Form
import play.api.i18n.I18nSupport
import play.api.mvc.{Action, AnyContent, Call, InjectedController, RequestHeader, Result}
import play.api.mvc.{
Action,
AnyContent,
BaseController,
Call,
ControllerComponents,
RequestHeader,
Result
}
import play.libs.ws.WSClient
import scala.concurrent.{ExecutionContext, Future}
import serializers.Keys
Expand All @@ -39,14 +47,15 @@ import views.editMyGroups.UserInfos
case class GroupController @Inject() (
applicationService: ApplicationService,
config: AppConfig,
val controllerComponents: ControllerComponents,
dependencies: ServicesDependencies,
eventService: EventService,
groupService: UserGroupService,
loginAction: LoginAction,
userService: UserService,
ws: WSClient,
)(implicit ec: ExecutionContext, webJarsUtil: WebJarsUtil)
extends InjectedController
extends BaseController
with I18nSupport
with Operators.Common
with GroupOperators
Expand Down Expand Up @@ -253,7 +262,7 @@ case class GroupController @Inject() (
)
Future(Unauthorized("Le groupe est utilisé."))
} else {
groupService.deleteById(groupId)
val _ = groupService.deleteById(groupId)
eventService.log(
UserGroupDeleted,
"Groupe supprimé",
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.webjars.play.WebJarsUtil
import play.api.Logger
import play.api.db.Database
import play.api.i18n.I18nSupport
import play.api.mvc._
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
import serializers.Keys
import views.home.LoginPanel

Expand All @@ -17,10 +17,11 @@ import views.home.LoginPanel
@Singleton
class HomeController @Inject() (
val config: AppConfig,
val controllerComponents: ControllerComponents,
loginAction: LoginAction,
db: Database,
)(implicit webJarsUtil: WebJarsUtil)
extends InjectedController
extends BaseController
with I18nSupport
with Operators.Common {

Expand Down
7 changes: 4 additions & 3 deletions app/controllers/JavascriptController.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package controllers

import javax.inject.Singleton
import javax.inject.{Inject, Singleton}
import play.api.http.MimeTypes
import play.api.mvc.{Action, AnyContent, InjectedController}
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
import play.api.routing.JavaScriptReverseRouter

@Singleton
class JavascriptController() extends InjectedController {
class JavascriptController @Inject() (val controllerComponents: ControllerComponents)
extends BaseController {

def javascriptRoutes: Action[AnyContent] =
Action { implicit request =>
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/LoginController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import models.{
import models.EventType.{GenerateToken, UnknownEmail}
import modules.AppConfig
import org.webjars.play.WebJarsUtil
import play.api.mvc.{Action, AnyContent, InjectedController, Request, Result}
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents, Request, Result}
import scala.concurrent.{ExecutionContext, Future}
import scala.jdk.CollectionConverters._
import scala.util.Try
Expand All @@ -42,14 +42,15 @@ import views.home.LoginPanel
class LoginController @Inject() (
agentConnectService: AgentConnectService,
val config: AppConfig,
val controllerComponents: ControllerComponents,
dependencies: ServicesDependencies,
userService: UserService,
notificationService: NotificationService,
tokenService: TokenService,
eventService: EventService,
signupService: SignupService
)(implicit ec: ExecutionContext, webJarsUtil: WebJarsUtil)
extends InjectedController
extends BaseController
with Operators.Common {

import dependencies.ioRuntime
Expand Down Expand Up @@ -145,7 +146,7 @@ class LoginController @Inject() (
)(implicit request: Request[AnyContent]) = {
// Note: we have a small race condition here
// this should be OK almost always
tokenService.create(token)
val _ = tokenService.create(token)
// Here we want to redirect some users to more useful pages:
// observer => /stats
val path: String = {
Expand Down
Loading

0 comments on commit 1e73a93

Please sign in to comment.