diff --git a/.changelog/10893.txt b/.changelog/10893.txt new file mode 100644 index 000000000..ffaf9e19e --- /dev/null +++ b/.changelog/10893.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fixes bug where UI was not detecting namespace-specific capabilities. +``` \ No newline at end of file diff --git a/ui/app/components/task-group-row.js b/ui/app/components/task-group-row.js index 8f01fd05e..57d9e9336 100644 --- a/ui/app/components/task-group-row.js +++ b/ui/app/components/task-group-row.js @@ -19,9 +19,14 @@ export default class TaskGroupRow extends Component { @oneWay('taskGroup.count') count; @alias('taskGroup.job.runningDeployment') runningDeployment; - @computed('runningDeployment') + get namespace() { + return this.get('taskGroup.job.namespace.name'); + } + + @computed('runningDeployment', 'namespace') get tooltipText() { - if (this.can.cannot('scale job')) return "You aren't allowed to scale task groups"; + if (this.can.cannot('scale job', null, { namespace: this.namespace })) + return "You aren't allowed to scale task groups"; if (this.runningDeployment) return 'You cannot scale task groups during a deployment'; return undefined; } diff --git a/ui/app/controllers/jobs/job/task-group.js b/ui/app/controllers/jobs/job/task-group.js index 8a86ddcf8..a85c97d30 100644 --- a/ui/app/controllers/jobs/job/task-group.js +++ b/ui/app/controllers/jobs/job/task-group.js @@ -66,9 +66,10 @@ export default class TaskGroupController extends Controller.extend( }) shouldShowScaleEventTimeline; - @computed('model.job.runningDeployment') + @computed('model.job.{namespace,runningDeployment}') get tooltipText() { - if (this.can.cannot('scale job')) return "You aren't allowed to scale task groups"; + if (this.can.cannot('scale job', null, { namespace: this.model.job.namespace.get('name') })) + return "You aren't allowed to scale task groups"; if (this.model.job.runningDeployment) return 'You cannot scale task groups during a deployment'; return undefined; } diff --git a/ui/app/routes/jobs/run.js b/ui/app/routes/jobs/run.js index ee72d95fb..2111e1334 100644 --- a/ui/app/routes/jobs/run.js +++ b/ui/app/routes/jobs/run.js @@ -15,8 +15,8 @@ export default class RunRoute extends Route { }, ]; - beforeModel() { - if (this.can.cannot('run job')) { + beforeModel(transition) { + if (this.can.cannot('run job', null, { namespace: transition.to.queryParams.namespace })) { this.transitionTo('jobs'); } } diff --git a/ui/app/templates/components/job-version.hbs b/ui/app/templates/components/job-version.hbs index fc219e964..a7076d75f 100644 --- a/ui/app/templates/components/job-version.hbs +++ b/ui/app/templates/components/job-version.hbs @@ -10,7 +10,7 @@
{{#unless this.isCurrent}} - {{#if (can "run job")}} + {{#if (can "run job" namespace=this.version.job.namespace)}}
{{#if (media "isMobile")}}
- {{#if (can "run job")}} - Run Job + {{#if (can "run job" namespace=this.qpNamespace)}} + Run Job {{else}}