diff --git a/ui/admin/app/components/form/worker/create-worker-led/index.hbs b/ui/admin/app/components/form/worker/create-worker-led/index.hbs
index 585cda81d..5b5eb9789 100644
--- a/ui/admin/app/components/form/worker/create-worker-led/index.hbs
+++ b/ui/admin/app/components/form/worker/create-worker-led/index.hbs
@@ -104,7 +104,7 @@
{{/if}}
- {{#if @model.cannotSave}}
+ {{#unless @model.isNew}}
@@ -118,10 +118,14 @@
{{t 'resources.worker.form.steps.3.registered'}}
- {{/if}}
+ {{/unless}}
-
+
{{t 'actions.done'}}
diff --git a/ui/admin/app/routes/scopes/scope/workers.js b/ui/admin/app/routes/scopes/scope/workers.js
index 159609af7..d47bcebdf 100644
--- a/ui/admin/app/routes/scopes/scope/workers.js
+++ b/ui/admin/app/routes/scopes/scope/workers.js
@@ -21,6 +21,18 @@ export default class ScopesScopeWorkersRoute extends Route {
if (!this.session.isAuthenticated) this.router.transitionTo('index');
}
+ /**
+ * Load all workers.
+ * @return {WorkerModel}
+ */
+ model() {
+ const scope = this.modelFor('scopes.scope');
+ const { id: scope_id } = scope;
+ if (this.can.can('list worker', scope, { collection: 'workers' })) {
+ return this.store.query('worker', { scope_id });
+ }
+ }
+
/**
* Refreshes worker data.
*/
diff --git a/ui/admin/app/routes/scopes/scope/workers/index.js b/ui/admin/app/routes/scopes/scope/workers/index.js
index 56a333f92..61b3b33e4 100644
--- a/ui/admin/app/routes/scopes/scope/workers/index.js
+++ b/ui/admin/app/routes/scopes/scope/workers/index.js
@@ -1,16 +1,18 @@
import Route from '@ember/routing/route';
import { action } from '@ember/object';
import { resourceFilter } from 'core/decorators/resource-filter';
-import { inject as service } from '@ember/service';
export default class ScopesScopeWorkersIndexRoute extends Route {
// =attributes
- @service can;
+ // This resource filter depends on the data from the list route so can't
+ // live in the same model where the list is loaded as it needs to get loaded
+ // first. If it's in the same file it might try to grab the model data before
+ // it's loaded.
@resourceFilter({
allowed: (route) => {
const configTags = route
- .modelFor('scopes.scope.workers.index')
+ .modelFor('scopes.scope.workers')
.toArray()
.flatMap((worker) => worker.config_tags?.type)
.filter(Boolean);
@@ -18,30 +20,25 @@ export default class ScopesScopeWorkersIndexRoute extends Route {
// Filter out duplicate tags
return [...new Set(configTags)];
},
+ refreshRouteOnChange: false,
})
tags;
// =methods
model() {
- const scope = this.modelFor('scopes.scope');
- const { id: scope_id } = scope;
- if (this.can.can('list worker', scope, { collection: 'workers' })) {
- const workers = this.store.query('worker', { scope_id });
+ const workers = this.modelFor('scopes.scope.workers');
- if (this.tags?.length) {
- // Return workers that have config tags that have at
- // least one intersection with the filter tags
- return workers.filter(
- (worker) =>
- worker.config_tags?.type.filter(
- Set.prototype.has,
- new Set(this.tags)
- ).length > 0
- );
- }
- return workers;
+ if (this.tags?.length) {
+ // Return workers that have config tags that have at
+ // least one intersection with the filter tags
+ return workers.filter(
+ (worker) =>
+ worker.config_tags.type.filter(Set.prototype.has, new Set(this.tags))
+ .length > 0
+ );
}
+ return workers;
}
/**
@@ -50,6 +47,7 @@ export default class ScopesScopeWorkersIndexRoute extends Route {
@action
clearAllFilters() {
this.tags = [];
+ this.refresh();
}
/**
@@ -60,6 +58,7 @@ export default class ScopesScopeWorkersIndexRoute extends Route {
@action
filterBy(field, value) {
this[field] = value;
+ this.refresh();
}
setupController(controller) {