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
d0e81848
Unverified
Commit
d0e81848
authored
Dec 22, 2023
by
Zzm0809
Committed by
GitHub
Dec 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix alert instance state bug (#2723)
* Spotless Apply * fix-alert-instance-state-bug * Spotless Apply --------- Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
e4bb53b3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
15 deletions
+18
-15
index.tsx
...nstance/components/AlertTypeChoose/InstanceForm/index.tsx
+10
-2
index.tsx
.../Alert/AlertInstance/components/AlertTypeChoose/index.tsx
+8
-13
No files found.
dinky-web/src/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/index.tsx
View file @
d0e81848
...
@@ -41,6 +41,8 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
...
@@ -41,6 +41,8 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
const
[
alertType
,
setAlertType
]
=
useState
<
string
>
(
values
.
type
??
ALERT_TYPE
.
DINGTALK
);
const
[
alertType
,
setAlertType
]
=
useState
<
string
>
(
values
.
type
??
ALERT_TYPE
.
DINGTALK
);
const
[
formValues
,
setFormValues
]
=
useState
<
Partial
<
Alert
.
AlertInstance
>>
(
values
);
const
renderPreForm
=
()
=>
{
const
renderPreForm
=
()
=>
{
return
(
return
(
<>
<>
...
@@ -87,10 +89,16 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
...
@@ -87,10 +89,16 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
return
(
return
(
<>
<>
<
ProForm
form=
{
form
}
submitter=
{
false
}
>
<
ProForm
form=
{
form
}
onValuesChange=
{
(
changedValues
,
allValues
)
=>
setFormValues
((
prevState
)
=>
({
...
prevState
,
...
allValues
,
...
changedValues
}))
}
submitter=
{
false
}
>
<
ProForm
.
Group
>
<
ProForm
.
Group
>
{
renderPreForm
()
}
{
renderPreForm
()
}
{
renderFormByType
(
v
alues
,
alertType
)
}
{
renderFormByType
(
formV
alues
,
alertType
)
}
</
ProForm
.
Group
>
</
ProForm
.
Group
>
</
ProForm
>
</
ProForm
>
</>
</>
...
...
dinky-web/src/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/index.tsx
View file @
d0e81848
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
*/
*/
import
{
Button
,
Form
}
from
'antd'
;
import
{
Button
,
Form
}
from
'antd'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
{
FormContextValue
}
from
'@/components/Context/FormContext'
;
import
{
FormContextValue
}
from
'@/components/Context/FormContext'
;
import
InstanceForm
from
'@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm'
;
import
InstanceForm
from
'@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm'
;
...
@@ -52,8 +52,6 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
...
@@ -52,8 +52,6 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
loading
loading
}
=
props
;
}
=
props
;
const
[
formValues
,
setFormValues
]
=
useState
<
Partial
<
Alert
.
AlertInstance
>>
(
values
);
/**
/**
* init form
* init form
*/
*/
...
@@ -81,17 +79,17 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
...
@@ -81,17 +79,17 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
* when modalVisible or values changed, set form values
* when modalVisible or values changed, set form values
*/
*/
useEffect
(()
=>
{
useEffect
(()
=>
{
form
.
setFieldsValue
(
formV
alues
);
form
.
setFieldsValue
(
v
alues
);
},
[
modalVisible
,
formV
alues
,
form
]);
},
[
modalVisible
,
v
alues
,
form
]);
const
testSend
=
async
()
=>
{
const
testSend
=
async
()
=>
{
const
validateFields
=
await
form
.
validateFields
();
const
validateFields
=
await
form
.
validateFields
();
handleTest
({
...
formV
alues
,
...
validateFields
});
handleTest
({
...
v
alues
,
...
validateFields
});
};
};
const
submit
=
async
()
=>
{
const
submit
=
async
()
=>
{
const
validateFields
=
await
form
.
validateFields
();
const
validateFields
=
await
form
.
validateFields
();
handleSubmit
({
...
formV
alues
,
...
validateFields
});
handleSubmit
({
...
v
alues
,
...
validateFields
});
handleCancel
();
handleCancel
();
};
};
...
@@ -120,18 +118,15 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
...
@@ -120,18 +118,15 @@ const AlertTypeChoose: React.FC<UpdateFormProps> = (props) => {
<>
<>
<
ModalForm
<
Alert
.
AlertInstance
>
<
ModalForm
<
Alert
.
AlertInstance
>
{
...
NORMAL_MODAL_OPTIONS
}
{
...
NORMAL_MODAL_OPTIONS
}
title=
{
formV
alues
?.
id
?
l
(
'rc.ai.modify'
)
:
l
(
'rc.ai.create'
)
}
title=
{
v
alues
?.
id
?
l
(
'rc.ai.modify'
)
:
l
(
'rc.ai.create'
)
}
open=
{
modalVisible
}
open=
{
modalVisible
}
form=
{
form
}
form=
{
form
}
initialValues=
{
formValues
}
initialValues=
{
values
}
onValuesChange=
{
(
changedValues
,
allValues
)
=>
setFormValues
((
prevState
)
=>
({
...
prevState
,
...
allValues
,
...
changedValues
}))
}
modalProps=
{
{
onCancel
:
handleCancel
,
...
NORMAL_MODAL_OPTIONS
}
}
modalProps=
{
{
onCancel
:
handleCancel
,
...
NORMAL_MODAL_OPTIONS
}
}
submitter=
{
{
render
:
()
=>
[...
renderFooter
()]
}
}
submitter=
{
{
render
:
()
=>
[...
renderFooter
()]
}
}
syncToInitialValues
syncToInitialValues
>
>
<
InstanceForm
form=
{
form
}
values=
{
formV
alues
}
/>
<
InstanceForm
form=
{
form
}
values=
{
v
alues
}
/>
</
ModalForm
>
</
ModalForm
>
</>
</>
);
);
...
...
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