Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangpeng
dinky
Commits
678817b5
Unverified
Commit
678817b5
authored
Dec 29, 2023
by
Zzm0809
Committed by
GitHub
Dec 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve document form layout (#2849)
* improve-document-form-layout * delete un use code * delete some code
parent
cac5239d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
105 deletions
+81
-105
index.tsx
...pages/DataStudio/LeftContainer/Project/JobModal/index.tsx
+1
-1
model.ts
dinky-web/src/pages/DataStudio/model.ts
+0
-8
index.tsx
.../Document/components/DocumentModal/DocumentForm/index.tsx
+64
-83
index.tsx
...ges/RegCenter/Document/components/DocumentModal/index.tsx
+16
-13
No files found.
dinky-web/src/pages/DataStudio/LeftContainer/Project/JobModal/index.tsx
View file @
678817b5
...
@@ -113,7 +113,7 @@ const JobModal: React.FC<JobModalProps> = (props) => {
...
@@ -113,7 +113,7 @@ const JobModal: React.FC<JobModalProps> = (props) => {
// if this type is flink job, init task value and submit
// if this type is flink job, init task value and submit
if
(
isFlinkJob
(
formData
.
type
??
''
))
{
if
(
isFlinkJob
(
formData
.
type
??
''
))
{
const
initTaskValue
=
{
const
initTaskValue
=
{
savePointStrategy
:
-
1
,
// -1
is disabled
savePointStrategy
:
0
,
// 0
is disabled
parallelism
:
1
,
// default parallelism
parallelism
:
1
,
// default parallelism
envId
:
-
1
,
// -1 is disabled
envId
:
-
1
,
// -1 is disabled
step
:
1
,
// default step is develop
step
:
1
,
// default step is develop
...
...
dinky-web/src/pages/DataStudio/model.ts
View file @
678817b5
...
@@ -422,7 +422,6 @@ const Model: ModelType = {
...
@@ -422,7 +422,6 @@ const Model: ModelType = {
},
},
*
queryEnv
({
payload
},
{
call
,
put
})
{
*
queryEnv
({
payload
},
{
call
,
put
})
{
const
response
:
EnvType
[]
=
yield
call
(
getEnvData
,
payload
);
const
response
:
EnvType
[]
=
yield
call
(
getEnvData
,
payload
);
console
.
log
(
response
);
yield
put
({
yield
put
({
type
:
'saveEnv'
,
type
:
'saveEnv'
,
payload
:
response
payload
:
response
...
@@ -463,13 +462,6 @@ const Model: ModelType = {
...
@@ -463,13 +462,6 @@ const Model: ModelType = {
payload
:
response
payload
:
response
});
});
},
},
*
queryEnv
({
payload
},
{
call
,
put
})
{
const
response
:
EnvType
[]
=
yield
call
(
getEnvData
,
payload
);
yield
put
({
type
:
'saveEnv'
,
payload
:
response
});
},
*
queryClusterConfigurationData
({
payload
},
{
call
,
put
})
{
*
queryClusterConfigurationData
({
payload
},
{
call
,
put
})
{
const
response
:
Cluster
.
Config
[]
=
yield
call
(
getClusterConfigurationData
,
payload
);
const
response
:
Cluster
.
Config
[]
=
yield
call
(
getClusterConfigurationData
,
payload
);
yield
put
({
yield
put
({
...
...
dinky-web/src/pages/RegCenter/Document/components/DocumentModal/DocumentForm/index.tsx
View file @
678817b5
...
@@ -18,18 +18,17 @@
...
@@ -18,18 +18,17 @@
*/
*/
import
CodeEdit
from
'@/components/CustomEditor/CodeEdit'
;
import
CodeEdit
from
'@/components/CustomEditor/CodeEdit'
;
import
{
JOB_TYPE
}
from
'@/pages/DataStudio/LeftContainer/Project/constants'
;
import
{
JOB_TYPE
}
from
'@/pages/DataStudio/LeftContainer/Project/constants'
;
import
{
import
{
DOCUMENT_CATEGORY_ENUMS
,
DOCUMENT_CATEGORY_ENUMS
,
DOCUMENT_FUNCTION_TYPE_ENUMS
,
DOCUMENT_FUNCTION_TYPE_ENUMS
,
DOCUMENT_TYPE_ENUMS
,
DOCUMENT_TYPE_ENUMS
,
VERSIONS
VERSIONS
}
from
'@/pages/RegCenter/Document/constans'
;
}
from
'@/pages/RegCenter/Document/constans'
;
import
{
FORM_LAYOUT_PUBLIC
}
from
'@/services/constants'
;
import
{
Document
}
from
'@/types/RegCenter/data'
;
import
{
Document
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
import
{
ProForm
,
ProForm
Group
,
ProFormItem
,
ProFormItem
,
ProFormSegmented
,
ProFormSegmented
,
ProFormSelect
,
ProFormSelect
,
...
@@ -37,11 +36,10 @@ import {
...
@@ -37,11 +36,10 @@ import {
ProFormText
,
ProFormText
,
ProFormTextArea
ProFormTextArea
}
from
'@ant-design/pro-components'
;
}
from
'@ant-design/pro-components'
;
import
{
ProFormDependency
}
from
'@ant-design/pro-form'
;
import
{
FormInstance
}
from
'antd/es/form/hooks/useForm'
;
import
{
FormInstance
}
from
'antd/es/form/hooks/useForm'
;
import
{
Values
}
from
'async-validator'
;
import
{
Values
}
from
'async-validator'
;
import
{
DefaultOptionType
}
from
'rc-select/lib/Select'
;
import
{
DefaultOptionType
}
from
'rc-select/lib/Select'
;
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
type
DocumentFormProps
=
{
type
DocumentFormProps
=
{
values
:
Partial
<
Document
>
;
values
:
Partial
<
Document
>
;
...
@@ -54,16 +52,16 @@ const CodeEditProps = {
...
@@ -54,16 +52,16 @@ const CodeEditProps = {
};
};
const
DocumentForm
:
React
.
FC
<
DocumentFormProps
>
=
(
props
)
=>
{
const
DocumentForm
:
React
.
FC
<
DocumentFormProps
>
=
(
props
)
=>
{
const
{
values
,
form
}
=
props
;
const
{
values
,
form
}
=
props
;
/**
/**
* status
* status
*/
*/
const
[
codeFillValue
,
setCodeFillValue
]
=
useState
<
string
>
(
values
.
fillValue
||
''
);
const
[
codeFillValue
,
setCodeFillValue
]
=
useState
<
string
>
(
values
.
fillValue
||
''
);
const
{
FLINK_OPTIONS
,
SQL_TEMPLATE
,
FUN_UDF
,
OTHER
}
=
DOCUMENT_TYPE_ENUMS
;
const
{
FLINK_OPTIONS
,
SQL_TEMPLATE
,
FUN_UDF
,
OTHER
}
=
DOCUMENT_TYPE_ENUMS
;
const
[
CATEGORY_LIST
]
=
useState
<
DefaultOptionType
[]
>
(
const
[
CATEGORY_LIST
]
=
useState
<
DefaultOptionType
[]
>
(
Object
.
values
(
DOCUMENT_CATEGORY_ENUMS
).
map
((
item
)
=>
({
label
:
item
.
text
,
value
:
item
.
value
}))
Object
.
values
(
DOCUMENT_CATEGORY_ENUMS
).
map
((
item
)
=>
({
label
:
item
.
text
,
value
:
item
.
value
}))
);
);
const
[
FUNCTION_TYPES
]
=
useState
<
DefaultOptionType
[]
>
(
const
[
FUNCTION_TYPES
]
=
useState
<
DefaultOptionType
[]
>
(
...
@@ -74,17 +72,11 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
...
@@ -74,17 +72,11 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
);
);
const
[
VERSION_OPTIONS
]
=
useState
<
DefaultOptionType
[]
>
(
const
[
VERSION_OPTIONS
]
=
useState
<
DefaultOptionType
[]
>
(
VERSIONS
.
map
((
item
)
=>
({
label
:
item
.
text
,
value
:
item
.
value
}))
VERSIONS
.
map
((
item
)
=>
({
label
:
item
.
text
,
value
:
item
.
value
}))
);
);
const
onTypeAndNameChange
=
(
type
:
string
,
name
:
string
)
=>
{
const
[
documentType
,
setDocumentType
]
=
useState
<
string
>
(
''
);
if
(
type
==
FLINK_OPTIONS
.
value
)
{
const
fillValue
=
"set '"
+
name
+
"' = '${1:}'"
;
form
.
setFieldsValue
({
category
:
'Varible'
});
form
.
setFieldsValue
({
fillValue
:
fillValue
});
setCodeFillValue
(
fillValue
);
}
};
/**
/**
* form
* form
...
@@ -93,51 +85,62 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
...
@@ -93,51 +85,62 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
const
documentFormRender
=
()
=>
{
const
documentFormRender
=
()
=>
{
return
(
return
(
<>
<>
<
ProFormSegmented
<
ProFormGroup
>
name=
'type'
<
ProFormSegmented
label=
{
l
(
'rc.doc.functionType'
)
}
name=
'type'
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.typePlaceholder'
)
}]
}
label=
{
l
(
'rc.doc.functionType'
)
}
valueEnum=
{
DOCUMENT_TYPE_ENUMS
}
initialValue=
{
SQL_TEMPLATE
.
value
}
/>
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.typePlaceholder'
)}]
}
valueEnum=
{
DOCUMENT_TYPE_ENUMS
}
fieldProps=
{
{
onChange
:
(
value
)
=>
setDocumentType
(
value
as
string
)}
}
/>
<
ProFormText
<
ProFormText
name=
'name'
name=
'name'
label=
{
l
(
'rc.doc.name'
)
}
width=
{
'md'
}
placeholder=
{
l
(
'rc.doc.namePlaceholder'
)
}
label=
{
l
(
'rc.doc.name'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.namePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.doc.namePlaceholder'
)
}
/>
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.namePlaceholder'
)}]
}
/>
<
ProFormSwitch
name=
'enabled'
label=
{
l
(
'global.table.isEnable'
)
}
checkedChildren=
{
l
(
'button.enable'
)
}
unCheckedChildren=
{
l
(
'button.disable'
)
}
/>
<
ProFormDependency
name=
{
[
'type'
,
'name'
]
}
>
</
ProFormGroup
>
{
({
type
,
name
})
=>
{
onTypeAndNameChange
(
type
,
name
);
<
ProFormGroup
>
return
(
<
ProFormSelect
<>
name=
'subtype'
{
type
!=
FLINK_OPTIONS
.
value
&&
type
!=
OTHER
.
value
&&
(
width=
{
'sm'
}
<
ProFormSelect
label=
{
l
(
'rc.doc.subFunctionType'
)
}
name=
'subtype'
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.subTypePlaceholder'
)}]
}
label=
{
l
(
'rc.doc.subFunctionType'
)
}
options=
{
documentType
==
FUN_UDF
.
value
?
FUNCTION_TYPES
:
JOB_TYPE
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.subTypePlaceholder'
)
}]
}
/>
options=
{
type
==
FUN_UDF
.
value
?
FUNCTION_TYPES
:
JOB_TYPE
}
/>
<
ProFormSelect
)
}
name=
'category'
width=
{
'sm'
}
<
ProFormSelect
label=
{
l
(
'rc.doc.category'
)
}
disabled=
{
type
==
FLINK_OPTIONS
.
value
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.categoryPlaceholder'
)}]
}
name=
'category'
options=
{
CATEGORY_LIST
}
label=
{
l
(
'rc.doc.category'
)
}
/>
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.categoryPlaceholder'
)
}]
}
<
ProFormSelect
options=
{
CATEGORY_LIST
}
name=
'version'
/>
width=
{
'sm'
}
</>
label=
{
l
(
'rc.doc.version'
)
}
);
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.versionPlaceholder'
)}]
}
}
}
options=
{
VERSION_OPTIONS
}
</
ProFormDependency
>
/>
</
ProFormGroup
>
<
ProFormItem
<
ProFormItem
name=
'fillValue'
name=
'fillValue'
label=
{
l
(
'rc.doc.fillValue'
)
}
label=
{
l
(
'rc.doc.fillValue'
)
}
tooltip=
{
l
(
'rc.doc.fillValuePlaceholder'
)
}
tooltip=
{
l
(
'rc.doc.fillValuePlaceholder'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.fillValueHelp'
)
}]
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.fillValueHelp'
)
}]
}
>
>
<
CodeEdit
<
CodeEdit
code=
{
codeFillValue
}
code=
{
codeFillValue
}
...
@@ -152,35 +155,13 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
...
@@ -152,35 +155,13 @@ const DocumentForm: React.FC<DocumentFormProps> = (props) => {
label=
{
l
(
'rc.doc.description'
)
}
label=
{
l
(
'rc.doc.description'
)
}
placeholder=
{
l
(
'rc.doc.descriptionPlaceholder'
)
}
placeholder=
{
l
(
'rc.doc.descriptionPlaceholder'
)
}
/>
/>
<
ProFormSelect
name=
'version'
label=
{
l
(
'rc.doc.version'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.doc.versionPlaceholder'
)
}]
}
options=
{
VERSION_OPTIONS
}
/>
<
ProFormSwitch
name=
'enabled'
label=
{
l
(
'global.table.isEnable'
)
}
checkedChildren=
{
l
(
'button.enable'
)
}
unCheckedChildren=
{
l
(
'button.disable'
)
}
/>
</>
</>
);
);
};
};
return
(
return
(
<>
<>
<
ProForm
{
documentFormRender
()
}
{
...
FORM_LAYOUT_PUBLIC
}
form=
{
form
}
submitter=
{
false
}
layout=
{
'horizontal'
}
initialValues=
{
values
}
>
{
documentFormRender
()
}
</
ProForm
>
</>
</>
);
);
};
};
...
...
dinky-web/src/pages/RegCenter/Document/components/DocumentModal/index.tsx
View file @
678817b5
...
@@ -19,11 +19,12 @@
...
@@ -19,11 +19,12 @@
import
{
FormContextValue
}
from
'@/components/Context/FormContext'
;
import
{
FormContextValue
}
from
'@/components/Context/FormContext'
;
import
DocumentForm
from
'@/pages/RegCenter/Document/components/DocumentModal/DocumentForm'
;
import
DocumentForm
from
'@/pages/RegCenter/Document/components/DocumentModal/DocumentForm'
;
import
{
NORMAL_MODAL_OPTIONS
}
from
'@/services/constants'
;
import
{
MODAL_FORM_OPTIONS
}
from
'@/services/constants'
;
import
{
Document
}
from
'@/types/RegCenter/data'
;
import
{
Document
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
Form
,
Modal
}
from
'antd'
;
import
{
Form
}
from
'antd'
;
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
{
ModalForm
}
from
"@ant-design/pro-components"
;
type
DocumentModalProps
=
{
type
DocumentModalProps
=
{
onCancel
:
(
flag
?:
boolean
)
=>
void
;
onCancel
:
(
flag
?:
boolean
)
=>
void
;
...
@@ -68,26 +69,28 @@ const DocumentModalForm: React.FC<DocumentModalProps> = (props) => {
...
@@ -68,26 +69,28 @@ const DocumentModalForm: React.FC<DocumentModalProps> = (props) => {
/**
/**
* submit form
* submit form
*/
*/
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
(
formValue
:
Partial
<
Document
>
)
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
await
form
.
validateFields
();
handleSubmit
({
...
values
,
...
f
ields
Value
});
handleSubmit
({
...
values
,
...
f
orm
Value
});
await
handleCancel
();
await
handleCancel
();
};
};
return
(
return
(
<
Modal
<
Modal
Form
<
Partial
<
Document
>
>
{
...
NORMAL_MODAL
_OPTIONS
}
{
...
MODAL_FORM
_OPTIONS
}
title=
{
values
.
id
?
l
(
'rc.doc.modify'
)
:
l
(
'rc.doc.create'
)
}
title=
{
values
.
id
?
l
(
'rc.doc.modify'
)
:
l
(
'rc.doc.create'
)
}
open=
{
modalVisible
}
open=
{
modalVisible
}
okButtonProps=
{
{
form=
{
form
}
htmlType
:
'submit'
,
initialValues=
{
values
}
autoFocus
:
true
modalProps=
{
{
onCancel
:
handleCancel
,
destroyOnClose
:
true
}
}
}
}
onOk=
{
()
=>
submitForm
()
}
onFinish=
{
submitForm
}
onCancel=
{
()
=>
handleCancel
()
}
>
>
<
DocumentForm
values=
{
values
}
form=
{
form
}
/>
<
DocumentForm
values=
{
values
}
form=
{
form
}
/>
</
Modal
>
</
Modal
Form
>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment