mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
[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:
@@ -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
|
||||
|
||||
@@ -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') {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user