[ui] Bugfix: reinstate the "this variable will be accessible by $job/$group/$task" notification (#14741)

* When we isolated the variable form path to within its component for isolation reasons, we lost the model-level checks for related entites at type-time

* Be a little more functionally pure

* Use Ember.set to appease mirage
This commit is contained in:
Phil Renaud
2022-09-29 10:40:00 -04:00
committed by GitHub
parent 97508ea162
commit 50001d11c8
3 changed files with 49 additions and 1 deletions

View File

@@ -40,6 +40,7 @@
@value={{this.path}}
placeholder="nomad/jobs/my-job/my-group/my-task"
class="input path-input {{if this.duplicatePathWarning "error"}}"
{{on "input" this.setModelPath}}
disabled={{not @model.isNew}}
{{autofocus}}
data-test-path-input

View File

@@ -168,6 +168,14 @@ export default class VariableFormComponent extends Component {
this.save(e, true);
}
/**
*
* @param {KeyboardEvent} e
*/
@action setModelPath(e) {
set(this.args.model, 'path', e.target.value);
}
@action
async save(e, overwrite = false) {
if (e.type === 'submit') {

View File

@@ -145,7 +145,7 @@ module('Acceptance | variables', function (hooks) {
});
test('variables prefixed with nomad/jobs/ correctly link to entities', async function (assert) {
assert.expect(23);
assert.expect(29);
allScenarios.variableTestCluster(server);
const variablesToken = server.db.tokens.find(VARIABLE_TOKEN_ID);
@@ -313,6 +313,45 @@ module('Acceptance | variables', function (hooks) {
assert
.dom('[data-test-task-stat="variables"]')
.doesNotExist('Link from Variable-less Job to Variable does not exist');
// Related Entities during the Variable creation process
await Variables.visitNew();
assert
.dom('.related-entities.notification')
.doesNotExist('Related Entities notification is not present by default');
await typeIn('[data-test-path-input]', 'foo/bar');
assert
.dom('.related-entities.notification')
.doesNotExist(
'Related Entities notification is not present when path is generic'
);
document.querySelector('[data-test-path-input]').value = ''; // clear path input
await typeIn('[data-test-path-input]', 'nomad/jobs/abc');
assert
.dom('.related-entities.notification')
.exists(
'Related Entities notification is present when path is job-oriented'
);
assert
.dom('.related-entities.notification')
.containsText(
'This variable will be accessible by job',
'Related Entities notification is job-oriented'
);
await typeIn('[data-test-path-input]', '/def');
assert
.dom('.related-entities.notification')
.containsText(
'This variable will be accessible by group',
'Related Entities notification is group-oriented'
);
await typeIn('[data-test-path-input]', '/ghi');
assert
.dom('.related-entities.notification')
.containsText(
'This variable will be accessible by task',
'Related Entities notification is task-oriented'
);
});
test('it does not allow you to save if you lack Items', async function (assert) {