Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] A few variables-ui-related bugfixes #17319

Merged
merged 2 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/17319.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: fixed a handful of UX-related bugs during variable editing
```
22 changes: 12 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 @@ -137,6 +148,7 @@
class="delete-row button is-danger is-inverted"
type="button"
{{on "click" (action this.deleteRow entry)}}
disabled={{eq this.keyValues.length 1}}
>
Delete
</button>
Expand All @@ -150,16 +162,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
12 changes: 9 additions & 3 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 @@ -180,7 +182,10 @@ export default class VariableFormComponent extends Component {
}

@action appendRow() {
this.keyValues.pushObject(copy(EMPTY_KV));
// Clear our any entity errors
let newRow = copy(EMPTY_KV);
newRow.warnings = EmberObject.create();
this.keyValues.pushObject(newRow);
}

@action deleteRow(row) {
Expand Down Expand Up @@ -372,7 +377,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 in this namespace
{{/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