Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support static Parameters for commands #42

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 50 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beer-garden/builder",
"version": "3.2.0",
"version": "3.2.1",
"description": "AngularJS module to generate Angular-Schema-Form from JSON",
"author": "The Beergarden Team",
"contributors": [],
Expand Down
31 changes: 23 additions & 8 deletions src/dynamicChoices.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ export function setDynamicChoices(schema, form, parameter, parentKey) {
form["choices"]["httpGet"]["queryParameterFields"][pair[0]] = field;
}
} else if (parameter.choices.type === "command") {

let providedParameters = {};

for (let i = 0; i < parameter.choices.details["args"].length; i++) {
let pair = parameter.choices.details["args"][i];
let field = fieldPath(pair[1], parentKey);

if (field.indexOf('"') >= 0){
providedParameters[pair[0]] = field.split('"')[1];
}
}

form["choices"] = {
updateOn: ["instance_name"],
callback: {
Expand All @@ -65,6 +77,7 @@ export function setDynamicChoices(schema, form, parameter, parentKey) {
{
command: parameter.choices.details["name"],
parameterNames: [],
parameters: providedParameters,
},
],
argumentFields: [],
Expand All @@ -75,15 +88,17 @@ export function setDynamicChoices(schema, form, parameter, parentKey) {
let pair = parameter.choices.details["args"][i];
let field = fieldPath(pair[1], parentKey);

// special fields are already in this, don't want to duplicate
if (!specialField(field)) {
form["choices"]["updateOn"].push(field);
}
if (field.indexOf('"') < 0){
// special fields are already in this, don't want to duplicate
if (!specialField(field)) {
form["choices"]["updateOn"].push(field);
}

form["choices"]["callback"]["argumentFields"].push(field);
form["choices"]["callback"]["arguments"][0]["parameterNames"].push(
pair[0]
);
form["choices"]["callback"]["argumentFields"].push(field);
form["choices"]["callback"]["arguments"][0]["parameterNames"].push(
pair[0]
);
}
}

// If it's an object then it's a fully specified command
Expand Down