Skip to content

Commit

Permalink
A few variable-adding bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed May 25, 2023
1 parent 3bde355 commit 3222cbe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
21 changes: 11 additions & 10 deletions ui/app/components/variable-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
Format: <code>nomad/jobs/&lt;jobname&gt;</code>, <code>nomad/jobs/&lt;jobname&gt;/&lt;groupname&gt;</code>, <code>nomad/jobs/&lt;jobname&gt;/&lt;groupname&gt;/&lt;taskname&gt;</code></p>
</div>
{{/unless}}

{{#if this.shouldShowLinkedEntities}}
<VariableForm::RelatedEntities
@new={{true}}
@job={{@model.pathLinkedEntities.job}}
@group={{@model.pathLinkedEntities.group}}
@task={{@model.pathLinkedEntities.task}}
@namespace={{this.variableNamespace}}
/>
{{/if}}

{{/if}}

{{#if this.hasConflict}}
Expand Down Expand Up @@ -150,16 +161,6 @@
{{/if}}
{{/if}}

{{#if (and this.shouldShowLinkedEntities @model.isNew)}}
<VariableForm::RelatedEntities
@new={{true}}
@job={{@model.pathLinkedEntities.job}}
@group={{@model.pathLinkedEntities.group}}
@task={{@model.pathLinkedEntities.task}}
@namespace={{this.variableNamespace}}
/>
{{/if}}

<footer>
{{#unless this.isJSONView}}
{{#unless this.isJobTemplateVariable}}
Expand Down
7 changes: 5 additions & 2 deletions ui/app/components/variable-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ export default class VariableFormComponent extends Component {
let existingVariable = existingVariables
.without(this.args.model)
.find(
(v) => v.path === pathValue && v.namespace === this.variableNamespace
(v) =>
v.path === pathValue &&
(v.namespace === this.variableNamespace || !this.variableNamespace)
);
if (existingVariable) {
return {
Expand Down Expand Up @@ -372,7 +374,8 @@ export default class VariableFormComponent extends Component {
return (
this.args.model.pathLinkedEntities?.job ||
this.args.model.pathLinkedEntities?.group ||
this.args.model.pathLinkedEntities?.task
this.args.model.pathLinkedEntities?.task ||
trimPath([this.path]) === 'nomad/jobs'
);
}

Expand Down
4 changes: 3 additions & 1 deletion ui/app/components/variable-form/related-entities.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
{{else if @group}}
group <LinkTo @route="jobs.job.task-group" @models={{array (concat @job "@" @namespace) @group}}>{{@group}} <FlightIcon @name="external-link" /></LinkTo>
{{else if @job}}
job <LinkTo @route="jobs.job" @model={{concat @job "@" @namespace}}>{{@job}} <FlightIcon @name="external-link" /></LinkTo><
job <LinkTo @route="jobs.job" @model={{concat @job "@" @namespace}}>{{@job}} <FlightIcon @name="external-link" /></LinkTo>
{{else}}
all nomad jobs
{{/if}}
</span>
</p>
3 changes: 2 additions & 1 deletion ui/app/controllers/variables/variable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export default class VariablesVariableIndexController extends Controller {
return (
this.model.pathLinkedEntities?.job ||
this.model.pathLinkedEntities?.group ||
this.model.pathLinkedEntities?.task
this.model.pathLinkedEntities?.task ||
this.model.path === 'nomad/jobs'
);
}

Expand Down

0 comments on commit 3222cbe

Please sign in to comment.