Skip to content

Commit

Permalink
Fix [Monitor Jobs] filter by time reset when navigating between pages (
Browse files Browse the repository at this point in the history
  • Loading branch information
Taras-Hlukhovetskyi authored Jan 16, 2025
1 parent 57199ea commit 959d8a4
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 34 deletions.
19 changes: 10 additions & 9 deletions src/components/Jobs/Jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ const Jobs = () => {
}, [navigate, params.pageTab, location])

const filters = useFiltersFromSearchParams(
tabData[selectedTab]?.filtersConfig,
tabData[selectedTab]?.parseQueryParamsCallback
initialTabData[selectedTab]?.filtersConfig,
initialTabData[selectedTab]?.parseQueryParamsCallback
)

return (
Expand Down Expand Up @@ -261,40 +261,41 @@ const Jobs = () => {
<JobsContext.Provider
value={{
abortControllerRef,
abortJobRef,
abortingJobs,
abortJobRef,
autoRefreshPrevValue,
editableItem,
fetchJobFunctionsPromiseRef,
getWorkflows,
handleMonitoring,
handleRerunJob,
autoRefreshPrevValue,
initialTabData,
jobRuns,
jobs,
jobsFiltersConfig: initialTabData[MONITOR_JOBS_TAB].filtersConfig,
jobWizardIsOpened,
jobWizardMode,
jobs,
jobsFiltersConfig: tabData[MONITOR_JOBS_TAB].filtersConfig,
paginatedJobs,
paginationConfigJobsRef,
refreshJobs,
refreshScheduled,
requestErrorMessage,
scheduledFiltersConfig: tabData[SCHEDULE_TAB].filtersConfig,
scheduledFiltersConfig: initialTabData[SCHEDULE_TAB].filtersConfig,
scheduledJobs,
searchParams,
selectedJob,
setAbortingJobs,
setConfirmData,
setEditableItem,
setJobRuns,
setJobs,
setJobWizardIsOpened,
setJobWizardMode,
setJobs,
setScheduledJobs,
setSelectedJob,
tabData,
terminateAbortTasksPolling,
workflowsFiltersConfig: tabData[MONITOR_WORKFLOWS_TAB].filtersConfig
workflowsFiltersConfig: initialTabData[MONITOR_WORKFLOWS_TAB].filtersConfig
}}
>
<Outlet />
Expand Down
10 changes: 5 additions & 5 deletions src/components/Jobs/MonitorJobs/MonitorJobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ const MonitorJobs = () => {
const { isStagingMode } = useMode()
const {
abortControllerRef,
abortJobRef,
abortingJobs,
fetchJobFunctionsPromiseRef,
abortJobRef,
autoRefreshPrevValue,
fetchJobFunctionsPromiseRef,
initialTabData,
jobRuns,
jobs,
jobsFiltersConfig,
Expand All @@ -54,14 +55,13 @@ const MonitorJobs = () => {
setJobRuns,
setJobs,
setSelectedJob,
tabData,
terminateAbortTasksPolling
} = React.useContext(JobsContext)
const jobsAreInitializedRef = useRef(false)

const filters = useFiltersFromSearchParams(
tabData[MONITOR_JOBS_TAB]?.filtersConfig,
tabData[MONITOR_JOBS_TAB]?.parseQueryParamsCallback
initialTabData[MONITOR_JOBS_TAB]?.filtersConfig,
initialTabData[MONITOR_JOBS_TAB]?.parseQueryParamsCallback
)

const tableContent = useMemo(
Expand Down
6 changes: 3 additions & 3 deletions src/components/Jobs/MonitorWorkflows/MonitorWorkflows.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ const MonitorWorkflows = ({ fetchFunctionLogs }) => {
abortJobRef,
dateFilter,
getWorkflows,
initialTabData,
requestErrorMessage,
tabData,
workflowsFiltersConfig
} = React.useContext(JobsContext)
const workflowsAreInitializedRef = useRef(false)

const filters = useFiltersFromSearchParams(
tabData[MONITOR_WORKFLOWS_TAB]?.filtersConfig,
tabData[MONITOR_WORKFLOWS_TAB]?.parseQueryParamsCallback
initialTabData[MONITOR_WORKFLOWS_TAB]?.filtersConfig,
initialTabData[MONITOR_WORKFLOWS_TAB]?.parseQueryParamsCallback
)

usePods(dispatch, detailsActions.fetchJobPods, detailsActions.removePods, selectedJob)
Expand Down
8 changes: 4 additions & 4 deletions src/components/Jobs/ScheduledJobs/ScheduledJobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ const ScheduledJobs = () => {
const [dataIsLoaded, setDataIsLoaded] = useState(false)
const {
abortControllerRef,
initialTabData,
scheduledJobs,
refreshScheduled: refreshJobs,
requestErrorMessage,
setJobs,
scheduledFiltersConfig,
tabData
scheduledFiltersConfig
} = React.useContext(JobsContext)
const dispatch = useDispatch()
const params = useParams()
const filters = useFiltersFromSearchParams(
tabData[SCHEDULE_TAB]?.filtersConfig,
tabData[SCHEDULE_TAB]?.parseQueryParamsCallback
initialTabData[SCHEDULE_TAB]?.filtersConfig,
initialTabData[SCHEDULE_TAB]?.parseQueryParamsCallback
)

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const JobsMonitoring = () => {
abortJobRef,
abortingJobs,
fetchJobFunctionsPromiseRef,
initialTabData,
jobRuns,
jobs,
jobsFiltersConfig,
Expand All @@ -54,14 +55,13 @@ const JobsMonitoring = () => {
setJobRuns,
setJobs,
setSelectedJob,
tabData,
terminateAbortTasksPolling
} = React.useContext(ProjectJobsMonitoringContext)
const jobsAreInitializedRef = useRef(false)

const filters = useFiltersFromSearchParams(
tabData[JOBS_MONITORING_JOBS_TAB]?.filtersConfig,
tabData[JOBS_MONITORING_JOBS_TAB]?.parseQueryParamsCallback
initialTabData[JOBS_MONITORING_JOBS_TAB]?.filtersConfig,
initialTabData[JOBS_MONITORING_JOBS_TAB]?.parseQueryParamsCallback
)

const tableContent = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ const ProjectsJobsMonitoring = () => {
}, [getWorkflows, handleRefreshJobs, initialTabData, refreshScheduled])

const filters = useFiltersFromSearchParams(
tabData[selectedTab]?.filtersConfig,
tabData[selectedTab]?.parseQueryParamsCallback
initialTabData[selectedTab]?.filtersConfig,
initialTabData[selectedTab]?.parseQueryParamsCallback
)

return (
Expand Down Expand Up @@ -194,7 +194,7 @@ const ProjectsJobsMonitoring = () => {
!isEmpty(selectedJob)
}
filters={filters}
filtersConfig={tabData[selectedTab].filtersConfig}
filtersConfig={initialTabData[selectedTab].filtersConfig}
handleRefresh={tabData[selectedTab].handleRefresh}
hidden={Boolean(params.workflowId)}
key={selectedTab}
Expand All @@ -218,6 +218,7 @@ const ProjectsJobsMonitoring = () => {
getWorkflows,
handleMonitoring,
handleRerunJob,
initialTabData,
jobRuns,
jobWizardIsOpened,
jobWizardMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ const ScheduledMonitoring = () => {
const [dataIsLoaded, setDataIsLoaded] = useState(false)
const dispatch = useDispatch()
const {
initialTabData,
requestErrorMessage,
refreshScheduled,
scheduledFiltersConfig,
scheduledJobs,
setScheduledJobs,
tabData
setScheduledJobs
} = React.useContext(ProjectJobsMonitoringContext)

const filters = useFiltersFromSearchParams(
tabData[JOBS_MONITORING_SCHEDULED_TAB]?.filtersConfig,
tabData[JOBS_MONITORING_SCHEDULED_TAB]?.parseQueryParamsCallback
initialTabData[JOBS_MONITORING_SCHEDULED_TAB]?.filtersConfig,
initialTabData[JOBS_MONITORING_SCHEDULED_TAB]?.parseQueryParamsCallback
)

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ const WorkflowsMonitoring = ({ fetchFunctionLogs }) => {
const { isStagingMode } = useMode()
const abortControllerRef = useRef(new AbortController())

const { abortJobRef, getWorkflows, requestErrorMessage, workflowsFiltersConfig, tabData } =
const { abortJobRef, initialTabData, getWorkflows, requestErrorMessage, workflowsFiltersConfig } =
React.useContext(ProjectJobsMonitoringContext)

const filters = useFiltersFromSearchParams(
tabData[JOBS_MONITORING_WORKFLOWS_TAB]?.filtersConfig,
tabData[JOBS_MONITORING_WORKFLOWS_TAB]?.parseQueryParamsCallback
initialTabData[JOBS_MONITORING_WORKFLOWS_TAB]?.filtersConfig,
initialTabData[JOBS_MONITORING_WORKFLOWS_TAB]?.parseQueryParamsCallback
)

usePods(dispatch, detailsActions.fetchJobPods, detailsActions.removePods, selectedJob)
Expand Down

0 comments on commit 959d8a4

Please sign in to comment.