From a27894af46d911298bb2d9f74d1e85b52dd138ba Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 29 Jun 2020 15:53:52 -0700 Subject: [PATCH 1/4] Add tooltips to scaling controls --- ui/app/components/stepper-input.js | 2 +- ui/app/components/task-group-row.js | 10 ++++++++++ ui/app/controllers/jobs/job/task-group.js | 8 ++++++++ ui/app/templates/components/task-group-row.hbs | 4 ++-- ui/app/templates/jobs/job/task-group.hbs | 1 + 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ui/app/components/stepper-input.js b/ui/app/components/stepper-input.js index 871d74729..bded1136e 100644 --- a/ui/app/components/stepper-input.js +++ b/ui/app/components/stepper-input.js @@ -9,7 +9,7 @@ const ESC = 27; @classic @classNames('stepper-input') -@classNameBindings('class', 'disabled:is-disabled') +@classNameBindings('class', 'disabled:is-disabled', 'disabled:tooltip', 'disabled:multiline') export default class StepperInput extends Component { min = 0; max = 10; diff --git a/ui/app/components/task-group-row.js b/ui/app/components/task-group-row.js index 685ea65f6..8f01fd05e 100644 --- a/ui/app/components/task-group-row.js +++ b/ui/app/components/task-group-row.js @@ -1,4 +1,5 @@ import Component from '@ember/component'; +import { inject as service } from '@ember/service'; import { computed, action } from '@ember/object'; import { alias, oneWay } from '@ember/object/computed'; import { debounce } from '@ember/runloop'; @@ -10,12 +11,21 @@ import { lazyClick } from '../helpers/lazy-click'; @tagName('tr') @classNames('task-group-row', 'is-interactive') export default class TaskGroupRow extends Component { + @service can; + taskGroup = null; debounce = 500; @oneWay('taskGroup.count') count; @alias('taskGroup.job.runningDeployment') runningDeployment; + @computed('runningDeployment') + get tooltipText() { + if (this.can.cannot('scale job')) return "You aren't allowed to scale task groups"; + if (this.runningDeployment) return 'You cannot scale task groups during a deployment'; + return undefined; + } + onClick() {} click(event) { diff --git a/ui/app/controllers/jobs/job/task-group.js b/ui/app/controllers/jobs/job/task-group.js index cb6915be0..c780f9722 100644 --- a/ui/app/controllers/jobs/job/task-group.js +++ b/ui/app/controllers/jobs/job/task-group.js @@ -14,6 +14,7 @@ export default class TaskGroupController extends Controller.extend( WithNamespaceResetting ) { @service userSettings; + @service can; queryParams = [ { @@ -50,6 +51,13 @@ export default class TaskGroupController extends Controller.extend( @alias('listSorted') listToSearch; @alias('listSearched') sortedAllocations; + @computed('model.job.runningDeployment') + get tooltipText() { + if (this.can.cannot('scale job')) 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; + } + @action gotoAllocation(allocation) { this.transitionToRoute('allocations.allocation', allocation); diff --git a/ui/app/templates/components/task-group-row.hbs b/ui/app/templates/components/task-group-row.hbs index 3bc7e6b67..c7fd37ec8 100644 --- a/ui/app/templates/components/task-group-row.hbs +++ b/ui/app/templates/components/task-group-row.hbs @@ -8,8 +8,8 @@ {{#if taskGroup.scaling}}
+ class="button-bar is-shadowless is-text bumper-left {{if (or runningDeployment (cannot "scale job")) "tooltip multiline"}}" + aria-label={{tooltipText}}>