Skip to content

Commit

Permalink
Read-based checks for viewing templates and write-based checks for sa…
Browse files Browse the repository at this point in the history
…ving them (#23458)
  • Loading branch information
philrenaud authored Jun 28, 2024
1 parent cc01c09 commit bbd1bb3
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/23458.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fix an issue where access to Job Templates in the UI was restricted to variable.write access
```
2 changes: 1 addition & 1 deletion ui/app/templates/components/job-editor.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
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 & dropping a file to the editor.
</p>

{{#if (can "write variable" path="*" namespace="*")}}
{{#if (can "read variable" path="nomad/job-templates/*" namespace="*")}}
<Hds::ButtonSet>
<label
class="job-spec-upload hds-button hds-button--color-secondary hds-button--size-medium"
Expand Down
18 changes: 10 additions & 8 deletions ui/app/templates/components/job-editor/edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,16 @@
data-test-plan
@text="Plan"
/>
{{#if @data.job.isNew}}
<Hds::Button
@text="Save as template"
@color="secondary"
@route="jobs.run.templates.new"
{{on "click" @fns.onSaveAs}}
data-test-save-as-template
/>
{{#if (can "write variable" path="nomad/job-templates/*" namespace="*")}}
{{#if @data.job.isNew}}
<Hds::Button
@text="Save as template"
@color="secondary"
@route="jobs.run.templates.new"
{{on "click" @fns.onSaveAs}}
data-test-save-as-template
/>
{{/if}}
{{/if}}
<Hds::Button
@text="Save as .nomad.hcl"
Expand Down
7 changes: 5 additions & 2 deletions ui/app/templates/jobs/run/templates/manage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
<:body as |B|>
<B.Tr>
<B.Td>
{{#if B.data.isDefaultJobTemplate}}
{{format-template-label B.data.path}}
{{#if (or
B.data.isDefaultJobTemplate
(not (can "write variable" path="nomad/job-templates/*" namespace="*"))
)}}
{{format-template-label B.data.path}}
{{else}}
<LinkTo @route="jobs.run.templates.template" @model={{concat B.data.path "@" B.data.namespace}} data-test-edit-template={{B.data.path}}>
{{format-template-label B.data.path}}
Expand Down

0 comments on commit bbd1bb3

Please sign in to comment.