1- import React , { useEffect , useMemo , useCallback } from 'react' ;
1+ import React , { useEffect , useMemo } from 'react' ;
22import moment from 'moment' ;
33import { Form , AutoComplete , Button } from 'antd' ;
44import PropTypes from 'prop-types' ;
55import { pipelineStatuses } from '@hkube/consts' ;
6- import { useQuery } from '@apollo/client' ;
6+ import { useQuery , useReactiveVar } from '@apollo/client' ;
77import { ALGORITHM_AND_PIPELINE_NAMES } from 'graphql/queries' ;
88import { FiltersForms } from 'styles' ;
99import { RangePickerNow } from 'components/common' ;
10+ import { isPinActiveJobVar } from 'cache' ;
1011
1112const DateFormat = 'YYYY-MM-DD HH:mm' ;
1213const QueryForm = ( { onSubmit, params, zoomDate } ) => {
1314 const [ form ] = Form . useForm ( ) ;
14-
15+ const isPinActiveJobs = useReactiveVar ( isPinActiveJobVar ) ;
1516 const SubmitForm = ( ) => {
1617 // setLoadingJobs(true);
1718 form . submit ( ) ;
@@ -54,19 +55,15 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
5455 onSubmit ( values ) ;
5556 } ;
5657
57- const isShowActive = useCallback (
58- ( ) => form . getFieldValue ( 'pipelineStatus' ) === 'active' ,
59- [ form ]
60- ) ;
61-
6258 const onPinActive = ( ) => {
63- // isPinActiveJobVar(!isPinActiveJobs);
64-
65- if ( form . getFieldValue ( 'pipelineStatus' ) === 'active' ) {
66- form . setFieldsValue ( { pipelineStatus : null } ) ;
67- } else {
59+ if ( ! isPinActiveJobs ) {
6860 form . setFieldsValue ( { pipelineStatus : 'active' } ) ;
61+ } else {
62+ form . setFieldsValue ( { pipelineStatus : null } ) ;
6963 }
64+
65+ isPinActiveJobVar ( ! isPinActiveJobs ) ;
66+
7067 SubmitForm ( ) ;
7168 } ;
7269
@@ -109,7 +106,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
109106 onFinish = { onFinish }
110107 spacearound = { 1 } >
111108 < Form . Item label = "Time" name = "time" >
112- < RangePickerNow onChange = { SubmitForm } />
109+ < RangePickerNow isDisabled = { isPinActiveJobs } onChange = { SubmitForm } />
113110 </ Form . Item >
114111 < Form . Item label = "Pipeline Name" name = "pipelineName" >
115112 < AutoComplete
@@ -133,6 +130,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
133130 }
134131 onSelect = { SubmitForm }
135132 onClear = { SubmitForm }
133+ disabled = { isPinActiveJobs }
136134 />
137135 </ Form . Item >
138136 < Form . Item label = "Algorithm Name" name = "algorithmName" >
@@ -149,7 +147,7 @@ const QueryForm = ({ onSubmit, params, zoomDate }) => {
149147 </ Form . Item >
150148 < Form . Item >
151149 < Button
152- type = { isShowActive ( ) ? 'primary' : 'dashed' }
150+ type = { isPinActiveJobs ? 'primary' : 'dashed' }
153151 htmlType = "button"
154152 onClick = { onPinActive }
155153 title = "Show Active" >
0 commit comments