From 8563e4b187e546403b143ae84d41fd5d5c4965b0 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Fri, 22 Nov 2024 12:23:53 -0500 Subject: [PATCH 1/3] Volumes and plugins navigation fixes, generally --- .changelog/24542.txt | 3 +++ ui/app/adapters/volume.js | 8 ++++++++ ui/app/controllers/csi/volumes/volume.js | 10 ++++------ ui/app/helpers/lazy-click.js | 2 +- ui/app/templates/csi/plugins/index.hbs | 7 ++++++- ui/app/templates/csi/volumes/index.hbs | 4 ++-- 6 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 .changelog/24542.txt diff --git a/.changelog/24542.txt b/.changelog/24542.txt new file mode 100644 index 00000000000..48c451928d8 --- /dev/null +++ b/.changelog/24542.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Fix an issue where volumes weren't navigable +``` diff --git a/ui/app/adapters/volume.js b/ui/app/adapters/volume.js index e8f2f59de8b..489967ed5d4 100644 --- a/ui/app/adapters/volume.js +++ b/ui/app/adapters/volume.js @@ -8,6 +8,14 @@ import classic from 'ember-classic-decorator'; @classic export default class VolumeAdapter extends WatchableNamespaceIDs { + // Over in serializers/volume.js, we prepend csi/ as part of the hash ID for request resolution reasons. + // However, this is not part of the actual ID stored in the database and we should treat it like a regular, unescaped + // path segment. + urlForFindRecord() { + let url = super.urlForFindRecord(...arguments); + return url.replace('csi%2F', 'csi/'); + } + queryParamsToAttrs = { type: 'type', plugin_id: 'plugin.id', diff --git a/ui/app/controllers/csi/volumes/volume.js b/ui/app/controllers/csi/volumes/volume.js index 29a92cc61dd..74fb18ed9eb 100644 --- a/ui/app/controllers/csi/volumes/volume.js +++ b/ui/app/controllers/csi/volumes/volume.js @@ -25,15 +25,13 @@ export default class VolumeController extends Controller { get breadcrumbs() { const volume = this.volume; + if (!volume) { + return []; + } return [ { label: 'Volumes', - args: [ - 'csi.volumes', - qpBuilder({ - volumeNamespace: volume.get('namespace.name') || 'default', - }), - ], + args: ['csi.volumes'], }, { label: volume.name, diff --git a/ui/app/helpers/lazy-click.js b/ui/app/helpers/lazy-click.js index 4e182620de7..1d55877d2b3 100644 --- a/ui/app/helpers/lazy-click.js +++ b/ui/app/helpers/lazy-click.js @@ -14,7 +14,7 @@ import Helper from '@ember/component/helper'; * that should be handled instead. */ export function lazyClick([onClick, event]) { - if (!['a', 'button'].includes(event?.target.tagName.toLowerCase())) { + if (!['a', 'button'].includes(event?.target?.tagName.toLowerCase())) { onClick(event); } } diff --git a/ui/app/templates/csi/plugins/index.hbs b/ui/app/templates/csi/plugins/index.hbs index fcc1f836754..082b41a5133 100644 --- a/ui/app/templates/csi/plugins/index.hbs +++ b/ui/app/templates/csi/plugins/index.hbs @@ -38,7 +38,12 @@ - + {{row.model.plainId}} diff --git a/ui/app/templates/csi/volumes/index.hbs b/ui/app/templates/csi/volumes/index.hbs index 3d73ff0b431..bb50661d2a5 100644 --- a/ui/app/templates/csi/volumes/index.hbs +++ b/ui/app/templates/csi/volumes/index.hbs @@ -77,7 +77,7 @@ {{on "click" (action "gotoVolume" row.model)}} > {{/if}} - \ No newline at end of file + From 1023a95530432e389b37357c438b4ee61979bc1b Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Sat, 23 Nov 2024 10:07:59 -0500 Subject: [PATCH 2/3] Mirage no longer has to take the csi/ string into account --- ui/mirage/config.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 0e780ae612f..9345e29194a 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -30,7 +30,7 @@ export function filesForPath(allocFiles, filterPath) { export default function () { this.timing = 0; // delay for each request, automatically set to 0 during testing - this.logging = window.location.search.includes('mirage-logging=true'); + this.logging = true; // TODO: window.location.search.includes('mirage-logging=true'); this.namespace = 'v1'; this.trackRequests = Ember.testing; @@ -667,13 +667,9 @@ export default function () { ); this.get( - '/volume/:id', + '/volume/csi/:id', withBlockingSupport(function ({ csiVolumes }, { params, queryParams }) { - if (!params.id.startsWith('csi/')) { - return new Response(404, {}, null); - } - - const id = params.id.replace(/^csi\//, ''); + const { id } = params; const volume = csiVolumes.all().models.find((volume) => { const volumeIsDefault = !volume.namespaceId || volume.namespaceId === 'default'; From 2fea53632f2fa05c365d64586f0735a03b1123c5 Mon Sep 17 00:00:00 2001 From: Phil Renaud Date: Sat, 23 Nov 2024 10:36:39 -0500 Subject: [PATCH 3/3] Volume adapter test fix --- ui/mirage/config.js | 2 +- ui/tests/unit/adapters/volume-test.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/mirage/config.js b/ui/mirage/config.js index 9345e29194a..3d3a9f001b5 100644 --- a/ui/mirage/config.js +++ b/ui/mirage/config.js @@ -30,7 +30,7 @@ export function filesForPath(allocFiles, filterPath) { export default function () { this.timing = 0; // delay for each request, automatically set to 0 during testing - this.logging = true; // TODO: window.location.search.includes('mirage-logging=true'); + this.logging = window.location.search.includes('mirage-logging=true'); this.namespace = 'v1'; this.trackRequests = Ember.testing; diff --git a/ui/tests/unit/adapters/volume-test.js b/ui/tests/unit/adapters/volume-test.js index eaf2d32bb41..118a1a2b653 100644 --- a/ui/tests/unit/adapters/volume-test.js +++ b/ui/tests/unit/adapters/volume-test.js @@ -87,9 +87,7 @@ module('Unit | Adapter | Volume', function (hooks) { await settled(); assert.deepEqual(pretender.handledRequests.mapBy('url'), [ - `/v1/volume/${encodeURIComponent( - volumeName - )}?namespace=${volumeNamespace}`, + `/v1/volume/${volumeName}?namespace=${volumeNamespace}`, ]); });