Skip to content

Commit

Permalink
Merge pull request #986 from hmrc/BDOG-3301
Browse files Browse the repository at this point in the history
BDOG-3301 add new teams page (with health indicators) + feature toggle
  • Loading branch information
Shnick authored Jan 9, 2025
2 parents 16bfde2 + ee0929c commit 2e6b36c
Show file tree
Hide file tree
Showing 32 changed files with 875 additions and 319 deletions.
3 changes: 3 additions & 0 deletions app/uk/gov/hmrc/cataloguefrontend/FeatureSwitch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ object CatalogueFrontendSwitches:

def showTestRepoRelationships: FeatureSwitch =
FeatureSwitch.forName("show-test-repo-relationships")

def showNewTeamPage: FeatureSwitch =
FeatureSwitch.forName("show-new-team-page")
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ class BobbyExplorerController @Inject() (
) extends FrontendController(mcc)
with CatalogueAuthBuilders:

def bobbyViolations(team: Option[TeamName], digitalService: Option[DigitalService], flag: Option[String]): Action[AnyContent] =
/**
* @param teamName for reverse routing
* @param digitalService for reverse routing
* @param flag for reverse routing
* @param isActive for reverse routing
*/
def bobbyViolations(teamName: Option[TeamName], digitalService: Option[DigitalService], flag: Option[String], isActive: Option[Boolean]): Action[AnyContent] =
BasicAuthAction.async: request =>
given MessagesRequest[AnyContent] = request
( for
Expand All @@ -54,11 +60,14 @@ class BobbyExplorerController @Inject() (
, formObject => Right(formObject)
))
results <- EitherT.right[Result]:
serviceDeps.bobbyReports(filter.team, filter.digitalService, filter.repoType, filter.flag)
serviceDeps.bobbyReports(filter.teamName, filter.digitalService, filter.repoType, filter.flag)
yield
Ok(bobbyViolationsPage(form, teams, digitalServices, results = Some(results)))
).merge

/**
* @param selector for reverse routing
*/
def list(selector: Option[String]): Action[AnyContent] =
BasicAuthAction.async: request =>
given RequestHeader = request
Expand All @@ -68,7 +77,7 @@ class BobbyExplorerController @Inject() (
yield Ok(bobbyExplorerPage(rules, counts))

case class BobbyReportFilter(
team : Option[TeamName] = None
teamName : Option[TeamName] = None
, digitalService: Option[DigitalService] = None
, repoType : Option[RepoType] = None
, flag : SlugInfoFlag = SlugInfoFlag.Latest
Expand All @@ -79,7 +88,7 @@ object BobbyReportFilter:
lazy val form: Form[BobbyReportFilter] =
Form(
Forms.mapping(
"team" -> Forms.optional(Forms.of[TeamName])
"teamName" -> Forms.optional(Forms.of[TeamName])
, "digitalService" -> Forms.optional(Forms.of[DigitalService])
, "repoType" -> Forms.optional(Forms.of[RepoType])
, "flag" -> Forms.optional(Forms.of[SlugInfoFlag]).transform(_.getOrElse(SlugInfoFlag.Latest), Some.apply)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class BobbyRulesTrendController @Inject() (
)
)

/**
* @param rules for reverse routing
* @param from for reverse routing
* @param to for reverse routing
*/
def display(
rules: Seq[String],
from : LocalDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
@import uk.gov.hmrc.cataloguefrontend.util.DateHelper._
@import views.html.helper.{FieldConstructor, select}

@this(
teamNamesPartial: partials.TeamNamesPartial
)
@this()

@(form : Form[BobbyReportFilter]
, teams : Seq[GitHubTeam]
Expand Down Expand Up @@ -53,7 +51,7 @@ <h1 id="search-service-header" class="page-heading mt-4">Bobby Violations</h1>
<div class="col-md-2">
@select(
field = form("repoType")
, options = RepoType.values.filterNot(_ == RepoType.Prototype).map(ds => ds.asString -> ds.asString)
, options = RepoType.values.filterNot(_ == RepoType.Prototype).map(ds => ds.asString -> ds.asString).toSeq
, Symbol("_default") -> "All"
, Symbol("_label") -> "Repository Type"
, Symbol("_labelClass") -> "form-label"
Expand All @@ -63,12 +61,12 @@ <h1 id="search-service-header" class="page-heading mt-4">Bobby Violations</h1>
</div>
<div class="col-md-2">
@select(
field = form("team")
field = form("teamName")
, options = teams.map(t => t.name.asString -> t.name.asString)
, Symbol("_default") -> "All"
, Symbol("_label") -> "Team"
, Symbol("_labelClass") -> "form-label"
, Symbol("id") -> "select-team"
, Symbol("id") -> "select-team-name"
, Symbol("class") -> "form-select"
)
</div>
Expand Down Expand Up @@ -185,7 +183,7 @@ <h1 id="search-service-header" class="page-heading mt-4">Bobby Violations</h1>
}

<script @CSPNonce.attr>
['select-team', 'select-digital-service', 'select-repo-type', 'select-environment', 'select-bobby-status']
['select-team-name', 'select-digital-service', 'select-repo-type', 'select-environment', 'select-bobby-status']
.forEach(function(id) {
document.getElementById(id).addEventListener("change", function() {
document.getElementById("form").submit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ class ServiceDependenciesConnector @Inject() (
.map(_.summary)

def bobbyReports(
teamName : Option[TeamName]
, digitalService: Option[DigitalService]
, repoType : Option[RepoType]
teamName : Option[TeamName] = None
, digitalService: Option[DigitalService] = None
, repoType : Option[RepoType] = None
, flag : SlugInfoFlag
)(using HeaderCarrier): Future[Seq[BobbyReport]] =
given Reads[BobbyReport] = BobbyReport.reads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ class TeamsAndRepositoriesConnector @Inject()(
private given Reads[GitRepository] = GitRepository.reads // v2 model

def findTestJobs(
teamName : Option[TeamName],
digitalService: Option[DigitalService]
teamName : Option[TeamName] = None,
digitalService: Option[DigitalService] = None
)(using HeaderCarrier): Future[Seq[JenkinsJob]] =
given Reads[JenkinsJob] =
JenkinsJob.reads
Expand Down Expand Up @@ -314,9 +314,9 @@ class TeamsAndRepositoriesConnector @Inject()(
logger.error(s"An error occurred when connecting to $url: ${ex.getMessage}", ex)
Seq.empty[String]

def allTeams()(using HeaderCarrier): Future[Seq[GitHubTeam]] =
httpClientV2
.get(url"$teamsAndServicesBaseUrl/api/v2/teams")
def allTeams(teamName: Option[TeamName] = None)(using HeaderCarrier): Future[Seq[GitHubTeam]] =
httpClientV2
.get(url"$teamsAndServicesBaseUrl/api/v2/teams?name=${teamName.map(_.asString)}")
.execute[Seq[GitHubTeam]]

def allDigitalServices()(using HeaderCarrier): Future[Seq[DigitalService]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package uk.gov.hmrc.cataloguefrontend.connector.model

import play.api.libs.functional.syntax._
import play.api.libs.json.{Json, Reads, __}
import play.api.libs.json.{Reads, __}
import uk.gov.hmrc.cataloguefrontend.model.{VersionRange, Version}
import uk.gov.hmrc.cataloguefrontend.connector.RepoType

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ class LeakDetectionController @Inject()(
given RequestHeader = request
leakDetectionService.ruleSummaries().map(s => Ok(rulesPage(s)))

/**
* @param team for reverse routing
*/
def repoSummaries(
includeWarnings : Boolean,
includeExemptions: Boolean,
includeViolations: Boolean,
includeNonIssues : Boolean
team : Option[TeamName]
, includeWarnings : Boolean
, includeExemptions: Boolean
, includeViolations: Boolean
, includeNonIssues : Boolean
): Action[AnyContent] =
BasicAuthAction.async: request =>
given Request[AnyContent] = request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ class LeakDetectionService @Inject() (
def resolutionUrl: String =
configuration
.get[String]("leakDetection.resolution.url")

def removeSensitiveInfoUrl: String =
configuration
.get[String]("leakDetection.removeSensitiveInfo.url")

def urlIfLeaksFound(repoName: String)(using HeaderCarrier): Future[Option[String]] =
repositoriesWithLeaks().map: reposWithLeaks =>
if hasLeaks(reposWithLeaks)(repoName)
if reposWithLeaks.exists(_.name == repoName)
then Some(appRoutes.LeakDetectionController.branchSummaries(repoName).url)
else None

Expand All @@ -54,9 +54,6 @@ class LeakDetectionService @Inject() (
then leakDetectionConnector.repositoriesWithLeaks()
else Future.successful(Nil)

def hasLeaks(reposWithLeaks: Seq[RepositoryWithLeaks])(repoName: String): Boolean =
reposWithLeaks.exists(_.name == repoName)

def ruleSummaries()(using HeaderCarrier): Future[Seq[LeakDetectionRulesWithCounts]] =
leakDetectionConnector
.leakDetectionSummaries(None, None, None)
Expand All @@ -75,8 +72,8 @@ class LeakDetectionService @Inject() (
.sortBy(_.unresolvedCount).reverse

def repoSummaries(
ruleId : Option[String],
team : Option[TeamName],
ruleId : Option[String] = None,
team : Option[TeamName] = None,
includeWarnings : Boolean,
includeExemptions: Boolean,
includeViolations: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ <h1 class="page-heading mt-4">Leak Detection Rules</h1>
@countWithLinkCell(ruleId: String, name: String, count: Int, hidden: Boolean) = {
<td class="@name text-center @if(hidden) {d-none}"><div class="d-none">@count</div>
@if(count > 0) {
<a id="@ruleId-@name-count" href="@appRoutes.LeakDetectionController.repoSummaries(false, name == "excluded", name == "unresolved" || name == "repo-count")&rule=@ruleId">@count</a>
<a id="@ruleId-@name-count" href="@appRoutes.LeakDetectionController.repoSummaries(includeWarnings = false, includeExemptions = name == "excluded", includeViolations = name == "unresolved" || name == "repo-count")&rule=@ruleId">@count</a>
} else {
<span>0</span>
}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class PlatformInitiativesController @Inject()
) extends FrontendController(mcc)
with CatalogueAuthBuilders:

/**
* @param team for reverse routing
*/
def platformInitiatives(display: DisplayType, team: Option[TeamName]): Action[AnyContent] =
BasicAuthAction.async: request =>
given MessagesRequest[AnyContent] = request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ class PrCommenterConnector @Inject()(
.execute[Option[PrCommenterReport]]

def search(
name : Option[String],
teamName : Option[TeamName],
commentType: Option[String]
name : Option[String] = None,
teamName : Option[TeamName] = None,
commentType: Option[String] = None
)(using
HeaderCarrier
): Future[Seq[PrCommenterReport]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
@standard_layout("Repositories", "repositories") {
<h1 class="page-heading mt-4">
Repositories
<div class="btn float-end" role="group">
<div class="float-end" role="group">
<a class="btn btn-success" href="@repoRoutes.CreateRepositoryController.createRepoLandingGet()">Create a Repository</a>
</div>
</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class ServiceCommissioningStatusConnector @Inject() (
.map(_.flatMap(identity))

def cachedCommissioningStatus(
teamName : Option[TeamName],
serviceType : Option[ServiceType],
lifecycleStatus: Seq[LifecycleStatus]
teamName : Option[TeamName] = None,
serviceType : Option[ServiceType] = None,
lifecycleStatus: Seq[LifecycleStatus] = Nil
)(using
HeaderCarrier
): Future[List[CachedServiceCheck]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ class ServiceCommissioningStatusController @Inject() (
yield Ok(searchServiceCommissioningStatusPage(form, allTeams, allChecks))
}

//Params exist so they can be provided for deep linking
def searchResults(teamName: Option[TeamName]): Action[AnyContent] =
/**
* @param teamName for reverse routing
* @param hasWarning for reverse routing
*/
def searchResults(teamName: Option[TeamName], hasWarning: Option[Boolean]): Action[AnyContent] =
BasicAuthAction.async { implicit request =>
SearchCommissioning
.searchForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ class ServiceConfigsController @Inject()(
) extends FrontendController(mcc)
with CatalogueAuthBuilders:

/**
* @param selector for reverse routing
*/
def configExplorer(serviceName: ServiceName, showWarnings: Boolean, selector: Option[KeyName]): Action[AnyContent] =
BasicAuthAction.async { implicit request =>
for
Expand All @@ -67,8 +70,11 @@ class ServiceConfigsController @Inject()(
yield Ok(searchConfigPage(SearchConfig.form.fill(SearchConfig.SearchConfigForm()), allTeams, configKeys))
}

/**
* @param configKey for dependencyExplorer reverse routing
*/
def searchResults(
configKey: Option[String] // For dependencyExplorer reverse route
configKey: Option[String]
): Action[AnyContent] =
BasicAuthAction.async { implicit request =>
SearchConfig
Expand Down
Loading

0 comments on commit 2e6b36c

Please sign in to comment.