Skip to content

Commit 1c1672f

Browse files
committed
Impl [Jobs] Change runs grouping behavior
1 parent a646aaa commit 1c1672f

File tree

16 files changed

+154
-214
lines changed

16 files changed

+154
-214
lines changed

src/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ const App = () => {
125125
<Route path="projects" element={<Projects />} />
126126
<Route path={`projects/*/${JOBS_MONITORING_PAGE}/*`} element={<ProjectsJobsMonitoring />}>
127127
{[
128-
`${JOBS_MONITORING_JOBS_TAB}/:jobName/:jobProjectName/:jobId/:tab`,
129-
`${JOBS_MONITORING_JOBS_TAB}/:jobProjectName/:jobId/:tab`,
128+
`${JOBS_MONITORING_JOBS_TAB}/:jobName/:jobId/:tab`,
129+
`${JOBS_MONITORING_JOBS_TAB}/:jobId/:tab`,
130130
`${JOBS_MONITORING_JOBS_TAB}/:jobName`,
131131
`${JOBS_MONITORING_JOBS_TAB}`
132132
].map((path, index) => {

src/common/Pagination/Pagination.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ such restriction.
2020
import React, { useCallback, useMemo, useRef } from 'react'
2121
import PropTypes from 'prop-types'
2222
import classnames from 'classnames'
23-
import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
24-
import { isEmpty, max, min } from 'lodash'
23+
import { useNavigate, useSearchParams } from 'react-router-dom'
24+
import { max, min } from 'lodash'
2525

2626
import { RoundedIcon } from 'igz-controls/components'
2727

@@ -36,7 +36,7 @@ import {
3636
ITEMS_COUNT_START
3737
} from '../../constants'
3838
import { PAGINATION_CONFIG } from '../../types'
39-
import { getDefaultCloseDetailsLink } from '../../utils/link-helper.util'
39+
import { getCloseDetailsLink } from '../../utils/link-helper.util'
4040

4141
import { ReactComponent as DoubleArrow } from 'igz-controls/images/pagination-double-arrow.svg'
4242
import { ReactComponent as Arrow } from 'igz-controls/images/pagination-arrow.svg'
@@ -45,10 +45,9 @@ import './pagination.scss'
4545

4646
const threeDotsString = '...'
4747

48-
const Pagination = ({ page, paginationConfig, selectedItem = {} }) => {
48+
const Pagination = ({ page, paginationConfig, selectedItemName = '' }) => {
4949
const [, setSearchParams] = useSearchParams()
5050
const navigate = useNavigate()
51-
const params = useParams()
5251
const paginationPagesRef = useRef()
5352
const leftSideRef = useRef(0)
5453
const rightSideRef = useRef(0)
@@ -78,10 +77,10 @@ const Pagination = ({ page, paginationConfig, selectedItem = {} }) => {
7877
}, [paginationConfig])
7978

8079
const handlePageChange = useCallback(() => {
81-
if (!isEmpty(selectedItem)) {
82-
navigate(getDefaultCloseDetailsLink(params, page), { replace: true })
80+
if (selectedItemName) {
81+
navigate(getCloseDetailsLink(selectedItemName, true), { replace: true })
8382
}
84-
}, [navigate, page, params, selectedItem])
83+
}, [navigate, selectedItemName])
8584

8685
const paginationItems = useMemo(() => {
8786
if (!paginationConfig[FE_PAGE]) return []
@@ -309,7 +308,7 @@ const Pagination = ({ page, paginationConfig, selectedItem = {} }) => {
309308
Pagination.propTypes = {
310309
page: PropTypes.string.isRequired,
311310
paginationConfig: PAGINATION_CONFIG.isRequired,
312-
selectedItem: PropTypes.shape({})
311+
selectedItemName: PropTypes.string
313312
}
314313

315314
export default Pagination

src/components/Jobs/Jobs.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ such restriction.
2020
import React, { useEffect, useState, useMemo, useLayoutEffect, useCallback } from 'react'
2121
import { useSelector } from 'react-redux'
2222
import { useNavigate, useParams, Outlet, useLocation } from 'react-router-dom'
23-
import { defaultsDeep } from 'lodash'
23+
import { defaultsDeep, isEmpty } from 'lodash'
2424

2525
import Breadcrumbs from '../../common/Breadcrumbs/Breadcrumbs'
2626
import ContentMenu from '../../elements/ContentMenu/ContentMenu'
@@ -64,6 +64,7 @@ export const JobsContext = React.createContext({})
6464
const Jobs = () => {
6565
const [confirmData, setConfirmData] = useState(null)
6666
const [selectedTab, setSelectedTab] = useState(null)
67+
const [selectedJob, setSelectedJob] = useState({})
6768
const params = useParams()
6869
const navigate = useNavigate()
6970
const location = useLocation()
@@ -98,6 +99,7 @@ const Jobs = () => {
9899
abortJobRef,
99100
abortingJobs,
100101
editableItem,
102+
fetchJobFunctionsPromiseRef,
101103
getWorkflows,
102104
handleMonitoring,
103105
handleRefreshJobs,
@@ -122,7 +124,11 @@ const Jobs = () => {
122124
setScheduledJobs,
123125
setSearchParams,
124126
terminateAbortTasksPolling
125-
} = useJobsPageData(initialTabData, selectedTab)
127+
} = useJobsPageData(
128+
setSelectedJob,
129+
initialTabData,
130+
selectedTab
131+
)
126132

127133
const handleActionsMenuClick = () => {
128134
setJobWizardMode(PANEL_CREATE_MODE)
@@ -229,11 +235,13 @@ const Jobs = () => {
229235
}
230236
]}
231237
autoRefreshIsEnabled={selectedTab === MONITOR_JOBS_TAB}
232-
autoRefreshIsStopped={jobWizardIsOpened || jobsStore.loading}
238+
autoRefreshIsStopped={
239+
jobWizardIsOpened || jobsStore.loading || !isEmpty(selectedJob)
240+
}
233241
filters={filters}
234242
filtersConfig={tabData[selectedTab].filtersConfig}
235243
handleRefresh={tabData[selectedTab].handleRefresh}
236-
hidden={Boolean(params.jobId || params.workflowId)}
244+
hidden={Boolean(params.workflowId)}
237245
key={selectedTab}
238246
page={JOBS_MONITORING_PAGE}
239247
setSearchParams={setSearchParams}
@@ -251,6 +259,7 @@ const Jobs = () => {
251259
abortJobRef,
252260
abortingJobs,
253261
editableItem,
262+
fetchJobFunctionsPromiseRef,
254263
getWorkflows,
255264
handleRerunJob,
256265
jobRuns,
@@ -266,6 +275,7 @@ const Jobs = () => {
266275
scheduledFiltersConfig: tabData[SCHEDULE_TAB].filtersConfig,
267276
scheduledJobs,
268277
searchParams,
278+
selectedJob,
269279
setAbortingJobs,
270280
setConfirmData,
271281
setEditableItem,
@@ -274,6 +284,7 @@ const Jobs = () => {
274284
setJobWizardMode,
275285
setJobs,
276286
setScheduledJobs,
287+
setSelectedJob,
277288
tabData,
278289
terminateAbortTasksPolling,
279290
workflowsFiltersConfig: tabData[MONITOR_WORKFLOWS_TAB].filtersConfig

src/components/Jobs/MonitorJobs/MonitorJobs.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
1717
under the Apache 2.0 license is conditioned upon your compliance with
1818
such restriction.
1919
*/
20-
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
20+
import React, { useCallback, useEffect, useMemo, useRef } from 'react'
2121
import { useParams } from 'react-router-dom'
2222
import { useDispatch } from 'react-redux'
2323

@@ -33,24 +33,26 @@ import { useFiltersFromSearchParams } from '../../../hooks/useFiltersFromSearchP
3333
import { getSavedSearchParams } from '../../../utils/filter.util'
3434

3535
const MonitorJobs = () => {
36-
const [selectedJob, setSelectedJob] = useState({})
3736
const params = useParams()
3837
const dispatch = useDispatch()
3938
const { isStagingMode } = useMode()
4039
const {
4140
abortControllerRef,
4241
abortJobRef,
4342
abortingJobs,
43+
fetchJobFunctionsPromiseRef,
4444
jobRuns,
4545
jobs,
4646
jobsFiltersConfig,
4747
paginatedJobs,
4848
refreshJobs,
4949
requestErrorMessage,
5050
searchParams,
51+
selectedJob,
5152
setAbortingJobs,
5253
setJobRuns,
5354
setJobs,
55+
setSelectedJob,
5456
tabData,
5557
terminateAbortTasksPolling
5658
} = React.useContext(JobsContext)
@@ -97,7 +99,7 @@ const MonitorJobs = () => {
9799
jobsAreInitializedRef.current = false
98100
terminateAbortTasksPolling()
99101
}
100-
}, [params.projectName, params.jobName, params.jobId, terminateAbortTasksPolling])
102+
}, [params.projectName, params.jobName, terminateAbortTasksPolling])
101103

102104
return (
103105
<>
@@ -111,9 +113,10 @@ const MonitorJobs = () => {
111113
jobs={jobs}
112114
navigateLink={getBackLink()}
113115
paginatedJobs={paginatedJobs}
114-
ref={{ abortJobRef }}
116+
ref={{ abortJobRef, fetchJobFunctionsPromiseRef }}
115117
refreshJobs={refreshJobs}
116118
requestErrorMessage={requestErrorMessage}
119+
searchParams={searchParams}
117120
selectedJob={selectedJob}
118121
setAbortingJobs={setAbortingJobs}
119122
setJobRuns={setJobRuns}

src/components/Jobs/MonitorJobs/monitorJobs.util.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ under the Apache 2.0 license is conditioned upon your compliance with
1818
such restriction.
1919
*/
2020
import React from 'react'
21-
import { isEmpty, debounce } from 'lodash'
21+
import { isEmpty } from 'lodash'
2222

2323
import { FUNCTION_RUN_KINDS } from '../../../constants'
2424
import {
@@ -112,12 +112,3 @@ export const generateActionsMenu = (
112112
]
113113
}
114114
}
115-
116-
export const fetchInitialJobs = debounce(
117-
(filters, selectedJob, jobId, refreshJobs, jobsAreInitializedRef) => {
118-
if (isEmpty(selectedJob) && !jobId && !jobsAreInitializedRef.current) {
119-
refreshJobs(filters)
120-
jobsAreInitializedRef.current = true
121-
}
122-
}
123-
)

src/components/Jobs/jobs.util.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ export const rerunJob = async (job, setEditableItem, setJobWizardMode, dispatch)
243243
}
244244

245245
export const handleAbortJob = (
246-
projectName,
247246
job,
248247
setNotification,
249248
refreshJobs,
@@ -262,7 +261,7 @@ export const handleAbortJob = (
262261
})
263262
)
264263

265-
dispatch(abortJob({ projectName, job }))
264+
dispatch(abortJob({ projectName: job.project, job }))
266265
.unwrap()
267266
.then(response => {
268267
const abortTaskId = get(response, 'metadata.name', '')
@@ -279,13 +278,13 @@ export const handleAbortJob = (
279278
}
280279
}
281280

282-
pollAbortingJobs(projectName, abortJobRef, newAbortingJobs, refreshJobs, dispatch)
281+
pollAbortingJobs(job.project, abortJobRef, newAbortingJobs, refreshJobs, dispatch)
283282

284283
return newAbortingJobs
285284
})
286285
} else {
287286
pollAbortingJobs(
288-
projectName,
287+
job.project,
289288
abortJobRef,
290289
{
291290
[abortTaskId]: {
@@ -301,7 +300,6 @@ export const handleAbortJob = (
301300
.catch(error => {
302301
showErrorNotification(dispatch, error, 'Failed to abort job', '', () =>
303302
handleAbortJob(
304-
projectName,
305303
job,
306304
setNotification,
307305
refreshJobs,
@@ -383,7 +381,6 @@ const abortJobSuccessHandler = (dispatch, job) => {
383381
* Enriches a job run object with the associated function tag(s)
384382
* @param {Object} jobRun - The job run object to enrich
385383
* @param {Object} dispatch - dispatch method
386-
* @param {Function} fetchJobFunctions - The function to fetch job functions from an API
387384
* @param {Object} fetchJobFunctionsPromiseRef - A ref object used to store a reference to
388385
* the promise returned by the `fetchJobFunctions` function.
389386
* @returns {Promise<Object>} A Promise that resolves with the enriched job run object
@@ -445,7 +442,9 @@ export const handleDeleteJob = (isJobRunSelected, job, refreshJobs, filters, dis
445442
)
446443
})
447444
.catch(error => {
448-
showErrorNotification(dispatch, error, 'Deleting job failed', '', () => handleDeleteJob(job))
445+
showErrorNotification(dispatch, error, 'Deleting job failed', '', () =>
446+
handleDeleteJob(isJobRunSelected, job, refreshJobs, filters, dispatch)
447+
)
449448
})
450449
}
451450

src/components/ProjectsJobsMonitoring/JobsMonitoring/JobsMonitoring.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
1717
under the Apache 2.0 license is conditioned upon your compliance with
1818
such restriction.
1919
*/
20-
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react'
20+
import React, { useMemo, useEffect, useRef, useCallback } from 'react'
2121
import { useParams } from 'react-router-dom'
2222

2323
import JobsTable from '../../../elements/JobsTable/JobsTable'
@@ -35,25 +35,27 @@ import { useFiltersFromSearchParams } from '../../../hooks/useFiltersFromSearchP
3535
import { getSavedSearchParams } from '../../../utils/filter.util'
3636

3737
const JobsMonitoring = () => {
38-
const [selectedJob, setSelectedJob] = useState({})
3938
const params = useParams()
4039
const { isStagingMode } = useMode()
4140
const {
4241
abortControllerRef,
4342
abortJobRef,
4443
abortingJobs,
44+
fetchJobFunctionsPromiseRef,
4545
jobRuns,
4646
jobs,
4747
jobsFiltersConfig,
48-
requestErrorMessage,
48+
paginatedJobs,
4949
refreshJobs,
50+
requestErrorMessage,
51+
searchParams,
52+
selectedJob,
5053
setAbortingJobs,
5154
setJobRuns,
5255
setJobs,
53-
terminateAbortTasksPolling,
56+
setSelectedJob,
5457
tabData,
55-
paginatedJobs,
56-
searchParams
58+
terminateAbortTasksPolling
5759
} = React.useContext(ProjectJobsMonitoringContext)
5860
const jobsAreInitializedRef = useRef(false)
5961

@@ -95,16 +97,17 @@ const JobsMonitoring = () => {
9597
{params.jobName && <TableTop link={getBackLink(true)} text={params.jobName} />}
9698
<JobsTable
9799
abortingJobs={abortingJobs}
98-
ref={{ abortJobRef }}
99100
context={ProjectJobsMonitoringContext}
100101
filters={filters}
101102
filtersConfig={jobsFiltersConfig}
102103
jobRuns={jobRuns}
103104
jobs={jobs}
104-
paginatedJobs={paginatedJobs}
105-
requestErrorMessage={requestErrorMessage}
106105
navigateLink={getBackLink()}
106+
paginatedJobs={paginatedJobs}
107+
ref={{ abortJobRef, fetchJobFunctionsPromiseRef }}
107108
refreshJobs={() => refreshJobs(filters)}
109+
requestErrorMessage={requestErrorMessage}
110+
searchParams={searchParams}
108111
selectedJob={selectedJob}
109112
setAbortingJobs={setAbortingJobs}
110113
setJobRuns={setJobRuns}

0 commit comments

Comments
 (0)