Skip to content

Commit

Permalink
Fixes for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
richmahn committed Dec 20, 2024
1 parent ec20098 commit 4540208
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 65 deletions.
21 changes: 12 additions & 9 deletions models/repo/door43healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ var IssueCodeNegatives = map[IssueCode]string{
IssueCodeTitle: "Title still contains 'unfoldingWord'",
IssueCodeIdentifier: "Identifier is not valid for the resource's subject",
IssueCodeLanguage: "Language is still English",
IssueCodeIngredientTitle: "Ingredient is still in English",
IssueCodeIngredientMissing: "Ingredient path is missing",
IssueCodeIngredientEmpty: "Ingredient file is empty",
IssueCodeIngredientTitle: "Book is still in English",
IssueCodeIngredientMissing: "Book file is missing",
IssueCodeIngredientEmpty: "Book file is empty",
IssueCodeReleaseNeeded: "An error-free release needs to be published for the resource",
}

Expand All @@ -162,9 +162,9 @@ var IssueCodePositives = map[IssueCode]string{
IssueCodeTitle: "Title has been properly changed",
IssueCodeIdentifier: "Identifier is valid for the resource's subject",
IssueCodeLanguage: "Language has been set",
IssueCodeIngredientTitle: "Ingredient titles have been translated",
IssueCodeIngredientMissing: "Ingredient paths exists",
IssueCodeIngredientEmpty: "Ingredient files are not empty",
IssueCodeIngredientTitle: "Book titles have been translated",
IssueCodeIngredientMissing: "Book files exist",
IssueCodeIngredientEmpty: "Book files are not empty",
IssueCodeReleaseNeeded: "An error-free release has been published",
}

Expand All @@ -177,7 +177,7 @@ var IssueDetailsFormatStrings = map[IssueCode]string{
IssueCodeIdentifier: "Identifier in manifest.yaml should not be **`%s`** for the subject **`%s`**.",
IssueCodeLanguage: "Language in manifest.yaml is still English **`en`**.",
IssueCodeIngredientTitle: "The title in for the project '%s' is still in English: %s",
IssueCodeIngredientMissing: "The path for project **`%s`** is does not exist in the repo: **`%s`**",
IssueCodeIngredientMissing: "The file for project **`%s`** is does not exist in the repo: **`%s`**",
IssueCodeIngredientEmpty: "The file for project **`%s`** is empty: **`%s`**",
IssueCodeReleaseNeeded: "An error-free release needs to be published for the resource.",
}
Expand All @@ -191,8 +191,8 @@ var IssueSuggestionsFormatStrings = map[IssueCode]string{
IssueCodeIdentifier: "Edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and change **`%s`** to the correct **`identifier`** for the subject **`%s`**, which is **`%s`**.",
IssueCodeLanguage: "Edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and change **`en`** to the correct **`language code`** for your project's language, the **`title`** of the language, and the **`direction`**.",
IssueCodeIngredientTitle: "Edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and translate the **`title`** of the projects. For example, translate **'%s'** to the resource's language.",
IssueCodeIngredientMissing: "Either edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and remove the project **`%s`** or add the missing file or path, **`%s`**, to the repository.",
IssueCodeIngredientEmpty: "Either edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and remove the project **`%s`** or add content to the file **`%s`**.",
IssueCodeIngredientMissing: "Either edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and remove the project with the identifier of **`%s`** or add the missing file, **`%s`**, to the repository.",
IssueCodeIngredientEmpty: "Either edit the <a href=\"%s/src/branch/%s/manifest.yaml\" target=\"_blank\">manifest.yaml</a> file and remove the project with the identifier of **`%s`** or add content to the file **`%s`**.",
IssueCodeReleaseNeeded: "It looks like %s of the **`%s`** branch's %ss has been fixed. You should create a release for the resource with <a href=\"https://gateway-admin.netlify.app/\" target=\"_blank\">**`gatewayAdmin`**</a>.",
}

Expand Down Expand Up @@ -232,6 +232,9 @@ func (h *Door43HealthcheckIssue) TableName() string {

// GetHealthcheck on Door43Metadata
func (dm *Door43Metadata) GetHealthcheck(ctx context.Context) *HealthcheckGroupedIssues {
if dm.MetadataType != "rc" {
return nil
}
dm.LoadRepo(ctx)
issues := []*Door43HealthcheckIssue{}

Expand Down
29 changes: 25 additions & 4 deletions routers/api/v1/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -1180,15 +1180,36 @@ func GetHealthcheck(ctx *context.APIContext) {
// "$ref": "#/responses/Door43Healthcheck"
// "404":
// "$ref": "#/responses/notFound"
// "422":
// "$ref": "#/responses/validationError"

ctx.Repo.Repository.LoadLatestDMs(ctx)

if ctx.Repo.Repository.RepoDM != nil || ctx.Repo.Repository.RepoDM.GetHealthcheck(ctx) == nil {
ctx.NotFound()
return
if ctx.Repo.Repository.RepoDM == nil || ctx.Repo.Repository.RepoDM.ID == 0 {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"ok": false,
"error": fmt.Sprintf("no metadata found for repo [%s]", ctx.Repo.Repository.FullName()),
})
}

if ctx.Repo.Repository.RepoDM.MetadataType != "rc" {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"ok": false,
"error": "currently only repositories of the 'rc' metadata type are supported",
})
}

healthcheck := ctx.Repo.Repository.RepoDM.GetHealthcheck(ctx)

if healthcheck == nil {
ctx.JSON(http.StatusUnprocessableEntity, map[string]any{
"ok": false,
"error": fmt.Sprintf("unable to perform a healthcheck on this repository [%s]", ctx.Repo.Repository.FullName()),
})
}

ctx.JSON(http.StatusOK, map[string]any{
"ok": true,
"data": ctx.Repo.Repository.RepoDM.GetHealthcheck(ctx),
"data": healthcheck,
})
}
2 changes: 1 addition & 1 deletion routers/web/dcs/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

const (
// tplCatalog catalog page template.
tplCatalog base.TplName = "healthcheck/healthcheck"
tplCatalog base.TplName = "catalog/catalog"
)

// CatalogSearchOptions when calling search catalog
Expand Down
51 changes: 34 additions & 17 deletions templates/catalog/catalog_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,41 @@
{{.Title}}
</a>
<span class="label-list">
{{if .Repo.IsFork}}
<span class="middle">{{svg "octicon-repo-forked" 16}}</span>
{{else if .Repo.IsMirror}}
<span class="middle">{{svg "octicon-repo-clone" 16}}</span>
{{end}}
{{if .Release}}
{{$color := "green"}}
{{$type := "Production"}}
{{if .Release.IsPrerelease}}
{{$color = "orange"}}
{{$type = "Pre-Release"}}
{{if .Repo.IsFork}}
<span class="middle">{{svg "octicon-repo-forked" 16}}</span>
{{else if .Repo.IsMirror}}
<span class="middle">{{svg "octicon-repo-clone" 16}}</span>
{{end}}
{{$color := ""}}
{{$icon := ""}}
{{if eq .HealthcheckSeverity.String "error"}}
{{$color = "red"}}
{{$icon = "octicon-shield-x"}}
{{else if eq .HealthcheckSeverity.String "warning"}}
{{$color = "octicon-shield"}}
{{else if eq .HealthcheckSeverity.String "info"}}
{{$color = "octicon-shield-lock"}}
{{end}}
{{if ne $icon ""}}
<span class="ui basic label" data-tooltip-content="Healthcheck: {{.HealthcheckSeverity.String}}">
<a class="muted" href="{{.Repo.Link}}/healthcheck" style="color: {{$color}}">
{{svg $icon 16}}
</a>
</span>
{{end}}
{{if .Release}}
{{$color := "green"}}
{{$type := "Production"}}
{{if .Release.IsPrerelease}}
{{$color = "orange"}}
{{$type = "Pre-Release"}}
{{end}}
<a href="{{.Release.HTMLURL}}" rel="nofollow" style="opacity: inherit !important; margin: 0">
<button class="ui {{$color}} label compact icon button tooltip" data-content="Catalog: {{$type}}" aria-label="Catalog: {{$type}}">
{{.Ref}}
</button>
</a>
{{end}}
<a class="catalog-badge" href="{{.Release.HTMLURL}}" rel="nofollow" style="opacity: inherit !important; margin: 0">
<button class="ui {{$color}} label compact icon button tooltip" data-content="Catalog: {{$type}}" aria-label="Catalog: {{$type}}">
{{.Ref}}
</button>
</a>
{{end}}
</span>
</div>
<div class="flex-item-trailing">
Expand Down
51 changes: 35 additions & 16 deletions templates/explore/repo_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,42 @@
{{if .IsTemplate}}
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.template"}}</span>
{{end}}
<!-- DCS Customizations -->
{{$color := ""}}
{{$icon := ""}}
{{if eq .RepoDM.HealthcheckSeverity.String "error"}}
{{$color = "red"}}
{{$icon = "octicon-shield-x"}}
{{else if eq .RepoDM.HealthcheckSeverity.String "warning"}}
{{$color = "orange"}}
{{$icon = "octicon-shield"}}
{{else if eq .RepoDM.HealthcheckSeverity.String "info"}}
{{$color = "blue"}}
{{$icon = "octicon-shield-lock"}}
{{end}}
{{if ne $icon ""}}
<span class="ui basic label" data-tooltip-content="Healthcheck: {{.RepoDM.HealthcheckSeverity.String}}">
<a class="muted" href="{{.Link}}/healthcheck" style="color: {{$color}}">
{{svg $icon 16}}
</a>
</span>
{{end}}
{{if .LatestProdDM}}
<a href="{{.Link}}/releases/tag/{{.LatestProdDM.Ref | PathEscapeSegments}}" rel="nofollow">
<button class="ui green label compact icon button tooltip" data-content="Catalog: Production" aria-label="Catalog: Production">
{{.LatestProdDM.Ref}}
</button>
</a>
{{end}}
{{if .LatestPreprodDM}}
<a href="{{.Link}}/releases/tag/{{.LatestPreprodDM.Ref | PathEscapeSegments}}" rel="nofollow">
<button class="ui orange label compact icon button tooltip" data-content="Catalog: Pre-Production" aria-label="Catalog: Production">
{{.LatestPreprodDM.Ref}}
</button>
</a>
{{end}}
<!-- END DCS Customizations -->
</span>
<!-- DCS Customizations -->
{{if .LatestProdDM}}
<a href="{{.Link}}/releases/tag/{{.LatestProdDM.Ref | PathEscapeSegments}}" rel="nofollow">
<button class="ui green label compact icon button tooltip" data-content="Catalog: Production" aria-label="Catalog: Production">
{{.LatestProdDM.Ref}}
</button>
</a>
{{end}}
{{if .LatestPreprodDM}}
<a href="{{.Link}}/releases/tag/{{.LatestPreprodDM.Ref | PathEscapeSegments}}" rel="nofollow">
<button class="ui orange label compact icon button tooltip" data-content="Catalog: Pre-Production" aria-label="Catalog: Production">
{{.LatestPreprodDM.Ref}}
</button>
</a>
{{end}}
<!-- END DCS Customizations -->
</div>
<div class="flex-item-trailing">
<!-- DCS Customizations -->
Expand Down
20 changes: 2 additions & 18 deletions templates/repo/dcs_healthcheck.tmpl
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
{{template "base/head" .}}
<script>
function toggleShowTable(element, type) {
var content = element.parentElement.nextElementSibling;
if (content.style.display === "none") {
if (content.tagName.toLowerCase() === "table") {
content.style.display = "table";
} else {
content.style.display = "block";
}
element.innerText = "Click to collapse "+type;
} else {
content.style.display = "none";
element.innerText = "Click to see "+type;
}
}
</script>
<style>
.status-item {
padding: 10px;
Expand Down Expand Up @@ -42,7 +26,7 @@
.item-text {
padding-left: 20px;
margin-top: 10px;
}
}pextra_
</style>
<div role="main" aria-label="{{.Title}}" class="page-content repository settings">
{{template "repo/header" .}}
Expand All @@ -56,7 +40,7 @@
Overall {{.Title}}
</h4>
<div class="ui attached segment">
{{if .Repo.RepoDM}}
{{if eq .Repo.RepoDM.MetadataType "rc"}}
{{template "repo/dcs_healthcheck_list" (dict "ctxData" . "Door43Metadata" .Repo.RepoDM)}}
{{else}}
<span>
Expand Down

0 comments on commit 4540208

Please sign in to comment.