diff --git a/app/auth/TokenSecurity.scala b/app/auth/TokenSecurity.scala index 5212850ee..c84c69343 100644 --- a/app/auth/TokenSecurity.scala +++ b/app/auth/TokenSecurity.scala @@ -56,6 +56,10 @@ trait TokenSecurity extends OidcSecurity with I18nSupport { consignmentTypeAction(consignmentId, "standard")(action) } + def tnaUserAction(action: Request[AnyContent] => Future[Result]): Action[AnyContent] = secureAction.async { request => + createResult(action, request, request.token.isTNAUser) + } + private def createResult(action: Request[AnyContent] => Future[Result], request: AuthenticatedRequest[AnyContent], isPermitted: Boolean) = { if (isPermitted) { action(request) diff --git a/app/controllers/MetadataReviewController.scala b/app/controllers/MetadataReviewController.scala new file mode 100644 index 000000000..cf2decdda --- /dev/null +++ b/app/controllers/MetadataReviewController.scala @@ -0,0 +1,24 @@ +package controllers + +import auth.TokenSecurity +import configuration.KeycloakConfiguration +import org.pac4j.play.scala.SecurityComponents +import play.api.mvc.{Action, AnyContent, Request} +import services.ConsignmentService + +import javax.inject.Inject + +class MetadataReviewController @Inject() ( + val keycloakConfiguration: KeycloakConfiguration, + val controllerComponents: SecurityComponents, + val consignmentService: ConsignmentService +) extends TokenSecurity { + + def metadataReviews(): Action[AnyContent] = tnaUserAction { implicit request: Request[AnyContent] => + for { + consignments <- consignmentService.getConsignmentsForReview(request.token.bearerAccessToken) + } yield { + Ok(views.html.tna.metadataReviews(consignments)) + } + } +} diff --git a/app/services/ConsignmentService.scala b/app/services/ConsignmentService.scala index ce23a7aad..b8935f0bd 100644 --- a/app/services/ConsignmentService.scala +++ b/app/services/ConsignmentService.scala @@ -17,6 +17,7 @@ import graphql.codegen.GetConsignmentSummary.getConsignmentSummary import graphql.codegen.GetConsignmentType.{getConsignmentType => gct} import graphql.codegen.GetConsignments.getConsignments.Consignments import graphql.codegen.GetConsignments.{getConsignments => gcs} +import graphql.codegen.GetConsignmentsForMetadataReview.{getConsignmentsForMetadataReview => gcfmr} import graphql.codegen.GetFileCheckProgress.{getFileCheckProgress => gfcp} import graphql.codegen.UpdateConsignmentSeriesId.updateConsignmentSeriesId import graphql.codegen.types._ @@ -43,6 +44,7 @@ class ConsignmentService @Inject() (val graphqlConfiguration: GraphQLConfigurati private val updateConsignmentSeriesIdClient = graphqlConfiguration.getClient[updateConsignmentSeriesId.Data, updateConsignmentSeriesId.Variables]() private val getConsignments = graphqlConfiguration.getClient[gcs.Data, gcs.Variables]() private val gctClient = graphqlConfiguration.getClient[gct.Data, gct.Variables]() + private val getConsignmentsForReviewClient = graphqlConfiguration.getClient[gcfmr.Data, gcfmr.Variables]() def fileCheckProgress(consignmentId: UUID, token: BearerAccessToken): Future[gfcp.GetConsignment] = { val variables = gfcp.Variables(consignmentId) @@ -187,6 +189,11 @@ class ConsignmentService @Inject() (val graphqlConfiguration: GraphQLConfigurati .map(data => data.consignments) } + def getConsignmentsForReview(token: BearerAccessToken): Future[List[gcfmr.GetConsignmentsForMetadataReview]] = { + sendApiRequest(getConsignmentsForReviewClient, gcfmr.document, token, gcfmr.Variables()) + .map(data => data.getConsignmentsForMetadataReview) + } + private def getFileFilters(metadataType: Option[String], fileIds: Option[List[UUID]], additionalProperties: Option[List[String]]): Option[FileFilters] = { val metadataTypeFilter = metadataType match { case None => additionalProperties.map(p => FileMetadataFilters(None, None, Some(p))) diff --git a/app/views/main.scala.html b/app/views/main.scala.html index 48d7d4b59..b4977c3b9 100644 --- a/app/views/main.scala.html +++ b/app/views/main.scala.html @@ -6,7 +6,7 @@ *@ @import views.html.helper.CSPNonce @import views.html.partials.feedbackLink -@(title: String, hasError: Boolean = false, isLoggedIn: Boolean = true, name: String = "", isJudgmentUser: Boolean = false, backLink: Option[Html] = None)(content: Html)(implicit messages: Messages, request: RequestHeader) +@(title: String, hasError: Boolean = false, isLoggedIn: Boolean = true, name: String = "", isJudgmentUser: Boolean = false, isTnaUser: Boolean = false, backLink: Option[Html] = None)(content: Html)(implicit messages: Messages, request: RequestHeader) @@ -61,7 +61,7 @@