2020-03-25 12:51:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { collect } from '@ember/object/computed';
|
|
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
|
|
|
import { qpBuilder } from 'nomad-ui/utils/classes/query-params';
|
|
|
|
import { watchRecord } from 'nomad-ui/utils/properties/watch';
|
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2020-06-22 15:48:53 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-22 15:48:53 +00:00
|
|
|
@classic
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class VolumeRoute extends Route.extend(WithWatchers) {
|
|
|
|
@service store;
|
|
|
|
@service system;
|
2020-03-25 12:51:26 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
breadcrumbs = volume => [
|
2020-03-25 12:51:26 +00:00
|
|
|
{
|
|
|
|
label: 'Volumes',
|
|
|
|
args: [
|
|
|
|
'csi.volumes',
|
|
|
|
qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: volume.name,
|
|
|
|
args: [
|
|
|
|
'csi.volumes.volume',
|
|
|
|
volume.plainId,
|
|
|
|
qpBuilder({ volumeNamespace: volume.get('namespace.name') || 'default' }),
|
|
|
|
],
|
|
|
|
},
|
2020-06-10 13:49:16 +00:00
|
|
|
];
|
2020-03-25 12:51:26 +00:00
|
|
|
|
|
|
|
startWatchers(controller, model) {
|
|
|
|
if (!model) return;
|
|
|
|
|
|
|
|
controller.set('watchers', {
|
|
|
|
model: this.watch.perform(model),
|
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-03-25 12:51:26 +00:00
|
|
|
|
|
|
|
serialize(model) {
|
|
|
|
return { volume_name: model.get('plainId') };
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-03-25 12:51:26 +00:00
|
|
|
|
|
|
|
model(params, transition) {
|
|
|
|
const namespace = transition.to.queryParams.namespace || this.get('system.activeNamespace.id');
|
|
|
|
const name = params.volume_name;
|
|
|
|
const fullId = JSON.stringify([`csi/${name}`, namespace || 'default']);
|
|
|
|
return this.store.findRecord('volume', fullId, { reload: true }).catch(notifyError(this));
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2020-03-25 12:51:26 +00:00
|
|
|
|
|
|
|
// Since volume includes embedded records for allocations,
|
|
|
|
// it's possible that allocations that are server-side deleted may
|
|
|
|
// not be removed from the UI while sitting on the volume detail page.
|
2020-06-10 13:49:16 +00:00
|
|
|
@watchRecord('volume') watch;
|
|
|
|
@collect('watch') watchers;
|
|
|
|
}
|