Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix [Workflows] TypeError: e.includes is not a function #2836

Merged
merged 3 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -36,7 +36,7 @@ import {
JOB_KIND_LOCAL
} 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 @@ -127,7 +127,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 @@ -460,7 +460,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 @@ -266,8 +266,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 @@ -352,7 +352,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 @@ -648,8 +648,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
Loading