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] Fix: upload jobspec button #23548

Merged
merged 1 commit into from
Jul 11, 2024
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/23548.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix the Upload Jobspec button on the Run Job page
```
2 changes: 2 additions & 0 deletions ui/app/modifiers/code-mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export default class CodeMirrorModifier extends Modifier {
this.element = element;
this.args = { positional, named };
this._setup();
} else {
this.didUpdateArguments();
}
}

Expand Down
30 changes: 14 additions & 16 deletions ui/app/templates/components/job-editor.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,26 @@
<p>
Paste or author HCL or JSON to submit to your cluster, or select from a list of templates. A plan will be requested before the job is submitted. You can also attach a job spec by uploading a job file or dragging &amp; dropping a file to the editor.
</p>

{{#if (can "read variable" path="nomad/job-templates/*" namespace="*")}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Psst: review this with "Hide Whitespace" enabled. This change makes it so that you can still upload a jobspec without the "read variables" ACL capability, which I had foolishly wrapped the upload button in before (it being next to the button that actually requires variable read access, "Choose from template")

<Hds::ButtonSet>
<label
class="job-spec-upload hds-button hds-button--color-secondary hds-button--size-medium"
>
<div class="hds-button__text">Upload file</div>
<input
type="file"
onchange={{action this.uploadJobSpec}}
accept=".hcl,.json,.nomad"
/>
</label>
<Hds::ButtonSet>
<label
class="job-spec-upload hds-button hds-button--color-secondary hds-button--size-medium"
>
<div class="hds-button__text">Upload file</div>
<input
type="file"
onchange={{action this.fns.onUpload}}
accept=".hcl,.json,.nomad"
/>
</label>
{{#if (can "read variable" path="nomad/job-templates/*" namespace="*")}}
<Hds::Button
@text="Choose from template"
@color="secondary"
@route="jobs.run.templates"
data-test-choose-template
/>
</Hds::ButtonSet>
{{/if}}

{{/if}}
</Hds::ButtonSet>
</header>
{{/if}}
{{did-update this.setDefinitionOnModel this.definition}}
Expand Down
Loading