open-nomad/ui/app/routes/optimize/summary.js
Buck Doyle 20ec481090
Add DAS subroute and copy button (#9201)
This continues iteration on the DAS UI by adding the ability to directly
navigate to a recommendation summary by (namespaced) slug and a copy
button for the direct navigation link.

It includes a change to CopyButton allowing it to take a block that’s
rendered within the button.

It also changes some instances of multi-relationship traversal to use
in-summary attributes, such as summary.jobNamespace instead of
summary.job.namespace.name.
2020-11-04 12:22:24 -06:00

30 lines
739 B
JavaScript

import Route from '@ember/routing/route';
import notifyError from 'nomad-ui/utils/notify-error';
export default class OptimizeSummaryRoute extends Route {
breadcrumbs(model) {
if (!model) return [];
return [
{
label: model.slug.replace('/', ' / '),
args: ['optimize.summary', model.slug],
},
];
}
async model({ jobNamespace, slug }) {
const model = this.modelFor('optimize').find(
summary => summary.slug === slug && summary.jobNamespace === jobNamespace
);
if (!model) {
const error = new Error(`Unable to find summary for ${slug} in namespace ${jobNamespace}`);
error.code = 404;
notifyError(this)(error);
} else {
return model;
}
}
}