@@ -3,18 +3,22 @@ import ActionGroup from './TableActionGroup';
3
3
import { useSelector } from 'react-redux' ;
4
4
import { useActionDispatch } from '../../../hooks/useActionDispatch' ;
5
5
import {
6
- getTableSchedulingGroup , resetTableSchedulingGroup , setIsUpdatedSchedulingGroup ,
6
+ getTableSchedulingGroup ,
7
+ resetTableSchedulingGroup ,
8
+ setIsUpdatedSchedulingGroup ,
7
9
setUpdatedSchedulingGroup ,
8
10
updateTableSchedulingGroup
9
11
} from '../../../redux/actions/table.actions' ;
10
- import { useHistory , useParams } from "react-router-dom" ;
11
- import ScheduleView from "../../ScheduleView" ;
12
- import { CheckRunMonitoringScheduleGroup } from "../../../shared/enums/scheduling.enum" ;
13
- import Tabs from "../../Tabs" ;
14
- import { getFirstLevelActiveTab , getFirstLevelState } from "../../../redux/selectors" ;
15
- import { CheckTypes } from "../../../shared/routes" ;
16
- import qs from "query-string" ;
17
-
12
+ import { useHistory , useParams } from 'react-router-dom' ;
13
+ import ScheduleView from '../../ScheduleView' ;
14
+ import { CheckRunMonitoringScheduleGroup } from '../../../shared/enums/scheduling.enum' ;
15
+ import Tabs from '../../Tabs' ;
16
+ import {
17
+ getFirstLevelActiveTab ,
18
+ getFirstLevelState
19
+ } from '../../../redux/selectors' ;
20
+ import { CheckTypes } from '../../../shared/routes' ;
21
+ import qs from 'query-string' ;
18
22
19
23
const pageTabs = [
20
24
{
@@ -36,33 +40,63 @@ const pageTabs = [
36
40
{
37
41
label : 'Partition Monthly' ,
38
42
value : CheckRunMonitoringScheduleGroup . partitioned_monthly
39
- } ,
40
- ]
43
+ }
44
+ ] ;
41
45
42
46
const ScheduleDetail = ( ) => {
43
- const { checkTypes, connection : connectionName , schema : schemaName , table : tableName } : { checkTypes : CheckTypes , connection : string , schema : string , table : string } = useParams ( ) ;
47
+ const {
48
+ checkTypes,
49
+ connection : connectionName ,
50
+ schema : schemaName ,
51
+ table : tableName
52
+ } : {
53
+ checkTypes : CheckTypes ;
54
+ connection : string ;
55
+ schema : string ;
56
+ table : string ;
57
+ } = useParams ( ) ;
44
58
const [ tabs , setTabs ] = useState ( pageTabs ) ;
45
- const { activeTab = CheckRunMonitoringScheduleGroup . profiling } = qs . parse ( location . search ) as any ;
59
+ const { activeTab = CheckRunMonitoringScheduleGroup . profiling } = qs . parse (
60
+ location . search
61
+ ) as any ;
46
62
47
- const { isUpdating, scheduleGroups } = useSelector ( getFirstLevelState ( checkTypes ) ) ;
63
+ const { isUpdating, scheduleGroups } = useSelector (
64
+ getFirstLevelState ( checkTypes )
65
+ ) ;
48
66
const updatedSchedule = scheduleGroups ?. [ activeTab ] ?. updatedSchedule ;
49
67
const isUpdatedSchedule = scheduleGroups ?. [ activeTab ] ?. isUpdatedSchedule ;
50
68
const firstLevelActiveTab = useSelector ( getFirstLevelActiveTab ( checkTypes ) ) ;
51
69
const history = useHistory ( ) ;
52
70
53
71
const dispatch = useActionDispatch ( ) ;
54
72
const onChangeTab = ( tab : CheckRunMonitoringScheduleGroup ) => {
55
- history . push ( `${ location . pathname } ?activeTab=${ tab } ` )
56
- }
73
+ history . push ( `${ location . pathname } ?activeTab=${ tab } ` ) ;
74
+ } ;
57
75
58
76
useEffect ( ( ) => {
59
77
if ( updatedSchedule === null || updatedSchedule === undefined ) {
60
- dispatch ( getTableSchedulingGroup ( checkTypes , firstLevelActiveTab , connectionName , schemaName , tableName , activeTab ) ) ;
78
+ dispatch (
79
+ getTableSchedulingGroup (
80
+ checkTypes ,
81
+ firstLevelActiveTab ,
82
+ connectionName ,
83
+ schemaName ,
84
+ tableName ,
85
+ activeTab
86
+ )
87
+ ) ;
61
88
}
62
89
} , [ connectionName , schemaName , tableName , activeTab , updatedSchedule ] ) ;
63
90
64
91
const handleChange = ( obj : any ) => {
65
- dispatch ( setIsUpdatedSchedulingGroup ( checkTypes , firstLevelActiveTab , activeTab , true ) ) ;
92
+ dispatch (
93
+ setIsUpdatedSchedulingGroup (
94
+ checkTypes ,
95
+ firstLevelActiveTab ,
96
+ activeTab ,
97
+ true
98
+ )
99
+ ) ;
66
100
dispatch (
67
101
setUpdatedSchedulingGroup ( checkTypes , firstLevelActiveTab , activeTab , {
68
102
...updatedSchedule ,
@@ -76,22 +110,50 @@ const ScheduleDetail = () => {
76
110
return ;
77
111
}
78
112
await dispatch (
79
- updateTableSchedulingGroup ( checkTypes , firstLevelActiveTab , connectionName , schemaName , tableName , activeTab , updatedSchedule )
113
+ updateTableSchedulingGroup (
114
+ checkTypes ,
115
+ firstLevelActiveTab ,
116
+ connectionName ,
117
+ schemaName ,
118
+ tableName ,
119
+ activeTab ,
120
+ updatedSchedule
121
+ )
122
+ ) ;
123
+ await dispatch (
124
+ getTableSchedulingGroup (
125
+ checkTypes ,
126
+ firstLevelActiveTab ,
127
+ connectionName ,
128
+ schemaName ,
129
+ tableName ,
130
+ activeTab
131
+ )
132
+ ) ;
133
+ dispatch (
134
+ setIsUpdatedSchedulingGroup (
135
+ checkTypes ,
136
+ firstLevelActiveTab ,
137
+ activeTab ,
138
+ false
139
+ )
80
140
) ;
81
- await dispatch ( getTableSchedulingGroup ( checkTypes , firstLevelActiveTab , connectionName , schemaName , tableName , activeTab ) ) ;
82
- dispatch ( setIsUpdatedSchedulingGroup ( checkTypes , firstLevelActiveTab , activeTab , false ) ) ;
83
141
} ;
84
142
85
143
useEffect ( ( ) => {
86
- setTabs ( prev => prev . map ( tab => tab . value === activeTab ? ( { ...tab , isUpdated : isUpdatedSchedule } ) : tab ) )
87
- } , [ isUpdatedSchedule , activeTab ] )
144
+ setTabs ( ( prev ) =>
145
+ prev . map ( ( tab ) =>
146
+ tab . value === activeTab ? { ...tab , isUpdated : isUpdatedSchedule } : tab
147
+ )
148
+ ) ;
149
+ } , [ isUpdatedSchedule , activeTab ] ) ;
88
150
89
151
useEffect ( ( ) => {
90
- setTabs ( prev => prev . map ( tab => ( { ...tab , isUpdate : false } ) ) )
152
+ setTabs ( ( prev ) => prev . map ( ( tab ) => ( { ...tab , isUpdate : false } ) ) ) ;
91
153
dispatch ( resetTableSchedulingGroup ( checkTypes , firstLevelActiveTab ) ) ;
92
- } , [ checkTypes , firstLevelActiveTab ] )
154
+ } , [ checkTypes , firstLevelActiveTab ] ) ;
93
155
return (
94
- < div className = "py-4 px-8 " >
156
+ < div className = "py-2 " >
95
157
< ActionGroup
96
158
onUpdate = { onUpdate }
97
159
isUpdated = { isUpdatedSchedule }
@@ -100,7 +162,9 @@ const ScheduleDetail = () => {
100
162
< div className = "border-b border-gray-300" >
101
163
< Tabs tabs = { tabs } activeTab = { activeTab } onChange = { onChangeTab } />
102
164
</ div >
103
- < ScheduleView handleChange = { handleChange } schedule = { updatedSchedule } />
165
+ < div className = "px-8" >
166
+ < ScheduleView handleChange = { handleChange } schedule = { updatedSchedule } />
167
+ </ div >
104
168
</ div >
105
169
) ;
106
170
} ;
0 commit comments