From 910a77dc8b5aa2542830302bb5a8ca88789d3d64 Mon Sep 17 00:00:00 2001 From: Damien Coraboeuf Date: Fri, 31 May 2024 07:36:56 +0200 Subject: [PATCH] #1275 Review of properties --- ....branching.BranchingModelPropertyType.adoc | 2 +- ...ty.GitBranchConfigurationPropertyType.adoc | 8 ++-- ...on.git.property.GitCommitPropertyType.adoc | 2 +- ...ow.BuildGitHubWorkflowRunPropertyType.adoc | 12 ++++++ .../general/BuildLinkDisplayProperty.kt | 8 ++++ .../git/branching/BranchingModelProperty.kt | 4 +- .../GitBranchConfigurationProperty.kt | 39 +++++++++++-------- .../git/property/GitCommitProperty.kt | 3 ++ .../BuildGitHubWorkflowRunProperty.kt | 2 + .../ValidationRunGitHubWorkflowJobProperty.kt | 8 +++- ...uildGitHubWorkflowRunPropertyType.tpl.html | 6 ++- .../ontrack/model/docs/DocumentationUtils.kt | 7 +--- .../ontrack/model/support/NameValue.kt | 8 ++-- .../Display.js | 12 ++++++ .../Icon.js | 5 +++ .../Display.js | 17 ++++++++ .../Icon.js | 5 +++ .../Display.js | 32 +++++++++++++++ .../Icon.js | 5 +++ .../Display.js | 25 ++++++++++++ .../Icon.js | 5 +++ .../Display.js | 15 +++++++ .../jira.JIRAFollowLinksPropertyType/Icon.js | 5 +++ 23 files changed, 198 insertions(+), 37 deletions(-) create mode 100644 ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Display.js create mode 100644 ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Icon.js create mode 100644 ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Display.js create mode 100644 ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Icon.js create mode 100644 ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Display.js create mode 100644 ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Icon.js create mode 100644 ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Display.js create mode 100644 ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Icon.js create mode 100644 ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Display.js create mode 100644 ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Icon.js diff --git a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.branching.BranchingModelPropertyType.adoc b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.branching.BranchingModelPropertyType.adoc index 63e7f180f3..15ea8a02ba 100644 --- a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.branching.BranchingModelPropertyType.adoc +++ b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.branching.BranchingModelPropertyType.adoc @@ -11,5 +11,5 @@ Scope: Configuration: -* **patterns** - List - required - patterns field +* **patterns** - List - required - List of branch patterns (name & value). The name is the category of branch and the value is a regular expression on the SCM branch. diff --git a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitBranchConfigurationPropertyType.adoc b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitBranchConfigurationPropertyType.adoc index 1be4b10619..2737241f44 100644 --- a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitBranchConfigurationPropertyType.adoc +++ b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitBranchConfigurationPropertyType.adoc @@ -11,15 +11,15 @@ Scope: Configuration: -* **branch** - String - required - branch field +* **branch** - String - required - Git branch or pull request ID -* **buildCommitLink** - Object - optional - buildCommitLink field +* **buildCommitLink** - Object - optional - How builds are linked to their Git commit ** **data** - JSON - optional - Configuration of the service ** **id** - String - required - ID of the service -* **buildTagInterval** - Int - required - buildTagInterval field +* **buildTagInterval** - Int - required - Interval in minutes for build/tag synchronization -* **isOverride** - Boolean - required - isOverride field +* **isOverride** - Boolean - required - Build overriding policy when synchronizing diff --git a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitCommitPropertyType.adoc b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitCommitPropertyType.adoc index 431a7e2c8d..5e9e9afad6 100644 --- a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitCommitPropertyType.adoc +++ b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.git.property.GitCommitPropertyType.adoc @@ -11,5 +11,5 @@ Scope: Configuration: -* **commit** - String - required - commit field +* **commit** - String - required - Commit hash diff --git a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.adoc b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.adoc index 1aad057298..c28e0418ab 100644 --- a/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.adoc +++ b/ontrack-docs/src/docs/asciidoc/properties/property-net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.adoc @@ -13,3 +13,15 @@ Configuration: * **workflows** - List - required - All workflows associated to a build. +** **event** - String - optional - Event having led to the creation of this build + +** **name** - String - required - Name of the workflow + +** **runId** - Long - required - ID of the run + +** **runNumber** - Int - required - Number of the run + +** **running** - Boolean - required - True if the run is still flagged as running + +** **url** - String - required - Link to the GitHub Workflow run + diff --git a/ontrack-extension-general/src/main/java/net/nemerosa/ontrack/extension/general/BuildLinkDisplayProperty.kt b/ontrack-extension-general/src/main/java/net/nemerosa/ontrack/extension/general/BuildLinkDisplayProperty.kt index 1f0ffd06df..c9d0c4e091 100644 --- a/ontrack-extension-general/src/main/java/net/nemerosa/ontrack/extension/general/BuildLinkDisplayProperty.kt +++ b/ontrack-extension-general/src/main/java/net/nemerosa/ontrack/extension/general/BuildLinkDisplayProperty.kt @@ -1,5 +1,7 @@ package net.nemerosa.ontrack.extension.general +import net.nemerosa.ontrack.model.annotations.APIDescription + /** * Configuration of the display options for build links * targeting a project. @@ -12,6 +14,12 @@ package net.nemerosa.ontrack.extension.general * the release name if available, and then the build name as a default. */ class BuildLinkDisplayProperty( + @APIDescription( + """Configuration at project label to specify that a + build link decoration should use the release/label + of a build when available. By default, it displays + the release name if available, and then the build name as a default.""" + ) val useLabel: Boolean ) diff --git a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/branching/BranchingModelProperty.kt b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/branching/BranchingModelProperty.kt index 235489fba3..0e74b5bc81 100644 --- a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/branching/BranchingModelProperty.kt +++ b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/branching/BranchingModelProperty.kt @@ -1,7 +1,9 @@ package net.nemerosa.ontrack.extension.git.branching +import net.nemerosa.ontrack.model.annotations.APIDescription import net.nemerosa.ontrack.model.support.NameValue class BranchingModelProperty( - val patterns: List + @APIDescription("List of branch patterns (name & value). The name is the category of branch and the value is a regular expression on the SCM branch.") + val patterns: List ) diff --git a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitBranchConfigurationProperty.kt b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitBranchConfigurationProperty.kt index b9c4055d77..6cb167f8a6 100644 --- a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitBranchConfigurationProperty.kt +++ b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitBranchConfigurationProperty.kt @@ -1,29 +1,34 @@ package net.nemerosa.ontrack.extension.git.property +import net.nemerosa.ontrack.model.annotations.APIDescription import net.nemerosa.ontrack.model.docs.DocumentationField import net.nemerosa.ontrack.model.structure.ServiceConfiguration class GitBranchConfigurationProperty( - /** - * Git branch or pull request ID - */ - val branch: String, + /** + * Git branch or pull request ID + */ + @APIDescription("Git branch or pull request ID") + val branch: String, - /** - * Build link - */ - @DocumentationField - val buildCommitLink: ServiceConfiguration?, + /** + * Build link + */ + @DocumentationField + @APIDescription("How builds are linked to their Git commit") + val buildCommitLink: ServiceConfiguration?, - /** - * Build overriding policy when synchronizing - */ - val isOverride: Boolean, + /** + * Build overriding policy when synchronizing + */ + @APIDescription("Build overriding policy when synchronizing") + val isOverride: Boolean, - /** - * Interval in minutes for build/tag synchronization - */ - val buildTagInterval: Int + /** + * Interval in minutes for build/tag synchronization + */ + @APIDescription("Interval in minutes for build/tag synchronization") + val buildTagInterval: Int ) diff --git a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitCommitProperty.kt b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitCommitProperty.kt index 24fa5e8f70..025dd49368 100644 --- a/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitCommitProperty.kt +++ b/ontrack-extension-git/src/main/java/net/nemerosa/ontrack/extension/git/property/GitCommitProperty.kt @@ -1,5 +1,8 @@ package net.nemerosa.ontrack.extension.git.property +import net.nemerosa.ontrack.model.annotations.APIDescription + class GitCommitProperty( + @APIDescription("Commit hash") val commit: String ) diff --git a/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/BuildGitHubWorkflowRunProperty.kt b/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/BuildGitHubWorkflowRunProperty.kt index b121011905..84d2e6fa58 100644 --- a/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/BuildGitHubWorkflowRunProperty.kt +++ b/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/BuildGitHubWorkflowRunProperty.kt @@ -1,6 +1,7 @@ package net.nemerosa.ontrack.extension.github.workflow import net.nemerosa.ontrack.model.annotations.APIDescription +import net.nemerosa.ontrack.model.docs.DocumentationList /** * Links between GitHub Workflow runs and an Ontrack build. @@ -9,6 +10,7 @@ import net.nemerosa.ontrack.model.annotations.APIDescription */ data class BuildGitHubWorkflowRunProperty( @APIDescription("All workflows associated to a build.") + @DocumentationList val workflows: List, ) { /** diff --git a/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/ValidationRunGitHubWorkflowJobProperty.kt b/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/ValidationRunGitHubWorkflowJobProperty.kt index 798013467e..2653dfa750 100644 --- a/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/ValidationRunGitHubWorkflowJobProperty.kt +++ b/ontrack-extension-github/src/main/java/net/nemerosa/ontrack/extension/github/workflow/ValidationRunGitHubWorkflowJobProperty.kt @@ -14,12 +14,18 @@ import net.nemerosa.ontrack.model.annotations.APIDescription * @property event Event having led to the creation of this validation */ class ValidationRunGitHubWorkflowJobProperty( + @APIDescription("ID of the run") val runId: Long, + @APIDescription("Link to the GitHub Workflow run") val url: String, + @APIDescription("Name of the workflow") val name: String, + @APIDescription("Number of the run") val runNumber: Int, - val job: String, + @APIDescription("True if the run is still flagged as running") val running: Boolean, @APIDescription("Event having led to the creation of this validation") val event: String?, + @APIDescription("Name of the workflow job which created this validation") + val job: String, ) diff --git a/ontrack-extension-github/src/main/resources/static/extension/github/property/net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.tpl.html b/ontrack-extension-github/src/main/resources/static/extension/github/property/net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.tpl.html index 6e174f772f..2b99a0e1b3 100644 --- a/ontrack-extension-github/src/main/resources/static/extension/github/property/net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.tpl.html +++ b/ontrack-extension-github/src/main/resources/static/extension/github/property/net.nemerosa.ontrack.extension.github.workflow.BuildGitHubWorkflowRunPropertyType.tpl.html @@ -1,2 +1,4 @@ -{{ property.value.name }}#{{ property.value.runNumber }} {{ property.value.event }} -(running) \ No newline at end of file +

+ {{ workflow.name }}#{{ workflow.runNumber }} {{ workflow.event }} + (running) +

\ No newline at end of file diff --git a/ontrack-model/src/main/java/net/nemerosa/ontrack/model/docs/DocumentationUtils.kt b/ontrack-model/src/main/java/net/nemerosa/ontrack/model/docs/DocumentationUtils.kt index f28f4694c2..a4812014c7 100644 --- a/ontrack-model/src/main/java/net/nemerosa/ontrack/model/docs/DocumentationUtils.kt +++ b/ontrack-model/src/main/java/net/nemerosa/ontrack/model/docs/DocumentationUtils.kt @@ -62,12 +62,7 @@ fun getFieldsForDocumentationClass(documentationClass: KClass<*>): List, section: String = ""): List { val documentationAnnotation = type.findAnnotations().firstOrNull { it.section == section } - val documentationClass = documentationAnnotation?.value - ?: if (type.hasAnnotation()) { - type - } else { - return emptyList() - } + val documentationClass = documentationAnnotation?.value ?: type return getFieldsForDocumentationClass(documentationClass) } diff --git a/ontrack-model/src/main/java/net/nemerosa/ontrack/model/support/NameValue.kt b/ontrack-model/src/main/java/net/nemerosa/ontrack/model/support/NameValue.kt index 3f47dd1d20..6c2525cb16 100644 --- a/ontrack-model/src/main/java/net/nemerosa/ontrack/model/support/NameValue.kt +++ b/ontrack-model/src/main/java/net/nemerosa/ontrack/model/support/NameValue.kt @@ -4,8 +4,8 @@ import net.nemerosa.ontrack.model.annotations.APIDescription @APIDescription("Association of a name with a value") data class NameValue( - @APIDescription("Name of the pair") - val name: String, - @APIDescription("Value of the pair") - val value: String, + @APIDescription("Name") + val name: String, + @APIDescription("Value") + val value: String, ) diff --git a/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Display.js b/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Display.js new file mode 100644 index 0000000000..20439c4349 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Display.js @@ -0,0 +1,12 @@ +import {Descriptions, Space, Tag, Typography} from "antd"; +import TimestampText from "@components/common/TimestampText"; +import YesNo from "@components/common/YesNo"; + +export default function Display({property}) { + return ( + + Use label: + + + ) +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Icon.js b/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Icon.js new file mode 100644 index 0000000000..0959821a9b --- /dev/null +++ b/ontrack-web-core/components/framework/properties/general.BuildLinkDisplayPropertyType/Icon.js @@ -0,0 +1,5 @@ +import {FaTag} from "react-icons/fa"; + +export default function Icon() { + return +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Display.js b/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Display.js new file mode 100644 index 0000000000..f43ac3e6e1 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Display.js @@ -0,0 +1,17 @@ +import {Descriptions, Typography} from "antd"; + +export default function Display({property}) { + + const items = property.value.patterns.map((pattern) => ({ + key: pattern.name, + label: pattern.name, + children: {pattern.value}, + span: 12, + })) + + return ( + <> + + + ) +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Icon.js b/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Icon.js new file mode 100644 index 0000000000..0f7dff802c --- /dev/null +++ b/ontrack-web-core/components/framework/properties/git.branching.BranchingModelPropertyType/Icon.js @@ -0,0 +1,5 @@ +import {FaCodeBranch} from "react-icons/fa"; + +export default function Icon() { + return +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Display.js b/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Display.js new file mode 100644 index 0000000000..551eddffd0 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Display.js @@ -0,0 +1,32 @@ +import {Space, Spin, Typography} from "antd"; +import Link from "next/link"; +import {FaGithub} from "react-icons/fa"; + +export default function Display({property}) { + + return ( + <> + + { + property.value.workflows.map(workflow => ( + <> + + + + {workflow.name}#{workflow.runNumber} + + {workflow.event && {workflow.event}} + { + workflow.running && <> + + Running + + } + + + )) + } + + + ) +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Icon.js b/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Icon.js new file mode 100644 index 0000000000..1818f0d014 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/github.workflow.BuildGitHubWorkflowRunPropertyType/Icon.js @@ -0,0 +1,5 @@ +import {FaGithub} from "react-icons/fa"; + +export default function Icon() { + return +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Display.js b/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Display.js new file mode 100644 index 0000000000..0cfc57ee8b --- /dev/null +++ b/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Display.js @@ -0,0 +1,25 @@ +import {Space, Spin, Typography} from "antd"; +import Link from "next/link"; +import {FaGithub} from "react-icons/fa"; + +export default function Display({property}) { + + return ( + <> + + + + {property.value.name}#{property.value.runNumber} + + {property.value.job} + {property.value.event && {property.value.event}} + { + property.value.running && <> + + Running + + } + + + ) +} diff --git a/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Icon.js b/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Icon.js new file mode 100644 index 0000000000..1818f0d014 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/github.workflow.ValidationRunGitHubWorkflowJobPropertyType/Icon.js @@ -0,0 +1,5 @@ +import {FaGithub} from "react-icons/fa"; + +export default function Icon() { + return +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Display.js b/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Display.js new file mode 100644 index 0000000000..5c3d845a9b --- /dev/null +++ b/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Display.js @@ -0,0 +1,15 @@ +import {Tag} from "antd"; + +export default function Display({property}) { + return ( + <> + { + property.value.linkNames.map(link => ( + <> + {link} + + )) + } + + ) +} \ No newline at end of file diff --git a/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Icon.js b/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Icon.js new file mode 100644 index 0000000000..a0d5210a59 --- /dev/null +++ b/ontrack-web-core/components/framework/properties/jira.JIRAFollowLinksPropertyType/Icon.js @@ -0,0 +1,5 @@ +import {FaJira} from "react-icons/fa"; + +export default function Icon() { + return +} \ No newline at end of file