-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import * as React from 'react'; | ||
import { | ||
Spinner, | ||
EmptyStateVariant, | ||
EmptyState, | ||
EmptyStateBody, | ||
EmptyStateHeader, | ||
} from '@patternfly/react-core'; | ||
import { | ||
InputDefinitionParameterType, | ||
PipelineRecurringRunKFv2, | ||
PipelineRunKFv2, | ||
PipelineSpecVariable, | ||
} from '~/concepts/pipelines/kfTypes'; | ||
import { | ||
DetailItem, | ||
renderDetailItems, | ||
} from '~/concepts/pipelines/content/pipelinesDetails/pipelineRun/utils'; | ||
import { ExecutionDetailsPropertiesValueCode } from '~/pages/pipelines/global/experiments/executions/details/ExecutionDetailsPropertiesValue'; | ||
|
||
type PipelineRunTabParametersProps = { | ||
run: PipelineRecurringRunKFv2 | PipelineRunKFv2 | null; | ||
pipelineSpec: PipelineSpecVariable | undefined; | ||
}; | ||
|
||
const PipelineRunTabParameters: React.FC<PipelineRunTabParametersProps> = ({ | ||
run, | ||
pipelineSpec, | ||
}) => { | ||
if (!run) { | ||
return ( | ||
Check warning on line 31 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx Codecov / codecov/patchfrontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L31
|
||
<EmptyState variant={EmptyStateVariant.lg} data-id="loading-empty-state"> | ||
<Spinner size="xl" /> | ||
<EmptyStateHeader titleText="Loading" headingLevel="h4" /> | ||
</EmptyState> | ||
); | ||
} | ||
|
||
const specParameters = | ||
pipelineSpec?.root?.inputDefinitions?.parameters || | ||
pipelineSpec?.pipeline_spec?.root.inputDefinitions?.parameters; | ||
|
||
const parameters = run.runtime_config?.parameters | ||
? Object.entries(run.runtime_config.parameters) | ||
: []; | ||
|
||
if (parameters.length === 0) { | ||
return ( | ||
<EmptyState variant={EmptyStateVariant.lg} data-id="parameters-empty-state"> | ||
<EmptyStateHeader titleText="No parameters" headingLevel="h2" /> | ||
<EmptyStateBody>This pipeline run does not have any parameters defined.</EmptyStateBody> | ||
</EmptyState> | ||
); | ||
} | ||
|
||
const details: DetailItem[] = parameters.map(([key, initialValue]) => { | ||
let value: React.ReactNode; | ||
const paramType = specParameters?.[key].parameterType; | ||
switch (paramType) { | ||
case InputDefinitionParameterType.DOUBLE: | ||
value = Number.isInteger(Number(initialValue)) | ||
? Number(initialValue).toFixed(1) | ||
: Number(initialValue); | ||
break; | ||
Check warning on line 64 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx Codecov / codecov/patchfrontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L60-L64
|
||
case InputDefinitionParameterType.INTEGER: | ||
value = Number(initialValue); | ||
break; | ||
case InputDefinitionParameterType.BOOLEAN: | ||
value = initialValue ? 'True' : 'False'; | ||
break; | ||
case InputDefinitionParameterType.STRING: | ||
value = String(initialValue); | ||
break; | ||
case InputDefinitionParameterType.LIST: | ||
value = ( | ||
Check warning on line 75 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx Codecov / codecov/patchfrontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L74-L75
|
||
<ExecutionDetailsPropertiesValueCode code={JSON.stringify(initialValue, null, 2)} /> | ||
); | ||
break; | ||
case InputDefinitionParameterType.STRUCT: | ||
value = ( | ||
Check warning on line 80 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx Codecov / codecov/patchfrontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L78-L80
|
||
<ExecutionDetailsPropertiesValueCode code={JSON.stringify(initialValue, null, 2)} /> | ||
); | ||
break; | ||
Check warning on line 83 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx Codecov / codecov/patchfrontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunTabParameters.tsx#L83
|
||
default: | ||
value = JSON.stringify(initialValue); | ||
} | ||
return { | ||
key, | ||
value, | ||
}; | ||
}); | ||
|
||
return <>{renderDetailItems(details)}</>; | ||
}; | ||
|
||
export default PipelineRunTabParameters; |