Skip to content

Commit

Permalink
Merge pull request #87 from lokanandaprabhu/feature/pipeline-detail-page
Browse files Browse the repository at this point in the history
ODC-7525: Move the Pipeline details page component to the dynamic plugin
  • Loading branch information
openshift-merge-bot[bot] authored Apr 9, 2024
2 parents 29965e5 + 31ac971 commit 00ee56e
Show file tree
Hide file tree
Showing 118 changed files with 8,540 additions and 60 deletions.
5 changes: 5 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ plugins:
rules:
prettier/prettier:
- error
react/prop-types: off
'@typescript-eslint/no-empty-function': off
'@typescript-eslint/ban-types': off
'@typescript-eslint/no-explicit-any': off
'react/display-name': 0
settings:
react:
version: detect
28 changes: 28 additions & 0 deletions console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,33 @@
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_NAV_OPTION"]
}
},
{
"type": "console.page/resource/details",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1beta1",
"kind": "Pipeline"
},
"component": { "$codeRef": "pipelinesDetails.PipelineDetailsPage" }
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_DETAILS"]
}
},
{
"type": "console.page/resource/details",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1",
"kind": "Pipeline"
},
"component": { "$codeRef": "pipelinesDetails.PipelineDetailsPage" }
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_DETAILS"]
}
}
]
52 changes: 51 additions & 1 deletion locales/en/plugin__pipelines-console-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,31 @@
"{{taskRunLabel}} details": "{{taskRunLabel}} details",
"<0>{{eventCount}} times in the last <3></3></0>": "<0>{{eventCount}} times in the last <3></3></0>",
"<0>{{eventCount}} times</0>": "<0>{{eventCount}} times</0>",
"Add a parallel task": "Add a parallel task",
"Add a sequential task after this task": "Add a sequential task after this task",
"Add a sequential task before this task": "Add a sequential task before this task",
"Add finally task": "Add finally task",
"Add Pipeline parameter": "Add Pipeline parameter",
"Add task": "Add task",
"Add values": "Add values",
"All": "All",
"An average of the time taken to run PipelineRuns. The trending shown is based on the time range selected. This metric does not show runs that are running or pending.": "An average of the time taken to run PipelineRuns. The trending shown is based on the time range selected. This metric does not show runs that are running or pending.",
"An error occurred": "An error occurred",
"An error occurred during event retrieval. Attempting to reconnect...": "An error occurred during event retrieval. Attempting to reconnect...",
"An error occurred while retrieving the requested logs.": "An error occurred while retrieving the requested logs.",
"An error occurred. Please try again.": "An error occurred. Please try again.",
"Annotations": "Annotations",
"Approval Task": "Approval Task",
"ApprovalTask": "ApprovalTask",
"ApprovalTasks": "ApprovalTasks",
"Approved": "Approved",
"Archived in Tekton results": "Archived in Tekton results",
"Average duration": "Average duration",
"Average Duration": "Average Duration",
"Cancel": "Cancel",
"Cancelled": "Cancelled",
"Cancelling": "Cancelling",
"Click {{submit}} to save changes or {{reset}} to cancel changes.": "Click {{submit}} to save changes or {{reset}} to cancel changes.",
"ClusterTask": "ClusterTask",
"ClusterTasks": "ClusterTasks",
"ClusterTriggerBinding": "ClusterTriggerBinding",
Expand All @@ -49,8 +63,14 @@
"Created": "Created",
"Created at": "Created at",
"Critical": "Critical",
"Custom Task": "Custom Task",
"CustomRun": "CustomRun",
"CustomRuns": "CustomRuns",
"Default value": "Default value",
"Delete {{resourceKind}}": "Delete {{resourceKind}}",
"Delete PipelineRun": "Delete PipelineRun",
"Delete task": "Delete task",
"Description": "Description",
"Details": "Details",
"Download": "Download",
"Download all": "Download all",
Expand All @@ -59,8 +79,10 @@
"Edit {{resourceKind}}": "Edit {{resourceKind}}",
"Edit annotations": "Edit annotations",
"Edit labels": "Edit labels",
"Embedded task": "Embedded task",
"Empty Directories": "Empty Directories",
"Empty Directory ({{workspaceName}})": "Empty Directory ({{workspaceName}})",
"Error": "Error",
"Error connecting to event stream": "Error connecting to event stream",
"Error connecting to event stream: { error }": "Error connecting to event stream: { error }",
"Error downloading logs.": "Error downloading logs.",
Expand All @@ -77,11 +99,15 @@
"Failed": "Failed",
"Failure - check logs for details.": "Failure - check logs for details.",
"Failure on task {{taskName}} - check logs for details.": "Failure on task {{taskName}} - check logs for details.",
"Finally task": "Finally task",
"Finally tasks": "Finally tasks",
"Generated from {{ sourceComponent }}": "Generated from {{ sourceComponent }}",
"Generated from {{ sourceComponent }} on {{ sourceHost }}": "Generated from {{ sourceComponent }} on {{ sourceHost }}",
"Generated from {{sourceComponent}} on <4>{{sourceHost}}</4>": "Generated from {{sourceComponent}} on <4>{{sourceHost}}</4>",
"High": "High",
"Installing": "Installing",
"Interrupt any executing non finally tasks, then execute finally tasks": "Interrupt any executing non finally tasks, then execute finally tasks",
"Invalid PipelineRun configuration, unable to start Pipeline.": "Invalid PipelineRun configuration, unable to start Pipeline.",
"Labels": "Labels",
"Last day": "Last day",
"Last month": "Last month",
Expand Down Expand Up @@ -112,30 +138,36 @@
"No labels": "No labels",
"No matching events": "No matching events",
"No owner": "No owner",
"No parameters are associated with this Pipeline.": "No parameters are associated with this Pipeline.",
"No PipelineRuns found": "No PipelineRuns found",
"No Pipelines found": "No Pipelines found",
"No Repositories found": "No Repositories found",
"No selector": "No selector",
"No TaskRuns found": "No TaskRuns found",
"No tasks": "No tasks",
"No Tasks found": "No Tasks found",
"Node": "Node",
"Node selector": "Node selector",
"Nodes": "Nodes",
"None": "None",
"Number of PipelineRuns": "Number of PipelineRuns",
"OK": "OK",
"Older events are not stored.": "Older events are not stored.",
"optional": "optional",
"Other": "Other",
"Others": "Others",
"Overview": "Overview",
"Owner": "Owner",
"Parameters": "Parameters",
"Partially approved": "Partially approved",
"Pause event streaming": "Pause event streaming",
"Pending": "Pending",
"Per Pipeline": "Per Pipeline",
"Per Repository": "Per Repository",
"PersistentVolumeClaim": "PersistentVolumeClaim",
"PersistentVolumeClaims": "PersistentVolumeClaims",
"Pipeline": "Pipeline",
"Pipeline details": "Pipeline details",
"PipelineRun": "PipelineRun",
"PipelineRun failed to start": "PipelineRun failed to start",
"PipelineRun not started yet": "PipelineRun not started yet",
Expand All @@ -150,15 +182,21 @@
"Project": "Project",
"Refresh Interval": "Refresh Interval",
"Refresh off": "Refresh off",
"Rejected": "Rejected",
"Reload": "Reload",
"Remove": "Remove",
"Repositories": "Repositories",
"Repository": "Repository",
"Required": "Required",
"Rerun": "Rerun",
"Reset": "Reset",
"Resource is being fetched from Tekton Results.": "Resource is being fetched from Tekton Results.",
"Route": "Route",
"Routes": "Routes",
"Running": "Running",
"Runs in pipelines": "Runs in pipelines",
"Runs in repositories": "Runs in repositories",
"Save": "Save",
"Search by pipeline name": "Search by pipeline name",
"Search by repository name": "Search by repository name",
"Secret": "Secret",
Expand All @@ -171,15 +209,19 @@
"Showing most recent {{count}} event_plural": "Showing most recent {{count}} event",
"Signed": "Signed",
"Skipped": "Skipped",
"Start last run": "Start last run",
"Start streaming events": "Start streaming events",
"Started": "Started",
"Status": "Status",
"Stop": "Stop",
"Streaming events...": "Streaming events...",
"Submit": "Submit",
"Succeeded": "Succeeded",
"Success rate": "Success rate",
"Success rate measure the % of successfully completed pipeline runs in relation to the total number of pipeline runs": "Success rate measure the % of successfully completed pipeline runs in relation to the total number of pipeline runs",
"Successfully updated the pipeline {{formName}}.": "Successfully updated the pipeline {{formName}}.",
"Task": "Task",
"Task does not exist": "Task does not exist",
"Task status": "Task status",
"TaskRun": "TaskRun",
"TaskRun details": "TaskRun details",
Expand All @@ -188,7 +230,9 @@
"TektonResult": "TektonResult",
"TektonResults": "TektonResults",
"This action will delete resource from k8s but still the resource can be fetched from Tekton Results": "This action will delete resource from k8s but still the resource can be fetched from Tekton Results",
"This Pipeline has no tasks to visualize.": "This Pipeline has no tasks to visualize.",
"Time Range": "Time Range",
"Timed out": "Timed out",
"Total duration": "Total duration",
"Total Duration": "Total Duration",
"Total Pipelineruns": "Total Pipelineruns",
Expand All @@ -198,14 +242,20 @@
"Triggers": "Triggers",
"TriggerTemplate": "TriggerTemplate",
"TriggerTemplates": "TriggerTemplates",
"Unknown": "Unknown",
"Unknown error retrieving logs": "Unknown error retrieving logs",
"Unknown failure condition": "Unknown failure condition",
"URL": "URL",
"Value": "Value",
"View logs": "View logs",
"VolumeClaimTemplate Resources": "VolumeClaimTemplate Resources",
"Vulnerabilities": "Vulnerabilities",
"Waiting": "Waiting",
"When expression": "When expression",
"When expression was met": "When expression was met",
"When expression was not met": "When expression was not met",
"Workspace Resources": "Workspace Resources",
"Workspaces": "Workspaces",
"YAML": "YAML"
"YAML": "YAML",
"You made changes to this page.": "You made changes to this page."
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@openshift/dynamic-plugin-sdk-extensions": "^1.3.0",
"@openshift/dynamic-plugin-sdk-utils": "^4.1.0",
"@patternfly/react-charts": "7.2.2",
"@patternfly/react-component-groups": "^5.1.0",
"@patternfly/react-core": "^5.2.1",
"@patternfly/react-icons": "5.2.1",
"@patternfly/react-table": "5.2.1",
Expand Down Expand Up @@ -57,6 +58,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.1",
"file-saver": "1.3.x",
"formik": "2.0.3",
"i18next-parser": "^3.11.0",
"jest": "^27.4.5",
"jest-junit": "^16.0.0",
Expand Down Expand Up @@ -110,7 +112,8 @@
"metricsComponent": "./components/pipelines-metrics",
"tasksComponent": "./components/pipelines-tasks",
"triggersDetails": "./components/triggers-details",
"triggersList": "./components/triggers-list"
"triggersList": "./components/triggers-list",
"pipelinesDetails": "./components/pipelines-details"
},
"dependencies": {
"@console/pluginAPI": ">=4.15"
Expand Down
84 changes: 84 additions & 0 deletions src/components/common/button-bar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* eslint-disable tsdoc/syntax */
import * as _ from 'lodash-es';
import * as React from 'react';
import * as classNames from 'classnames';
import * as PropTypes from 'prop-types';
import { Alert, AlertGroup } from '@patternfly/react-core';
import { useTranslation } from 'react-i18next';
import { LoadingInline } from '../status/status-box';

const injectDisabled = (children, disabled) => {
return React.Children.map(children, (c) => {
if (!_.isObject(c) || c.type !== 'button') {
return c;
}

return React.cloneElement(c, { disabled: c.props.disabled || disabled });
});
};

const ErrorMessage = ({ message }) => {
const { t } = useTranslation('plugin__pipelines-console-plugin');
return (
<Alert
isInline
className="co-alert co-alert--scrollable"
variant="danger"
title={t('An error occurred')}
data-test="alert-error"
>
<div className="co-pre-line">{message}</div>
</Alert>
);
};
const InfoMessage = ({ message }) => (
<Alert
isInline
className="co-alert"
variant="info"
title={message}
data-test="button-bar-info-message"
/>
);
const SuccessMessage = ({ message }) => (
<Alert isInline className="co-alert" variant="success" title={message} />
);

// NOTE: DO NOT use <a> elements within a ButtonBar.
// They don't support the disabled attribute, and therefore
// can't be disabled during a pending promise/request.
/** @type {React.SFC<{children: any, className?: string, errorMessage?: React.ReactNode, infoMessage?: string, successMessage?: string, inProgress?: boolean}}>} */
export const ButtonBar = ({
children,
className,
errorMessage,
infoMessage,
successMessage,
inProgress,
}) => {
return (
<div className={classNames(className, 'co-m-btn-bar')}>
<AlertGroup
isLiveRegion
aria-live="polite"
aria-atomic="false"
aria-relevant="additions text"
>
{successMessage && <SuccessMessage message={successMessage} />}
{errorMessage && <ErrorMessage message={errorMessage} />}
{injectDisabled(children, inProgress)}
{inProgress && <LoadingInline />}
{infoMessage && <InfoMessage message={infoMessage} />}
</AlertGroup>
</div>
);
};

ButtonBar.propTypes = {
children: PropTypes.node.isRequired,
successMessage: PropTypes.string,
errorMessage: PropTypes.node,
infoMessage: PropTypes.string,
inProgress: PropTypes.bool,
className: PropTypes.string,
};
29 changes: 29 additions & 0 deletions src/components/hooks/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
WatchK8sResource,
useK8sWatchResource,
} from '@openshift-console/dynamic-plugin-sdk';
import { TektonResourceLabel } from '../../consts';
import { PipelineRunModel } from '../../models';
import { PipelineRunKind } from '../../types';
import { getReferenceForModel } from '../pipelines-overview/utils';
import { getLatestRun } from '../utils/pipeline-augment';

export const useLatestPipelineRun = (
pipelineName: string,
namespace: string,
): PipelineRunKind => {
const pipelineRunResource: WatchK8sResource = {
kind: getReferenceForModel(PipelineRunModel),
namespace,
selector: {
matchLabels: { [TektonResourceLabel.pipeline]: pipelineName },
},
optional: true,
isList: true,
};
const [pipelineRun, pipelineRunLoaded, pipelineRunError] =
useK8sWatchResource<PipelineRunKind[]>(pipelineRunResource);

const latestRun = getLatestRun(pipelineRun, 'creationTimestamp');
return pipelineRunLoaded && !pipelineRunError ? latestRun : null;
};
Loading

0 comments on commit 00ee56e

Please sign in to comment.