Skip to content

Commit

Permalink
Fix [Workflows] TypeError: e.includes is not a function (#2836)
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-prokopchuk authored Oct 21, 2024
1 parent 69b41b0 commit 45ba01a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ const DetailsTabsContent = ({
return (
<DetailsCode
code={
selectedItem.build.functionSourceCode ??
selectedItem.base_spec.spec?.build?.functionSourceCode
selectedItem.build?.functionSourceCode ??
selectedItem.base_spec?.spec?.build?.functionSourceCode ?? ''
}
/>
)
Expand Down
12 changes: 7 additions & 5 deletions src/components/DetailsArtifacts/DetailsArtifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ const DetailsArtifacts = ({
useEffect(() => {
if (!isNaN(parseInt(bestIteration))) {
setIteration(`${bestIteration}`)
} else if (selectedItem.iterationStats.length > 0 && iterationOptions.length > 0) {
} else if (selectedItem.iterationStats?.length > 0 && iterationOptions?.length > 0) {
setIteration(iterationOptions[0].id)
}

Expand Down Expand Up @@ -175,10 +175,12 @@ const DetailsArtifacts = ({
)

useEffect(() => {
if (selectedItem.iterationStats.length > 0 && iteration) {
getJobArtifacts(selectedItem, iteration)
} else if (selectedItem.iterationStats.length === 0) {
getJobArtifacts(selectedItem, null)
if (params.jobId === selectedItem.uid) {
if (selectedItem.iterationStats?.length > 0 && iteration) {
getJobArtifacts(selectedItem, iteration)
} else if (selectedItem.iterationStats?.length === 0) {
getJobArtifacts(selectedItem, null)
}
}
}, [getJobArtifacts, iteration, params.jobId, params.projectName, selectedItem])

Expand Down
6 changes: 3 additions & 3 deletions src/components/Jobs/jobs.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ illegal under applicable law, and the grant of the foregoing license
under the Apache 2.0 license is conditioned upon your compliance with
such restriction.
*/
import { get } from 'lodash'
import { get, isObject } from 'lodash'

import tasksApi from '../../api/tasks-api'

Expand All @@ -38,7 +38,7 @@ import {
FAILED_STATE
} from '../../constants'
import jobsActions from '../../actions/jobs'
import { generateKeyValues, truncateUid } from '../../utils'
import { generateKeyValues, parseKeyValues, truncateUid } from '../../utils'
import { BG_TASK_FAILED, BG_TASK_SUCCEEDED, pollTask } from '../../utils/poll.util'
import { setNotification } from '../../reducers/notificationReducer'
import { showErrorNotification } from '../../utils/notifications.util'
Expand Down Expand Up @@ -129,7 +129,7 @@ export const isJobAborting = (currentJob = {}) => {
}

export const isJobKindDask = (jobLabels = []) => {
return jobLabels?.includes(`kind: ${JOB_KIND_DASK}`)
return (isObject(jobLabels) ? parseKeyValues(jobLabels) : jobLabels)?.includes(`kind: ${JOB_KIND_DASK}`)
}

export const isJobKindLocal = job =>
Expand Down
5 changes: 3 additions & 2 deletions src/components/Workflow/Workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,14 @@ const Workflow = ({
? getWorkflowMonitoringDetailsLink(
params.workflowProjectName,
params.workflowId,
node.data.customData
node.data.customData,
params.tab
)
: getWorkflowDetailsLink(
params.projectName,
params.workflowId,
node.data.customData,
null,
params.tab,
MONITOR_WORKFLOWS_TAB
)

Expand Down
1 change: 0 additions & 1 deletion src/elements/WorkflowsTable/WorkflowsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ const WorkflowsTable = React.forwardRef(
checkIfWorkflowItemIsJob() && !dataIsLoading
) {
setDataIsLoading(true)

fetchRun().finally(() => setDataIsLoading(false))
}
}, [fetchRun, params.jobId, selectedJob, checkIfWorkflowItemIsJob, dataIsLoading])
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useSortTable.hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useSortTable = ({ headers, content, sortConfig = {} }) => {

const isDateValid = date => {
const dateString = String(date)

if (Date.parse(dateString)) {
return !(dateString.match(/-/g) && !dateString.split('-').every(char => isNumber(char)))
}
Expand Down Expand Up @@ -179,7 +179,10 @@ export const useSortTable = ({ headers, content, sortConfig = {} }) => {

if (columnName) {
const sorted = orderBy(content, getValueByType(columnIndex), sortDirection)
setSortedTableContent(sorted)

setSortedTableContent(prevState => {
return isEqual(prevState, sorted) ? prevState : sorted
})
}

setSelectedColumnName(columnName)
Expand Down
10 changes: 5 additions & 5 deletions src/utils/createJobsContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ export const createJobsWorkflowsTabContent = (jobs, projectName, isStagingMode,
value: jobName,
className: 'table-cell-name',
type: 'link',
getLink: () => {
return getWorkflowDetailsLink(projectName, job.id, null, null, MONITOR_WORKFLOWS_TAB)
getLink: tab => {
return getWorkflowDetailsLink(projectName, job.id, null, tab, MONITOR_WORKFLOWS_TAB)
},
showStatus: true
},
Expand Down Expand Up @@ -353,7 +353,7 @@ export const createJobsWorkflowContent = (
type: 'link',
getLink: tab => {
return workflowProjectName
? getWorkflowMonitoringDetailsLink(workflowProjectName, workflowId, job.customData)
? getWorkflowMonitoringDetailsLink(workflowProjectName, workflowId, job.customData, tab)
: getWorkflowDetailsLink(
projectName,
workflowId,
Expand Down Expand Up @@ -649,8 +649,8 @@ export const createWorkflowsMonitoringContent = (jobs, isStagingMode, isSelected
value: jobName,
className: 'table-cell-name',
type: 'link',
getLink: () => {
return getWorkflowMonitoringDetailsLink(job.project, job.id)
getLink: tab => {
return getWorkflowMonitoringDetailsLink(job.project, job.id, null, tab)
},
showStatus: true
},
Expand Down

0 comments on commit 45ba01a

Please sign in to comment.