Remove namespace cache (#13679)
This commit is contained in:
parent
fc4cd53cfb
commit
59c12fc758
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
ui: Namespace filter query paramters are now isolated by route
|
||||
```
|
|
@ -1,4 +1,3 @@
|
|||
import { set } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { action, computed } from '@ember/object';
|
||||
import { alias, readOnly } from '@ember/object/computed';
|
||||
|
@ -64,7 +63,7 @@ export default class IndexController extends Controller.extend(
|
|||
|
||||
fuzzySearchEnabled = true;
|
||||
|
||||
@computed('qpNamespace', 'model.namespaces.[]', 'system.cachedNamespace')
|
||||
@computed('qpNamespace', 'model.namespaces.[]')
|
||||
get optionsNamespaces() {
|
||||
const availableNamespaces = this.model.namespaces.map((namespace) => ({
|
||||
key: namespace.name,
|
||||
|
@ -81,7 +80,7 @@ export default class IndexController extends Controller.extend(
|
|||
// eslint-disable-next-line ember/no-incorrect-calls-with-inline-anonymous-functions
|
||||
scheduleOnce('actions', () => {
|
||||
// eslint-disable-next-line ember/no-side-effects
|
||||
this.set('qpNamespace', this.system.cachedNamespace || '*');
|
||||
this.set('qpNamespace', '*');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -101,11 +100,6 @@ export default class IndexController extends Controller.extend(
|
|||
@alias('listSorted') listToSearch;
|
||||
@alias('listSearched') sortedVolumes;
|
||||
|
||||
@action
|
||||
cacheNamespace(namespace) {
|
||||
set(this, 'system.cachedNamespace', namespace);
|
||||
}
|
||||
|
||||
setFacetQueryParam(queryParam, selection) {
|
||||
this.set(queryParam, serialize(selection));
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/* eslint-disable ember/no-incorrect-calls-with-inline-anonymous-functions */
|
||||
import { set } from '@ember/object';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { alias, readOnly } from '@ember/object/computed';
|
||||
import Controller from '@ember/controller';
|
||||
import { action, computed } from '@ember/object';
|
||||
import { computed } from '@ember/object';
|
||||
import { scheduleOnce } from '@ember/runloop';
|
||||
import intersection from 'lodash.intersection';
|
||||
import Sortable from 'nomad-ui/mixins/sortable';
|
||||
|
@ -165,7 +164,7 @@ export default class IndexController extends Controller.extend(
|
|||
}));
|
||||
}
|
||||
|
||||
@computed('qpNamespace', 'model.namespaces.[]', 'system.cachedNamespace')
|
||||
@computed('qpNamespace', 'model.namespaces.[]')
|
||||
get optionsNamespaces() {
|
||||
const availableNamespaces = this.model.namespaces.map((namespace) => ({
|
||||
key: namespace.name,
|
||||
|
@ -181,7 +180,7 @@ export default class IndexController extends Controller.extend(
|
|||
if (!availableNamespaces.mapBy('key').includes(this.qpNamespace)) {
|
||||
scheduleOnce('actions', () => {
|
||||
// eslint-disable-next-line ember/no-side-effects
|
||||
this.set('qpNamespace', this.system.cachedNamespace || '*');
|
||||
this.set('qpNamespace', '*');
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -252,11 +251,6 @@ export default class IndexController extends Controller.extend(
|
|||
|
||||
isShowingDeploymentDetails = false;
|
||||
|
||||
@action
|
||||
cacheNamespace(namespace) {
|
||||
set(this, 'system.cachedNamespace', namespace);
|
||||
}
|
||||
|
||||
setFacetQueryParam(queryParam, selection) {
|
||||
this.set(queryParam, serialize(selection));
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export default class OptimizeController extends Controller {
|
|||
if (!availableNamespaces.mapBy('key').includes(this.qpNamespace)) {
|
||||
scheduleOnce('actions', () => {
|
||||
// eslint-disable-next-line ember/no-side-effects
|
||||
this.qpNamespace = this.system.cachedNamespace || '*';
|
||||
this.qpNamespace = '*';
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -247,11 +247,6 @@ export default class OptimizeController extends Controller {
|
|||
});
|
||||
}
|
||||
|
||||
@action
|
||||
cacheNamespace(namespace) {
|
||||
this.system.cachedNamespace = namespace;
|
||||
}
|
||||
|
||||
@action
|
||||
setFacetQueryParam(queryParam, selection) {
|
||||
this[queryParam] = serialize(selection);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import Service, { inject as service } from '@ember/service';
|
||||
import { computed } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { alias } from '@ember/object/computed';
|
||||
import PromiseObject from '../utils/classes/promise-object';
|
||||
import PromiseArray from '../utils/classes/promise-array';
|
||||
|
@ -132,12 +131,6 @@ export default class SystemService extends Service {
|
|||
);
|
||||
}
|
||||
|
||||
// The cachedNamespace is set on pages that have a namespaces filter.
|
||||
// It is set so other pages that have a namespaces filter can default to
|
||||
// what the previous namespaces filter page used rather than defaulting
|
||||
// to 'default' or '*'.
|
||||
@tracked cachedNamespace = null;
|
||||
|
||||
@task(function* () {
|
||||
const emptyLicense = { License: { Features: [] } };
|
||||
|
||||
|
|
|
@ -33,9 +33,7 @@
|
|||
@label="Namespace"
|
||||
@options={{this.optionsNamespaces}}
|
||||
@selection={{this.qpNamespace}}
|
||||
@onSelect={{action
|
||||
(queue (action this.cacheNamespace) (action this.setFacetQueryParam "qpNamespace"))
|
||||
}}
|
||||
@onSelect={{action this.setFacetQueryParam "qpNamespace"}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -43,12 +43,7 @@
|
|||
@label="Namespace"
|
||||
@options={{this.optionsNamespaces}}
|
||||
@selection={{this.qpNamespace}}
|
||||
@onSelect={{action
|
||||
(queue
|
||||
(action this.cacheNamespace)
|
||||
(action this.setFacetQueryParam "qpNamespace")
|
||||
)
|
||||
}}
|
||||
@onSelect={{action this.setFacetQueryParam "qpNamespace"}}
|
||||
/>
|
||||
{{/if}}
|
||||
<MultiSelectDropdown
|
||||
|
|
|
@ -23,12 +23,7 @@
|
|||
@label="Namespace"
|
||||
@options={{this.optionsNamespaces}}
|
||||
@selection={{this.qpNamespace}}
|
||||
@onSelect={{action
|
||||
(queue
|
||||
(action this.cacheNamespace)
|
||||
(action this.setFacetQueryParam "qpNamespace")
|
||||
)
|
||||
}}
|
||||
@onSelect={{action this.setFacetQueryParam "qpNamespace"}}
|
||||
/>
|
||||
{{/if}}
|
||||
<MultiSelectDropdown
|
||||
|
|
|
@ -6,7 +6,6 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
|
|||
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
|
||||
import pageSizeSelect from './behaviors/page-size-select';
|
||||
import JobsList from 'nomad-ui/tests/pages/jobs/list';
|
||||
import Layout from 'nomad-ui/tests/pages/layout';
|
||||
import percySnapshot from '@percy/ember';
|
||||
|
||||
let managementToken, clientToken;
|
||||
|
@ -423,19 +422,6 @@ module('Acceptance | jobs list', function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test('the active namespace is carried over to the storage pages', async function (assert) {
|
||||
server.createList('namespace', 2);
|
||||
|
||||
const namespace = server.db.namespaces[1];
|
||||
await JobsList.visit();
|
||||
await JobsList.facets.namespace.toggle();
|
||||
await JobsList.facets.namespace.options.objectAt(2).select();
|
||||
|
||||
await Layout.gutter.visitStorage();
|
||||
|
||||
assert.equal(currentURL(), `/csi/volumes?namespace=${namespace.id}`);
|
||||
});
|
||||
|
||||
test('when the user has a client token that has a namespace with a policy to run a job', async function (assert) {
|
||||
const READ_AND_WRITE_NAMESPACE = 'read-and-write-namespace';
|
||||
const READ_ONLY_NAMESPACE = 'read-only-namespace';
|
||||
|
|
|
@ -76,6 +76,12 @@ module('Acceptance | optimize', function (hooks) {
|
|||
.flat()
|
||||
.find((r) => r.resource === 'CPU');
|
||||
|
||||
const currentTaskGroupHasMemoryRecommendation =
|
||||
currentTaskGroup.tasks.models
|
||||
.mapBy('recommendations.models')
|
||||
.flat()
|
||||
.find((r) => r.resource === 'MemoryMB');
|
||||
|
||||
// If no CPU recommendation, will not be able to accept recommendation with all memory recommendations turned off
|
||||
|
||||
if (!currentTaskGroupHasCPURecommendation) {
|
||||
|
@ -85,6 +91,13 @@ module('Acceptance | optimize', function (hooks) {
|
|||
resource: 'CPU',
|
||||
});
|
||||
}
|
||||
if (!currentTaskGroupHasMemoryRecommendation) {
|
||||
const currentTaskGroupTask = currentTaskGroup.tasks.models[0];
|
||||
this.server.create('recommendation', {
|
||||
task: currentTaskGroupTask,
|
||||
resource: 'MemoryMB',
|
||||
});
|
||||
}
|
||||
|
||||
await Optimize.visit();
|
||||
|
||||
|
|
|
@ -6,9 +6,7 @@ import { setupMirage } from 'ember-cli-mirage/test-support';
|
|||
import a11yAudit from 'nomad-ui/tests/helpers/a11y-audit';
|
||||
import pageSizeSelect from './behaviors/page-size-select';
|
||||
import VolumesList from 'nomad-ui/tests/pages/storage/volumes/list';
|
||||
import Layout from 'nomad-ui/tests/pages/layout';
|
||||
import percySnapshot from '@percy/ember';
|
||||
|
||||
const assignWriteAlloc = (volume, alloc) => {
|
||||
volume.writeAllocs.add(alloc);
|
||||
volume.allocations.add(alloc);
|
||||
|
@ -193,19 +191,6 @@ module('Acceptance | volumes list', function (hooks) {
|
|||
assert.equal(VolumesList.volumes.objectAt(0).name, volume2.id);
|
||||
});
|
||||
|
||||
test('the active namespace is carried over to the jobs pages', async function (assert) {
|
||||
server.createList('namespace', 2);
|
||||
|
||||
const namespace = server.db.namespaces[1];
|
||||
await VolumesList.visit();
|
||||
await VolumesList.facets.namespace.toggle();
|
||||
await VolumesList.facets.namespace.options.objectAt(2).select();
|
||||
|
||||
await Layout.gutter.visitJobs();
|
||||
|
||||
assert.equal(currentURL(), `/jobs?namespace=${namespace.id}`);
|
||||
});
|
||||
|
||||
test('when accessing volumes is forbidden, a message is shown with a link to the tokens page', async function (assert) {
|
||||
server.pretender.get('/v1/volumes', () => [403, {}, null]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue