-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix ACL requirements for job details UI #11672
Changes from 10 commits
eefcfe4
5c9b6af
c92304b
a11b171
0c04a38
3d8a615
f837114
cac1550
96bf92f
dde13e7
e5e6fea
fe643d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Fix the ACL requirements for displaying the job details page | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import Route from '@ember/routing/route'; | ||
import { inject as service } from '@ember/service'; | ||
import { collect } from '@ember/object/computed'; | ||
import { | ||
watchRecord, | ||
|
@@ -9,12 +10,20 @@ import { | |
import WithWatchers from 'nomad-ui/mixins/with-watchers'; | ||
|
||
export default class IndexRoute extends Route.extend(WithWatchers) { | ||
@service can; | ||
|
||
async model() { | ||
// Optimizing future node look ups by preemptively loading everything | ||
await this.store.findAll('node'); | ||
return this.modelFor('jobs.job'); | ||
} | ||
|
||
async afterModel(model) { | ||
// Optimizing future node look ups by preemptively loading all nodes if | ||
// necessary and allowed. | ||
if (model && model.get('hasClientStatus') && this.can.can('read client')) { | ||
await this.store.findAll('node'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do users with write access not need this optimization for some reason? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if this is how it works in other projects, but in Nomad ACL system a |
||
} | ||
} | ||
|
||
startWatchers(controller, model) { | ||
if (!model) { | ||
return; | ||
|
@@ -29,7 +38,8 @@ export default class IndexRoute extends Route.extend(WithWatchers) { | |
list: | ||
model.get('hasChildren') && | ||
this.watchAllJobs.perform({ namespace: model.namespace.get('name') }), | ||
nodes: model.get('hasClientStatus') && this.watchNodes.perform(), | ||
nodes: | ||
this.can.can('read client') && model.get('hasClientStatus') && this.watchNodes.perform(), | ||
}); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
{{/if}} | ||
<li data-test-tab="allocations"><LinkTo @route="jobs.job.allocations" @query={{hash namespace=this.job.namespace.id}} @model={{@job}} @activeClass="is-active">Allocations</LinkTo></li> | ||
<li data-test-tab="evaluations"><LinkTo @route="jobs.job.evaluations" @query={{hash namespace=this.job.namespace.id}} @model={{@job}} @activeClass="is-active">Evaluations</LinkTo></li> | ||
{{#if (and this.job.hasClientStatus (not this.job.hasChildren))}} | ||
{{#if (and (can "read client") (and this.job.hasClientStatus (not this.job.hasChildren)))}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem to work for the subnav. Do components inherit property from parents? |
||
<li data-test-tab="clients"><LinkTo @route="jobs.job.clients" @query={{hash namespace=this.job.namespace.id}} @model={{@job}} @activeClass="is-active">Clients</LinkTo></li> | ||
{{/if}} | ||
</ul> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets turn
forceCollapsed
into a reactive getter and then this no longer needs to be a computed property.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I follow.
forcedCollapsed
is an external property that is set by the caller to force the collapse state.isExpanded
is the getter used to set the component state.