From 3bdf6613efa7b063a7d04a717985c74f2876ed95 Mon Sep 17 00:00:00 2001 From: Jai Bhagat Date: Fri, 17 Dec 2021 11:29:36 -0500 Subject: [PATCH] refact: clean-up breadcrumb invocations --- .../allocations/allocation/task.js | 20 +++++----- ui/app/controllers/clients.js | 7 ---- ui/app/controllers/clients/client.js | 20 +++++----- ui/app/controllers/csi/plugins.js | 7 ---- ui/app/controllers/csi/plugins/plugin.js | 10 +++-- ui/app/controllers/csi/volumes.js | 7 ---- ui/app/controllers/csi/volumes/volume.js | 6 ++- ui/app/controllers/jobs.js | 10 +---- ui/app/controllers/jobs/job.js | 4 +- ui/app/controllers/jobs/job/dispatch.js | 10 +---- ui/app/controllers/jobs/job/task-group.js | 40 ++++++++++--------- ui/app/controllers/jobs/run.js | 7 ---- ui/app/controllers/optimize.js | 7 ---- ui/app/controllers/optimize/summary.js | 18 ++++----- ui/app/controllers/servers.js | 7 ---- ui/app/controllers/servers/server.js | 8 ---- ui/app/controllers/topology.js | 7 ---- .../templates/allocations/allocation/task.hbs | 5 +-- ui/app/templates/clients.hbs | 4 +- ui/app/templates/clients/client.hbs | 5 +-- ui/app/templates/csi/plugins.hbs | 5 +-- ui/app/templates/csi/volumes.hbs | 5 +-- ui/app/templates/jobs.hbs | 4 +- ui/app/templates/jobs/job.hbs | 5 +-- ui/app/templates/jobs/job/dispatch.hbs | 4 +- ui/app/templates/jobs/job/task-group.hbs | 4 +- ui/app/templates/jobs/run.hbs | 4 +- ui/app/templates/optimize.hbs | 4 +- ui/app/templates/optimize/summary.hbs | 8 +--- ui/app/templates/servers.hbs | 4 +- ui/app/templates/servers/server.hbs | 5 ++- ui/app/templates/topology.hbs | 2 +- 32 files changed, 87 insertions(+), 176 deletions(-) diff --git a/ui/app/controllers/allocations/allocation/task.js b/ui/app/controllers/allocations/allocation/task.js index 1fefdd66c5a..3e3c9a0343b 100644 --- a/ui/app/controllers/allocations/allocation/task.js +++ b/ui/app/controllers/allocations/allocation/task.js @@ -1,15 +1,15 @@ import Controller from '@ember/controller'; export default class AllocationsAllocationTaskController extends Controller { - get breadcrumbs() { - const model = this.model; - if (!model) return []; - return [ - { - title: 'Task', - label: model.get('name'), - args: ['allocations.allocation.task', model.get('allocation'), model], - }, - ]; + get task() { + return this.model; + } + + get breadcrumb() { + return { + title: 'Task', + label: this.task.get('name'), + args: ['allocations.allocation.task', this.task.get('allocation'), this.task], + }; } } diff --git a/ui/app/controllers/clients.js b/ui/app/controllers/clients.js index 12f209399c9..673868f9b58 100644 --- a/ui/app/controllers/clients.js +++ b/ui/app/controllers/clients.js @@ -2,11 +2,4 @@ import Controller from '@ember/controller'; export default class ClientsController extends Controller { isForbidden = false; - - breadcrumbs = [ - { - label: 'Clients', - args: ['clients.index'], - }, - ]; } diff --git a/ui/app/controllers/clients/client.js b/ui/app/controllers/clients/client.js index e13e1e9c19b..d13eb42be7b 100644 --- a/ui/app/controllers/clients/client.js +++ b/ui/app/controllers/clients/client.js @@ -1,15 +1,15 @@ import Controller from '@ember/controller'; export default class ClientsClientController extends Controller { - get breadcrumbs() { - const model = this.model; - if (!model) return []; - return [ - { - title: 'Client', - label: model.get('shortId'), - args: ['clients.client', model.get('id')], - }, - ]; + get client() { + return this.model; + } + + get breadcrumb() { + return { + title: 'Client', + label: this.client.get('shortId'), + args: ['clients.client', this.client.get('id')], + }; } } diff --git a/ui/app/controllers/csi/plugins.js b/ui/app/controllers/csi/plugins.js index d18af07be15..b9a8c5a5415 100644 --- a/ui/app/controllers/csi/plugins.js +++ b/ui/app/controllers/csi/plugins.js @@ -2,11 +2,4 @@ import Controller from '@ember/controller'; export default class PluginsController extends Controller { isForbidden = false; - - breadcrumbs = [ - { - label: 'Storage', - args: ['csi.index'], - }, - ]; } diff --git a/ui/app/controllers/csi/plugins/plugin.js b/ui/app/controllers/csi/plugins/plugin.js index 67f11a4216e..d82e83f7f0d 100644 --- a/ui/app/controllers/csi/plugins/plugin.js +++ b/ui/app/controllers/csi/plugins/plugin.js @@ -1,16 +1,20 @@ import Controller from '@ember/controller'; export default class CsiPluginsPluginController extends Controller { + get plugin() { + return this.model; + } + get breadcrumbs() { - const plugin = this.model; + const { plainId } = this.plugin; return [ { label: 'Plugins', args: ['csi.plugins'], }, { - label: plugin.plainId, - args: ['csi.plugins.plugin', plugin.plainId], + label: plainId, + args: ['csi.plugins.plugin', plainId], }, ]; } diff --git a/ui/app/controllers/csi/volumes.js b/ui/app/controllers/csi/volumes.js index ca6e80148e2..1eb7ecfecdb 100644 --- a/ui/app/controllers/csi/volumes.js +++ b/ui/app/controllers/csi/volumes.js @@ -2,11 +2,4 @@ import Controller from '@ember/controller'; export default class VolumesController extends Controller { isForbidden = false; - - breadcrumbs = [ - { - label: 'Storage', - args: ['csi.index'], - }, - ]; } diff --git a/ui/app/controllers/csi/volumes/volume.js b/ui/app/controllers/csi/volumes/volume.js index 735700e4a6d..c151e5dec63 100644 --- a/ui/app/controllers/csi/volumes/volume.js +++ b/ui/app/controllers/csi/volumes/volume.js @@ -14,8 +14,12 @@ export default class VolumeController extends Controller { ]; volumeNamespace = 'default'; + get volume() { + return this.model; + } + get breadcrumbs() { - const volume = this.model; + const volume = this.volume; return [ { label: 'Volumes', diff --git a/ui/app/controllers/jobs.js b/ui/app/controllers/jobs.js index 5fbfeede25d..77b1678a439 100644 --- a/ui/app/controllers/jobs.js +++ b/ui/app/controllers/jobs.js @@ -1,10 +1,4 @@ import Controller from '@ember/controller'; -export default class JobsController extends Controller { - breadcrumbs = [ - { - label: 'Jobs', - args: ['jobs.index'], - }, - ]; -} +// The WithNamespaceResetting Mixin uses Controller Injection and requires us to keep this controller around +export default class JobsController extends Controller {} diff --git a/ui/app/controllers/jobs/job.js b/ui/app/controllers/jobs/job.js index 17e726db491..93c96493ea7 100644 --- a/ui/app/controllers/jobs/job.js +++ b/ui/app/controllers/jobs/job.js @@ -8,7 +8,7 @@ export default class JobController extends Controller { ]; jobNamespace = 'default'; - get breadcrumbs() { - return [{ type: 'job', job: this.model }]; + get job() { + return this.model; } } diff --git a/ui/app/controllers/jobs/job/dispatch.js b/ui/app/controllers/jobs/job/dispatch.js index e2145103f42..7498f649ab6 100644 --- a/ui/app/controllers/jobs/job/dispatch.js +++ b/ui/app/controllers/jobs/job/dispatch.js @@ -1,10 +1,4 @@ import Controller from '@ember/controller'; -export default class JobsJobDispatchController extends Controller { - breadcrumbs = [ - { - label: 'Dispatch', - args: ['jobs.job.dispatch'], - }, - ]; -} +// This may be safe to remove but we can't be sure, some route may try access this directly using this.controllerFor +export default class JobsJobDispatchController extends Controller {} diff --git a/ui/app/controllers/jobs/job/task-group.js b/ui/app/controllers/jobs/job/task-group.js index a25f3b139e3..3cb6efe3477 100644 --- a/ui/app/controllers/jobs/job/task-group.js +++ b/ui/app/controllers/jobs/job/task-group.js @@ -14,10 +14,10 @@ import classic from 'ember-classic-decorator'; @classic export default class TaskGroupController extends Controller.extend( - Sortable, - Searchable, - WithNamespaceResetting - ) { + Sortable, + Searchable, + WithNamespaceResetting +) { @service userSettings; @service can; @@ -142,20 +142,22 @@ export default class TaskGroupController extends Controller.extend( setFacetQueryParam(queryParam, selection) { this.set(queryParam, serialize(selection)); } - get breadcrumbs() { - const model = this.model; - if (!model) return []; - return [ - { - title: 'Task Group', - label: model.get('name'), - args: [ - 'jobs.job.task-group', - model.get('job'), - model.get('name'), - qpBuilder({ jobNamespace: model.get('job.namespace.name') || 'default' }), - ], - }, - ]; + + get taskGroup() { + return this.model; + } + + get breadcrumb() { + const { job, name } = this.taskGroup; + return { + title: 'Task Group', + label: name, + args: [ + 'jobs.job.task-group', + job, + name, + qpBuilder({ jobNamespace: job.get('namespace.name') || 'default' }), + ], + }; } } diff --git a/ui/app/controllers/jobs/run.js b/ui/app/controllers/jobs/run.js index 0ad8722dc02..5921713017c 100644 --- a/ui/app/controllers/jobs/run.js +++ b/ui/app/controllers/jobs/run.js @@ -1,13 +1,6 @@ import Controller from '@ember/controller'; export default class RunController extends Controller { - breadcrumbs = [ - { - label: 'Run', - args: ['jobs.run'], - }, - ]; - onSubmit(id, namespace) { this.transitionToRoute('jobs.job', id, { queryParams: { namespace }, diff --git a/ui/app/controllers/optimize.js b/ui/app/controllers/optimize.js index 94542b1db95..b5c438a99fc 100644 --- a/ui/app/controllers/optimize.js +++ b/ui/app/controllers/optimize.js @@ -102,13 +102,6 @@ export default class OptimizeController extends Controller { { key: 'dead', label: 'Dead' }, ]; - breadcrumbs = [ - { - label: 'Recommendations', - args: ['optimize'], - }, - ]; - get optionsDatacenter() { const flatten = (acc, val) => acc.concat(val); const allDatacenters = new Set(this.summaries.mapBy('job.datacenters').reduce(flatten, [])); diff --git a/ui/app/controllers/optimize/summary.js b/ui/app/controllers/optimize/summary.js index 204730e98d2..986dede450d 100644 --- a/ui/app/controllers/optimize/summary.js +++ b/ui/app/controllers/optimize/summary.js @@ -10,15 +10,15 @@ export default class OptimizeSummaryController extends Controller { }, ]; - get breadcrumbs() { - const model = this.model; - if (!model) return []; + get summary() { + return this.model; + } - return [ - { - label: model.slug.replace('/', ' / '), - args: ['optimize.summary', model.slug], - }, - ]; + get breadcrumb() { + const { slug } = this.summary; + return { + label: slug.replace('/', ' / '), + args: ['optimize.summary', slug], + }; } } diff --git a/ui/app/controllers/servers.js b/ui/app/controllers/servers.js index bf61fed66f7..aa0b590ba7e 100644 --- a/ui/app/controllers/servers.js +++ b/ui/app/controllers/servers.js @@ -2,11 +2,4 @@ import Controller from '@ember/controller'; export default class ServersController extends Controller { isForbidden = false; - - breadcrumbs = [ - { - label: 'Servers', - args: ['servers.index'], - }, - ]; } diff --git a/ui/app/controllers/servers/server.js b/ui/app/controllers/servers/server.js index e01310c1a54..81a3d406278 100644 --- a/ui/app/controllers/servers/server.js +++ b/ui/app/controllers/servers/server.js @@ -4,12 +4,4 @@ export default class ServersServerController extends Controller { get server() { return this.model; } - - get breadcrumb() { - return { - title: 'Server', - label: this.server.name, - args: ['servers.server', this.server.id], - }; - } } diff --git a/ui/app/controllers/topology.js b/ui/app/controllers/topology.js index a16d411d4fb..4b9a38b060e 100644 --- a/ui/app/controllers/topology.js +++ b/ui/app/controllers/topology.js @@ -143,11 +143,4 @@ export default class TopologyControllers extends Controller { this.filteredNodes = filteredNodesError.context; } } - - get breadcrumb() { - return { - label: 'Topology', - args: ['topology'], - }; - } } diff --git a/ui/app/templates/allocations/allocation/task.hbs b/ui/app/templates/allocations/allocation/task.hbs index 0915a337c5c..2cb65188614 100644 --- a/ui/app/templates/allocations/allocation/task.hbs +++ b/ui/app/templates/allocations/allocation/task.hbs @@ -1,4 +1 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} -{{outlet}} \ No newline at end of file +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/clients.hbs b/ui/app/templates/clients.hbs index 82ed74cdcf9..4da9ce68a00 100644 --- a/ui/app/templates/clients.hbs +++ b/ui/app/templates/clients.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{outlet}} \ No newline at end of file diff --git a/ui/app/templates/clients/client.hbs b/ui/app/templates/clients/client.hbs index 0915a337c5c..2cb65188614 100644 --- a/ui/app/templates/clients/client.hbs +++ b/ui/app/templates/clients/client.hbs @@ -1,4 +1 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} -{{outlet}} \ No newline at end of file +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/csi/plugins.hbs b/ui/app/templates/csi/plugins.hbs index 0915a337c5c..1d511b7a813 100644 --- a/ui/app/templates/csi/plugins.hbs +++ b/ui/app/templates/csi/plugins.hbs @@ -1,4 +1 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} -{{outlet}} \ No newline at end of file +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/csi/volumes.hbs b/ui/app/templates/csi/volumes.hbs index 0915a337c5c..1d511b7a813 100644 --- a/ui/app/templates/csi/volumes.hbs +++ b/ui/app/templates/csi/volumes.hbs @@ -1,4 +1 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} -{{outlet}} \ No newline at end of file +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/jobs.hbs b/ui/app/templates/jobs.hbs index 82ed74cdcf9..f2c9986c752 100644 --- a/ui/app/templates/jobs.hbs +++ b/ui/app/templates/jobs.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{outlet}} \ No newline at end of file diff --git a/ui/app/templates/jobs/job.hbs b/ui/app/templates/jobs/job.hbs index 0915a337c5c..ba9c71856e9 100644 --- a/ui/app/templates/jobs/job.hbs +++ b/ui/app/templates/jobs/job.hbs @@ -1,4 +1 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} -{{outlet}} \ No newline at end of file +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/jobs/job/dispatch.hbs b/ui/app/templates/jobs/job/dispatch.hbs index 2387f0af060..6252aa206ec 100644 --- a/ui/app/templates/jobs/job/dispatch.hbs +++ b/ui/app/templates/jobs/job/dispatch.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{page-title "Dispatch new " this.model.name}}
diff --git a/ui/app/templates/jobs/job/task-group.hbs b/ui/app/templates/jobs/job/task-group.hbs index ee56ba4b02b..dd95b32e0a9 100644 --- a/ui/app/templates/jobs/job/task-group.hbs +++ b/ui/app/templates/jobs/job/task-group.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{page-title "Task group " this.model.name " - Job " this.model.job.name}}
    diff --git a/ui/app/templates/jobs/run.hbs b/ui/app/templates/jobs/run.hbs index 89e14da8280..7bb74880bc6 100644 --- a/ui/app/templates/jobs/run.hbs +++ b/ui/app/templates/jobs/run.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{page-title "Run a job"}}
    diff --git a/ui/app/templates/optimize.hbs b/ui/app/templates/optimize.hbs index 35c289fc6d3..5e1795c15a0 100644 --- a/ui/app/templates/optimize.hbs +++ b/ui/app/templates/optimize.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} +
    {{#if this.summaries}} diff --git a/ui/app/templates/optimize/summary.hbs b/ui/app/templates/optimize/summary.hbs index f84fa9366ae..bb0e7100365 100644 --- a/ui/app/templates/optimize/summary.hbs +++ b/ui/app/templates/optimize/summary.hbs @@ -1,6 +1,2 @@ -{{#if @model}} - -{{/if}} \ No newline at end of file + + \ No newline at end of file diff --git a/ui/app/templates/servers.hbs b/ui/app/templates/servers.hbs index 82ed74cdcf9..d90af14eec3 100644 --- a/ui/app/templates/servers.hbs +++ b/ui/app/templates/servers.hbs @@ -1,6 +1,4 @@ -{{#each this.breadcrumbs as |crumb|}} - -{{/each}} + {{outlet}} \ No newline at end of file diff --git a/ui/app/templates/servers/server.hbs b/ui/app/templates/servers/server.hbs index 2cb65188614..29449f35863 100644 --- a/ui/app/templates/servers/server.hbs +++ b/ui/app/templates/servers/server.hbs @@ -1 +1,4 @@ -{{outlet}} \ No newline at end of file + +{{outlet}} \ No newline at end of file diff --git a/ui/app/templates/topology.hbs b/ui/app/templates/topology.hbs index e2d060fa343..a95d57d0808 100644 --- a/ui/app/templates/topology.hbs +++ b/ui/app/templates/topology.hbs @@ -1,4 +1,4 @@ - + {{page-title "Cluster Topology"}}