Merge "feat: update creating heat stack"
This commit is contained in:
commit
35f57c4c25
@ -20,7 +20,9 @@ import {
|
|||||||
getFormDefaultValues,
|
getFormDefaultValues,
|
||||||
getTemplate,
|
getTemplate,
|
||||||
rollbackTip,
|
rollbackTip,
|
||||||
|
getParamsFromContent,
|
||||||
} from 'resources/heat/stack';
|
} from 'resources/heat/stack';
|
||||||
|
import { getValue } from 'utils/yaml';
|
||||||
|
|
||||||
export class Parameter extends Base {
|
export class Parameter extends Base {
|
||||||
get isStep() {
|
get isStep() {
|
||||||
@ -71,6 +73,23 @@ export class Parameter extends Base {
|
|||||||
return getFormItems(this.template);
|
return getFormItems(this.template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateParamsInContext = (key, value) => {
|
||||||
|
const { params = '' } = this.props.context || {};
|
||||||
|
const newParams = !params ? { parameters: {} } : getYaml(params);
|
||||||
|
newParams.parameters[key] = value;
|
||||||
|
this.updateContext({ params: getValue(newParams) });
|
||||||
|
};
|
||||||
|
|
||||||
|
onValuesChange = (changedFields) => {
|
||||||
|
const params = getParamsFromContent(this.template);
|
||||||
|
const keys = Object.keys(params);
|
||||||
|
Object.keys(changedFields).forEach((key) => {
|
||||||
|
if (keys.includes(key)) {
|
||||||
|
this.updateParamsInContext(key, changedFields[key]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
get rollbackOptions() {
|
get rollbackOptions() {
|
||||||
return [
|
return [
|
||||||
{ value: true, label: t('Enable') },
|
{ value: true, label: t('Enable') },
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { has, isObject } from 'lodash';
|
import { has, isEmpty, isObject } from 'lodash';
|
||||||
import { yesNoOptions } from 'utils/constants';
|
import { yesNoOptions } from 'utils/constants';
|
||||||
|
|
||||||
export const stackStatus = {
|
export const stackStatus = {
|
||||||
@ -114,14 +114,26 @@ export const getFormItemType = (type) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getFormItems = (contentYaml) => {
|
export const getParamsFromContent = (contentYaml) => {
|
||||||
const formItems = [];
|
|
||||||
try {
|
try {
|
||||||
const content = yaml.load(contentYaml);
|
const content = yaml.load(contentYaml);
|
||||||
if (!isObject(content)) {
|
if (!isObject(content)) {
|
||||||
return formItems;
|
return {};
|
||||||
}
|
}
|
||||||
const params = content.parameters;
|
const params = content.parameters;
|
||||||
|
return params || {};
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getFormItems = (contentYaml) => {
|
||||||
|
const formItems = [];
|
||||||
|
try {
|
||||||
|
const params = getParamsFromContent(contentYaml);
|
||||||
|
if (isEmpty(params)) {
|
||||||
|
return formItems;
|
||||||
|
}
|
||||||
Object.keys(params).forEach((key) => {
|
Object.keys(params).forEach((key) => {
|
||||||
const value = params[key];
|
const value = params[key];
|
||||||
const { type = 'string', description = '', label, hidden } = value;
|
const { type = 'string', description = '', label, hidden } = value;
|
||||||
|
Loading…
Reference in New Issue
Block a user