Skip to content
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: authorization bug for job-client-status-summary #11780

Merged
merged 37 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
74bc21e
ui: prepare rebase for contextual job-page
ChaiWithJai Jan 24, 2022
4d93ca6
fix: remove sourceMaps false in ember-cli-build
ChaiWithJai Jan 3, 2022
184bc11
feat: create job-page contextual component
ChaiWithJai Jan 3, 2022
9613d16
refact: job-page/system template to use contextual components
ChaiWithJai Jan 3, 2022
a8888cd
refact: job-page/sysbatch template to use contextual components
ChaiWithJai Jan 3, 2022
6465090
refact: job-page/service template to use contextual components
ChaiWithJai Jan 3, 2022
0fb0ad3
refact: job-page/periodic template to use contextual components
ChaiWithJai Jan 3, 2022
c3b8811
refact: job-page/periodic-child template to use contextual components
ChaiWithJai Jan 3, 2022
e40fab4
refact: job-page/parameterized template to use contextual components
ChaiWithJai Jan 3, 2022
4076e26
refact: job-page/parameterized-child template to use contextual comp…
ChaiWithJai Jan 3, 2022
4aa035b
refact: job-page/batch template to use contextual components
ChaiWithJai Jan 3, 2022
dec6a68
refact: remove unused backing component classes and extend periodic …
ChaiWithJai Jan 3, 2022
204cbea
refact: move conditional rendering logic from job-page to job-client…
ChaiWithJai Jan 3, 2022
8c2ce12
refactor: compute jobClientStatus in summary backing class component
ChaiWithJai Jan 3, 2022
6f2e16c
chore: prettify task-groups template
ChaiWithJai Jan 3, 2022
4327589
refact: move gotoTaskGroup action to component
ChaiWithJai Jan 3, 2022
da2f574
chore: prettify job-row template
ChaiWithJai Jan 3, 2022
6bbcc10
chore: prettify jobs index template
ChaiWithJai Jan 3, 2022
2979538
chore: prettify children template
ChaiWithJai Jan 3, 2022
6b26fe8
chore: prettify job/index controller
ChaiWithJai Jan 3, 2022
9f1d225
refact: move gotoJob to component
ChaiWithJai Jan 3, 2022
d64df8b
fix: router expect identifier instead of model for trans to job page
ChaiWithJai Jan 3, 2022
2778fa1
fix: remove debugger
ChaiWithJai Jan 3, 2022
1a9b706
refact: move gotoClients logic down to component
ChaiWithJai Jan 3, 2022
0eff35d
ui: add "read client" ability
lgfa29 Dec 13, 2021
1751f5b
fix: move node loading to jobs.job route and add auth logic
ChaiWithJai Jan 5, 2022
c423bfe
fix: update conditional rendering of clients tab
ChaiWithJai Jan 5, 2022
ecbc327
fix: update component props for glimmer syntax
ChaiWithJai Jan 5, 2022
e634a41
fix: prevent async request for node relationship on alloc
ChaiWithJai Jan 5, 2022
e536e80
feat: add conditional rendering logic to template for not auth concern
ChaiWithJai Jan 5, 2022
55d1dbb
fix: protect route if not auth
ChaiWithJai Jan 5, 2022
3de0a88
fix: auth node requests with mirage
ChaiWithJai Jan 5, 2022
b72bf6f
test: add tests for not auth behavior for job-client-status-summary
ChaiWithJai Jan 5, 2022
de0ac15
fix: no longer need gotoTaskGroup prop
ChaiWithJai Jan 5, 2022
c1bb21d
ui: prettify remaining files
ChaiWithJai Jan 26, 2022
6c65966
refact: fix tests after contextual job page changes
ChaiWithJai Jan 26, 2022
8d8fe0b
refact: extract setPolicy into utils
ChaiWithJai Jan 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions ui/app/components/job-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import messageForError from 'nomad-ui/utils/message-from-adapter-error';

export default class JobPage extends Component {
@tracked errorMessage = null;

@action
clearErrorMessage() {
this.errorMessage = null;
}

@action
handleError(errorObject) {
this.errorMessage = errorObject;
}

@action
setError(err) {
this.errorMessage = {
title: 'Could Not Force Launch',
description: messageForError(err, 'submit jobs'),
};
}
}
37 changes: 0 additions & 37 deletions ui/app/components/job-page/abstract.js

This file was deleted.

5 changes: 0 additions & 5 deletions ui/app/components/job-page/batch.js

This file was deleted.

6 changes: 2 additions & 4 deletions ui/app/components/job-page/parameterized-child.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import PeriodicChildJobPage from './periodic-child';
import classic from 'ember-classic-decorator';
import Component from '@glimmer/component';

@classic
export default class ParameterizedChild extends PeriodicChildJobPage {
export default class ParameterizedChild extends Component {
@alias('job.decodedPayload') payload;

@computed('payload')
Expand Down
5 changes: 0 additions & 5 deletions ui/app/components/job-page/parameterized.js

This file was deleted.

3 changes: 0 additions & 3 deletions ui/app/components/job-page/parts/children.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export default class Children extends Component.extend(Sortable) {
sortDescending = null;
currentPage = null;

// Provide an action with access to the router
gotoJob() {}

@readOnly('userSettings.pageSize') pageSize;

@computed('job.taskGroups.[]')
Expand Down
29 changes: 21 additions & 8 deletions ui/app/components/job-page/parts/job-client-status-summary.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
import Component from '@ember/component';
import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { classNames } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
import jobClientStatus from 'nomad-ui/utils/properties/job-client-status';

@classic
@classNames('boxed-section')
export default class JobClientStatusSummary extends Component {
@service router;
@service store;

@jobClientStatus('nodes', 'job') jobClientStatus;

get nodes() {
return this.store.peekAll('node');
}

job = null;
nodes = null;
forceCollapsed = false;
gotoClients() {}

@computed('forceCollapsed')
get isExpanded() {
if (this.forceCollapsed) return false;
@action
gotoClients(statusFilter) {
this.router.transitionTo('jobs.job.clients', this.job, {
queryParams: {
status: JSON.stringify(statusFilter),
namespace: this.job.get('namespace.name'),
},
});
}

@computed
get isExpanded() {
const storageValue = window.localStorage.nomadExpandJobClientStatusSummary;
return storageValue != null ? JSON.parse(storageValue) : true;
}

@jobClientStatus('nodes', 'job') jobClientStatus;

@action
onSliceClick(ev, slice) {
/* eslint-disable-next-line ember/no-string-prototype-extensions */
Expand Down
11 changes: 8 additions & 3 deletions ui/app/components/job-page/parts/task-groups.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { action, computed } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
import Sortable from 'nomad-ui/mixins/sortable';
import { classNames } from '@ember-decorators/component';
Expand All @@ -8,14 +9,18 @@ import classic from 'ember-classic-decorator';
@classic
@classNames('boxed-section')
export default class TaskGroups extends Component.extend(Sortable) {
@service router;

job = null;

// Provide a value that is bound to a query param
sortProperty = null;
sortDescending = null;

// Provide an action with access to the router
gotoTaskGroup() {}
@action
gotoTaskGroup(taskGroup) {
this.router.transitionTo('jobs.job.task-group', this.job, taskGroup);
}

@computed('job.taskGroups.[]')
get taskGroups() {
Expand Down
24 changes: 0 additions & 24 deletions ui/app/components/job-page/periodic-child.js

This file was deleted.

26 changes: 5 additions & 21 deletions ui/app/components/job-page/periodic.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
import AbstractJobPage from './abstract';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import classic from 'ember-classic-decorator';
import messageForError from 'nomad-ui/utils/message-from-adapter-error';

@classic
export default class Periodic extends AbstractJobPage {
@service store;

errorMessage = null;
import Component from '@glimmer/component';

export default class Periodic extends Component {
@action
forceLaunch() {
this.job.forcePeriodic().catch((err) => {
this.set('errorMessage', {
title: 'Could Not Force Launch',
description: messageForError(err, 'submit jobs'),
});
forceLaunch(setError) {
this.args.job.forcePeriodic().catch((err) => {
setError(err);
});
}

@action
clearErrorMessage() {
this.set('errorMessage', null);
}
}
5 changes: 0 additions & 5 deletions ui/app/components/job-page/service.js

This file was deleted.

5 changes: 0 additions & 5 deletions ui/app/components/job-page/sysbatch.js

This file was deleted.

5 changes: 0 additions & 5 deletions ui/app/components/job-page/system.js

This file was deleted.

18 changes: 13 additions & 5 deletions ui/app/components/job-row.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { lazyClick } from '../helpers/lazy-click';
import { classNames, tagName } from '@ember-decorators/component';
import classic from 'ember-classic-decorator';
Expand All @@ -8,18 +9,25 @@ import classic from 'ember-classic-decorator';
@tagName('tr')
@classNames('job-row', 'is-interactive')
export default class JobRow extends Component {
@service system;
@service router;
@service store;
@service system;

job = null;

// One of independent, parent, or child. Used to customize the template
// based on the relationship of this job to others.
context = 'independent';

onClick() {}

click(event) {
lazyClick([this.onClick, event]);
lazyClick([this.gotoJob, event]);
}

@action
gotoJob() {
const { job } = this;
this.router.transitionTo('jobs.job', job.plainId, {
queryParams: { namespace: job.get('namespace.name') },
});
}
}
16 changes: 12 additions & 4 deletions ui/app/components/job-subnav.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import Component from '@ember/component';
import { tagName } from '@ember-decorators/component';
import { inject as service } from '@ember/service';
import Component from '@glimmer/component';

@tagName('')
export default class JobSubnav extends Component {}
export default class JobSubnav extends Component {
@service can;

get shouldRenderClientsTab() {
const { job } = this.args;
return (
job?.hasClientStatus && !job?.hasChildren && this.can.can('read client')
);
}
}
2 changes: 0 additions & 2 deletions ui/app/components/list-accordion/accordion-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ export default class AccordionHead extends Component {
'data-test-accordion-head' = true;

buttonLabel = 'toggle';
tooltip = '';
isOpen = false;
isExpandable = true;
isDisabled = false;
item = null;

onClose() {}
Expand Down
7 changes: 0 additions & 7 deletions ui/app/controllers/jobs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,4 @@ export default class IndexController extends Controller.extend(
setFacetQueryParam(queryParam, selection) {
this.set(queryParam, serialize(selection));
}

@action
gotoJob(job) {
this.transitionToRoute('jobs.job', job.get('plainId'), {
queryParams: { namespace: job.get('namespace.name') },
});
}
}
4 changes: 1 addition & 3 deletions ui/app/controllers/jobs/job/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ export default class ClientsController extends Controller.extend(

@computed('store')
get allNodes() {
return this.store.peekAll('node').length
? this.store.peekAll('node')
: this.store.findAll('node');
return this.store.peekAll('node');
}

@computed('allNodes', 'jobClientStatus.byNode')
Expand Down
41 changes: 3 additions & 38 deletions ui/app/controllers/jobs/job/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
import Controller from '@ember/controller';
import { alias } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
import { action } from '@ember/object';
import classic from 'ember-classic-decorator';

@classic
Expand All @@ -25,42 +24,8 @@ export default class IndexController extends Controller.extend(

currentPage = 1;

@computed('model.job')
get job() {
return this.model.job;
}

@computed('model.nodes.[]')
get nodes() {
return this.model.nodes;
}
@alias('model') job;

sortProperty = 'name';
sortDescending = false;

@action
gotoTaskGroup(taskGroup) {
this.transitionToRoute(
'jobs.job.task-group',
taskGroup.get('job'),
taskGroup
);
}

@action
gotoJob(job) {
this.transitionToRoute('jobs.job', job, {
queryParams: { jobNamespace: job.get('namespace.name') },
});
}

@action
gotoClients(statusFilter) {
this.transitionToRoute('jobs.job.clients', this.job, {
queryParams: {
status: JSON.stringify(statusFilter),
namespace: this.job.get('namespace.name'),
},
});
}
}
Loading