Skip to content

Commit

Permalink
fix: Fix app deploy form and yaml mode
Browse files Browse the repository at this point in the history
Signed-off-by: leoliu <leoliu@yunify.com>
  • Loading branch information
leoliu committed Jul 28, 2020
1 parent 86c07ad commit 6eaef59
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/components/Forms/AppDeploy/AppConfig/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { set } from 'lodash'
import { reaction } from 'mobx'
import { observer } from 'mobx-react'
import { Loading } from '@pitrix/lego-ui'
import { CodeEditor, Switch } from 'components/Base'
import { Alert, CodeEditor, Switch } from 'components/Base'
import { safeParseJSON } from 'utils'
import { getValueObj, getValue } from 'utils/yaml'

Expand All @@ -33,6 +33,7 @@ import styles from './index.scss'
export default class Services extends React.Component {
state = {
valuesYaml: '',
valuesJSON: {},
valuesSchema: undefined,
loadingFile: true,
isCodeMode: false,
Expand Down Expand Up @@ -73,12 +74,13 @@ export default class Services extends React.Component {

updateFormData = () => {
const { formData } = this.props
const { isCodeMode, valuesYaml, valuesJSON } = this.state

set(
formData,
'conf',
getValue({
...getValueObj(this.state.valuesYaml),
...(isCodeMode ? getValueObj(valuesYaml) : valuesJSON),
Name: formData.name || '',
Description: formData.desc || '',
Workspace: formData.workspace,
Expand All @@ -87,21 +89,14 @@ export default class Services extends React.Component {
}

handleModeChange = () => {
const { isCodeMode, valuesYaml } = this.state
if (isCodeMode) {
this.setState({
valuesJSON: getValueObj(valuesYaml),
isCodeMode: !isCodeMode,
})
} else {
this.setState({
isCodeMode: !isCodeMode,
})
}
const { isCodeMode } = this.state
this.setState({
isCodeMode: !isCodeMode,
})
}

handleValueChange = value => {
this.setState({ valueJSON: value, valuesYaml: getValue(value) })
this.setState({ valueJSON: value })
}

handleYamlChange = value => {
Expand Down Expand Up @@ -155,6 +150,13 @@ export default class Services extends React.Component {
/>
)}
</div>
{valuesSchema && (
<Alert
className="margin-b12"
type="warning"
message={t('HELM_APP_SCHEMA_FORM_TIP')}
/>
)}
{showCodeEditor ? this.renderYamlEdit() : this.renderSchemaForm()}
</div>
)
Expand Down
3 changes: 3 additions & 0 deletions src/locales/en/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,7 @@ export default {
APP_ICON_NOTE: 'JPG or PNG within 96px * 96px',

MISS_FILE_NOTE: 'The file {file} not found',

HELM_APP_SCHEMA_FORM_TIP:
'The app configuration can be displayed in a form. You can modify the default app configuration through either the form or YAML editor. Note: app data stored in different patterns are independent of each other.',
}
3 changes: 3 additions & 0 deletions src/locales/es/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,7 @@ export default {
APP_ICON_NOTE: 'JPG o PNG menor o igual a 200px * 200px',

MISS_FILE_NOTE: 'No se encuentra el fichero {file}',

HELM_APP_SCHEMA_FORM_TIP:
'The app configuration can be displayed in a form. You can modify the default app configuration through either the form or YAML editor. Note: app data stored in different patterns are independent of each other.',
}
3 changes: 3 additions & 0 deletions src/locales/tc/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,7 @@ export default {
'Please select a workspace': '請選擇企業空間',
'Please select a cluster': '請選擇集群',
'Please select a project': '請選擇項目',

HELM_APP_SCHEMA_FORM_TIP:
'此应用支持表单模式,可选择通过表单或 YAML 编辑器来修改默认应用配置。注意:不同模式之间数据独立。',
}
3 changes: 3 additions & 0 deletions src/locales/zh/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,7 @@ export default {
'Please select a workspace': '请选择企业空间',
'Please select a cluster': '请选择集群',
'Please select a project': '请选择项目',

HELM_APP_SCHEMA_FORM_TIP:
'此应用支持表单模式,可选择通过表单或 YAML 编辑器来修改默认应用配置。注意:不同模式之间数据独立。',
}

0 comments on commit 6eaef59

Please sign in to comment.