-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ui, bugfix] Link fix for volumes where per_alloc=true #12713
Changes from all commits
3926584
f16fdc5
ffc2d4c
190370d
633b877
0ebdeb6
f1ee4bd
78c7282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
ui: Fixed a bug where volumes were being incorrectly linked when per_alloc=true | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"compilerOptions":{"target":"es6","experimentalDecorators":true},"exclude":["node_modules","bower_components","tmp","vendor",".git","dist"]} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { helper } from '@ember/component/helper'; | ||
|
||
/** | ||
* Volume Name Formatter | ||
* | ||
* Usage: {{format-volume-name source=string isPerAlloc=boolean volumeExtension=string}} | ||
* | ||
* Outputs a title/link for volumes that are per_alloc-aware. | ||
* (when a volume is per_alloc, its route location requires an additional extension) | ||
*/ | ||
export function formatVolumeName( | ||
_, | ||
{ source = '', isPerAlloc, volumeExtension } | ||
) { | ||
return `${source}${isPerAlloc ? volumeExtension : ''}`; | ||
} | ||
|
||
export default helper(formatVolumeName); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,12 +293,17 @@ | |
<tr data-test-volume> | ||
<td data-test-volume-name> | ||
{{#if row.model.isCSI}} | ||
<LinkTo | ||
@route="csi.volumes.volume" | ||
@model={{concat row.model.source "@" row.model.namespace.id}} | ||
> | ||
{{row.model.name}} | ||
</LinkTo> | ||
{{!-- if volume is per_alloc=true, there's no one specific volume. So, link to the volumes index with an active query --}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. This seems like the best we can do here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably unrelated to this PR, but on one attempt to click this link the back button broke and I couldn't get back to this page. Unfortunately it only happened once and I can't reproduce it anymore. |
||
{{#if row.model.perAlloc}} | ||
<LinkTo @route="csi.volumes.index" @query={{hash search=row.model.source}}>{{row.model.name}}</LinkTo> | ||
{{else}} | ||
<LinkTo | ||
@route="csi.volumes.volume" | ||
@model={{concat row.model.source "@" row.model.namespace.id}} | ||
> | ||
{{row.model.name}} | ||
</LinkTo> | ||
{{/if}} | ||
{{else}} | ||
{{row.model.name}} | ||
{{/if}} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { module, test } from 'qunit'; | ||
import { formatVolumeName } from 'nomad-ui/helpers/format-volume-name'; | ||
|
||
module('Unit | Helper | formatVolumeName', function () { | ||
test('Returns source as string when isPerAlloc is false', function (assert) { | ||
const expectation = 'my-volume-source'; | ||
assert.equal( | ||
formatVolumeName(null, { | ||
source: 'my-volume-source', | ||
isPerAlloc: false, | ||
volumeExtension: '[arbitrary]', | ||
}), | ||
expectation, | ||
'false perAlloc' | ||
); | ||
assert.equal( | ||
formatVolumeName(null, { | ||
source: 'my-volume-source', | ||
isPerAlloc: null, | ||
volumeExtension: '[arbitrary]', | ||
}), | ||
expectation, | ||
'null perAlloc' | ||
); | ||
}); | ||
|
||
test('Returns concatonated name when isPerAlloc is true', function (assert) { | ||
const expectation = 'my-volume-source[1]'; | ||
assert.equal( | ||
formatVolumeName(null, { | ||
source: 'my-volume-source', | ||
isPerAlloc: true, | ||
volumeExtension: '[1]', | ||
}), | ||
expectation, | ||
expectation | ||
); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise:
great job! This is such a simple, elegant solution.