Skip to content

Commit

Permalink
Allow links without a description and max description to 1000 chars
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed May 10, 2024
1 parent 127b619 commit c68129f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
7 changes: 7 additions & 0 deletions nomad/structs/structs.go
Expand Up @@ -4657,6 +4657,13 @@ func (j *Job) Validate() error {
}
}

const MaxDescriptionCharacters = 1000
if j.Ui != nil {
if len(j.Ui.Description) > MaxDescriptionCharacters {
mErr.Errors = append(mErr.Errors, fmt.Errorf("UI description must be under 1000 characters, currently %d", len(j.Ui.Description)))
}
}

// Check for duplicate task groups
taskGroups := make(map[string]int)
for idx, tg := range j.TaskGroups {
Expand Down
11 changes: 11 additions & 0 deletions nomad/structs/structs_test.go
Expand Up @@ -342,6 +342,17 @@ func TestJob_Validate(t *testing.T) {
"datacenter must be non-empty string",
},
},
{
name: "job description is too long",
job: &Job{
Ui: &JobUIConfig{
Description: strings.Repeat("a", 1015),
},
},
expErr: []string{
"UI description must be under 1000 characters",
},
},
{
name: "job task group is type invalid",
job: &Job{
Expand Down
18 changes: 9 additions & 9 deletions ui/app/templates/components/job-page/parts/title.hbs
Expand Up @@ -18,15 +18,15 @@
<PH.Description data-test-job-description>
{{this.description}}
</PH.Description>
{{#if this.links}}
<PH.Generic>
<div class="job-ui-links">
{{#each this.links as |link|}}
<Hds::Button @color="secondary" @isInline={{true}} @text={{link.Label}} @icon="external-link" @iconPosition="trailing" @href={{link.Url}} />
{{/each}}
</div>
</PH.Generic>
{{/if}}
{{/if}}
{{#if this.links}}
<PH.Generic>
<div class="job-ui-links">
{{#each this.links as |link|}}
<Hds::Button @color="secondary" @isInline={{true}} @text={{link.Label}} @icon="external-link" @iconPosition="trailing" @href={{link.Url}} />
{{/each}}
</div>
</PH.Generic>
{{/if}}
<PH.Actions>

Expand Down

0 comments on commit c68129f

Please sign in to comment.