Skip to content

Commit

Permalink
ui: fix remaining linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaiWithJai committed Jan 20, 2022
1 parent 2032813 commit cae4bec
Show file tree
Hide file tree
Showing 25 changed files with 426 additions and 353 deletions.
8 changes: 4 additions & 4 deletions ui/app/abilities/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ export default class Client extends AbstractAbility {
get policiesIncludeNodeRead() {
return policiesIncludePermissions(this.get('token.selfTokenPolicies'), [
'read',
'write'
'write',
]);
}

@computed('token.selfTokenPolicies.[]')
get policiesIncludeNodeWrite() {
return policiesIncludePermissions(this.get('token.selfTokenPolicies'), [
'write'
'write',
]);
}
}
Expand All @@ -37,9 +37,9 @@ function policiesIncludePermissions(policies = [], permissions = []) {
// For each policy record, extract the Node policy
const nodePolicies = policies
.toArray()
.map(policy => get(policy, 'rulesJSON.Node.Policy'))
.map((policy) => get(policy, 'rulesJSON.Node.Policy'))
.compact();

// Check for requested permissions
return nodePolicies.some(policy => permissions.includes(policy));
return nodePolicies.some((policy) => permissions.includes(policy));
}
2 changes: 1 addition & 1 deletion ui/app/components/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Trigger extends Component {
this.error = null;
}

@task(function*() {
@task(function* () {
this._reset();
try {
this.result = yield this.args.do();
Expand Down
7 changes: 6 additions & 1 deletion ui/app/controllers/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export default class AllocationsAllocationController extends Controller {
{
title: 'Task Group',
label: allocation.taskGroupName,
args: ['jobs.job.task-group', job.plainId, allocation.taskGroupName, jobQueryParams],
args: [
'jobs.job.task-group',
job.plainId,
allocation.taskGroupName,
jobQueryParams,
],
},
{
title: 'Allocation',
Expand Down
6 changes: 5 additions & 1 deletion ui/app/controllers/allocations/allocation/task.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export default class AllocationsAllocationTaskController extends Controller {
return {
title: 'Task',
label: this.task.get('name'),
args: ['allocations.allocation.task', this.task.get('allocation'), this.task],
args: [
'allocations.allocation.task',
this.task.get('allocation'),
this.task,
],
};
}
}
8 changes: 6 additions & 2 deletions ui/app/controllers/csi/volumes/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ export default class VolumeController extends Controller {
label: 'Volumes',
args: [
'csi.volumes',
qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }),
qpBuilder({
volumeNamespace: volume.get('namespace.name') || 'default',
}),
],
},
{
label: volume.name,
args: [
'csi.volumes.volume',
volume.plainId,
qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }),
qpBuilder({
volumeNamespace: volume.get('namespace.name') || 'default',
}),
],
},
];
Expand Down
4 changes: 1 addition & 3 deletions ui/app/models/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export default class Allocation extends Model {
@attr('string') nodeName;
@computed
get shortNodeId() {
return this.belongsTo('node')
.id()
.split('-')[0];
return this.belongsTo('node').id().split('-')[0];
}

@attr('number') modifyIndex;
Expand Down
2 changes: 1 addition & 1 deletion ui/app/routes/allocations/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class AllocationRoute extends Route.extend(WithWatchers) {
// Preload the job for the allocation since it's required for the breadcrumb trail
return super
.model(...arguments)
.then(allocation =>
.then((allocation) =>
allocation
.get('job')
.then(() => this.store.findAll('namespace')) // namespaces belong to a job and are an asynchronous relationship so we can peak them later on
Expand Down
6 changes: 3 additions & 3 deletions ui/app/routes/csi/volumes/volume.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default class VolumeRoute extends Route.extend(WithWatchers) {
if (!model) return;

controller.set('watchers', {
model: this.watch.perform(model)
model: this.watch.perform(model),
});
}

Expand All @@ -30,9 +30,9 @@ export default class VolumeRoute extends Route.extend(WithWatchers) {
const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']);
return RSVP.hash({
volume: this.store.findRecord('volume', fullId, { reload: true }),
namespaces: this.store.findAll('namespace')
namespaces: this.store.findAll('namespace'),
})
.then(hash => hash.volume)
.then((hash) => hash.volume)
.catch(notifyError(this));
}

Expand Down
8 changes: 4 additions & 4 deletions ui/app/routes/jobs/job/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
watchRecord,
watchRelationship,
watchAll,
watchQuery
watchQuery,
} from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';

Expand Down Expand Up @@ -43,12 +43,12 @@ export default class IndexRoute extends Route.extend(WithWatchers) {
list:
model.job.get('hasChildren') &&
this.watchAllJobs.perform({
namespace: model.job.namespace.get('name')
namespace: model.job.namespace.get('name'),
}),
nodes:
this.can.can('read client') &&
model.job.get('hasClientStatus') &&
this.watchNodes.perform()
this.watchNodes.perform(),
});
}

Expand All @@ -61,7 +61,7 @@ export default class IndexRoute extends Route.extend(WithWatchers) {
) {
controller.setProperties({
sortProperty: 'submitTime',
sortDescending: true
sortDescending: true,
});
}
return super.setupController(...arguments);
Expand Down
6 changes: 3 additions & 3 deletions ui/app/routes/jobs/job/task-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import EmberError from '@ember/error';
import { resolve, all } from 'rsvp';
import {
watchRecord,
watchRelationship
watchRelationship,
} from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
import notifyError from 'nomad-ui/utils/notify-error';
Expand Down Expand Up @@ -34,7 +34,7 @@ export default class TaskGroupRoute extends Route.extend(WithWatchers) {
// Refresh job allocations before-hand (so page sort works on load)
return all([
job.hasMany('allocations').reload(),
job.get('scaleState')
job.get('scaleState'),
]).then(() => taskGroup);
})
.catch(notifyError(this));
Expand All @@ -50,7 +50,7 @@ export default class TaskGroupRoute extends Route.extend(WithWatchers) {
allocations: this.watchAllocations.perform(job),
latestDeployment:
job.get('supportsDeployments') &&
this.watchLatestDeployment.perform(job)
this.watchLatestDeployment.perform(job),
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion ui/app/services/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class BucketService extends Service {
}

@action deregisterBreadcrumb(crumb) {
const newCrumbs = this.crumbs.filter(c => c !== crumb);
const newCrumbs = this.crumbs.filter((c) => c !== crumb);

this.crumbs = newCrumbs;
}
Expand Down
14 changes: 7 additions & 7 deletions ui/app/utils/properties/job-client-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ export default function jobClientStatus(nodesKey, jobKey) {
return computed(
`${nodesKey}.[]`,
`${jobKey}.{datacenters,status,allocations.@each.clientStatus,taskGroups}`,
function() {
function () {
const job = this.get(jobKey);
const nodes = this.get(nodesKey);

// Filter nodes by the datacenters defined in the job.
const filteredNodes = nodes.filter(n => {
const filteredNodes = nodes.filter((n) => {
return job.datacenters.indexOf(n.datacenter) >= 0;
});

Expand All @@ -34,7 +34,7 @@ export default function jobClientStatus(nodesKey, jobKey) {

// Group the job allocations by the ID of the client that is running them.
const allocsByNodeID = {};
job.allocations.forEach(a => {
job.allocations.forEach((a) => {
const nodeId = a.belongsTo('node').id();
if (!allocsByNodeID[nodeId]) {
allocsByNodeID[nodeId] = [];
Expand All @@ -47,7 +47,7 @@ export default function jobClientStatus(nodesKey, jobKey) {
byStatus: {},
totalNodes: filteredNodes.length,
};
filteredNodes.forEach(n => {
filteredNodes.forEach((n) => {
const status = jobStatus(allocsByNodeID[n.id], job.taskGroups.length);
result.byNode[n.id] = status;

Expand All @@ -63,9 +63,9 @@ export default function jobClientStatus(nodesKey, jobKey) {
}

function allQueued(nodes) {
const nodeIDs = nodes.map(n => n.id);
const nodeIDs = nodes.map((n) => n.id);
return {
byNode: Object.fromEntries(nodeIDs.map(id => [id, 'queued'])),
byNode: Object.fromEntries(nodeIDs.map((id) => [id, 'queued'])),
byStatus: canonicalizeStatus({ queued: nodeIDs }),
totalNodes: nodes.length,
};
Expand Down Expand Up @@ -105,7 +105,7 @@ function jobStatus(allocs, expected) {

// Count how many allocations are in each `clientStatus` value.
const summary = allocs
.filter(a => !a.isOld)
.filter((a) => !a.isOld)
.reduce((acc, a) => {
const status = a.clientStatus;
if (!acc[status]) {
Expand Down
Loading

0 comments on commit cae4bec

Please sign in to comment.