Skip to content

Commit

Permalink
Merge pull request #82 from vikram-raj/PLRs-repo-list
Browse files Browse the repository at this point in the history
ODC-7483,ODC-7487: Add PipelineRuns and Repositories List pages
  • Loading branch information
openshift-merge-bot[bot] authored Apr 9, 2024
2 parents 1dc1aae + f0d0136 commit 29965e5
Show file tree
Hide file tree
Showing 37 changed files with 1,760 additions and 67 deletions.
133 changes: 133 additions & 0 deletions console-extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@
"abbr": "PL"
}
},
{
"type": "console.model-metadata",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1beta1",
"kind": "PipelineRun"
},
"color": "#38812f",
"label": "%PipelineRun%",
"labelPlural": "%PipelineRuns%",
"abbr": "PLR"
}
},
{
"type": "console.model-metadata",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1",
"kind": "PipelineRun"
},
"color": "#38812f",
"label": "%PipelineRun%",
"labelPlural": "%PipelineRuns%",
"abbr": "PLR"
}
},
{
"type": "console.page/route",
"properties": {
Expand Down Expand Up @@ -222,6 +250,48 @@
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINES_LIST"]
}
},
{
"type": "console.page/resource/list",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1beta1",
"kind": "PipelineRun"
},
"component": { "$codeRef": "pipelineRunsList.PipelineRunsListPage" }
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINERUNS_LIST"]
}
},
{
"type": "console.page/resource/list",
"properties": {
"model": {
"group": "tekton.dev",
"version": "v1",
"kind": "PipelineRun"
},
"component": { "$codeRef": "pipelineRunsList.PipelineRunsListPage" }
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINERUNS_LIST"]
}
},
{
"type": "console.page/resource/list",
"properties": {
"model": {
"group": "pipelinesascode.tekton.dev",
"version": "v1alpha1",
"kind": "Repository"
},
"component": { "$codeRef": "repositoriesList.RepositoriesListPage" }
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_REPOSITORIES_LIST"]
}
},
{
"type": "console.page/resource/list",
"properties": {
Expand Down Expand Up @@ -487,6 +557,19 @@
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_CLUSTERTRIGGERSBINDINGS_LIST"]
}
},
{
"type": "console.page/route",
"properties": {
"path": ["/dev-pipelines/ns/:ns", "/dev-pipelines/all-namespaces"],
"exact": false,
"component": {
"$codeRef": "pipelinesList.PipelinesTabbedPage"
}
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_NAV_OPTION"]
}
},
{
"type": "console.page/route",
"properties": {
Expand All @@ -500,6 +583,19 @@
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_TRIGGERS_NAV_OPTION"]
}
},
{
"type": "console.page/route",
"properties": {
"path": ["/pipelines/ns/:ns", "/pipelines/all-namespaces"],
"exact": false,
"component": {
"$codeRef": "pipelinesList.PipelinesTabbedPage"
}
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_NAV_OPTION"]
}
},
{
"type": "console.navigation/href",
"properties": {
Expand Down Expand Up @@ -606,5 +702,42 @@
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_TASKRUN_DETAILS"]
}
},
{
"type": "console.navigation/href",
"properties": {
"id": "pipelines",
"perspective": "admin",
"section": "pipelines",
"name": "%Pipelines%",
"href": "/pipelines",
"insertBefore": "pipeline-tasks",
"namespaced": true,
"dataAttributes": {
"data-quickstart-id": "qs-nav-pipelines"
}
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_NAV_OPTION"]
}
},
{
"type": "console.navigation/href",
"properties": {
"id": "pipelines",
"perspective": "dev",
"section": "resources",
"insertAfter": "builds",
"name": "%Pipelines%",
"href": "/dev-pipelines",
"namespaced": true,
"dataAttributes": {
"data-quickstart-id": "qs-nav-pipelines",
"data-test-id": "pipeline-header"
}
},
"flags": {
"required": ["HIDE_STATIC_PIPELINE_PLUGIN_PIPELINE_NAV_OPTION"]
}
}
]
13 changes: 12 additions & 1 deletion locales/en/plugin__pipelines-console-plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"Archived in Tekton results": "Archived in Tekton results",
"Average duration": "Average duration",
"Average Duration": "Average Duration",
"Cancel": "Cancel",
"Cancelled": "Cancelled",
"Cancelling": "Cancelling",
"ClusterTask": "ClusterTask",
Expand All @@ -45,11 +46,11 @@
"Create": "Create",
"Create {{name}}": "Create {{name}}",
"Create {{resourceKind}}": "Create {{resourceKind}}",
"Create Pipeline": "Create Pipeline",
"Created": "Created",
"Created at": "Created at",
"Critical": "Critical",
"Delete {{resourceKind}}": "Delete {{resourceKind}}",
"Delete PipelineRun": "Delete PipelineRun",
"Details": "Details",
"Download": "Download",
"Download all": "Download all",
Expand All @@ -68,6 +69,7 @@
"Error loading events": "Error loading events",
"Event": "Event",
"Event stream is paused.": "Event stream is paused.",
"Event type": "Event type",
"EventListener": "EventListener",
"EventListeners": "EventListeners",
"Events": "Events",
Expand All @@ -79,16 +81,19 @@
"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",
"Interrupt any executing non finally tasks, then execute finally tasks": "Interrupt any executing non finally tasks, then execute finally tasks",
"Labels": "Labels",
"Last day": "Last day",
"Last month": "Last month",
"Last quarter": "Last quarter",
"Last run": "Last run",
"Last run duration": "Last run duration",
"Last run status": "Last run status",
"Last run time": "Last run time",
"Last weeks": "Last weeks",
"Last year": "Last year",
"less than a sec": "less than a sec",
"Let the running tasks complete, then execute finally tasks": "Let the running tasks complete, then execute finally tasks",
"Loading events...": "Loading events...",
"Log snippet": "Log snippet",
"Logs": "Logs",
Expand All @@ -108,6 +113,8 @@
"No matching events": "No matching events",
"No owner": "No owner",
"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 found": "No Tasks found",
Expand Down Expand Up @@ -145,6 +152,7 @@
"Refresh off": "Refresh off",
"Repositories": "Repositories",
"Repository": "Repository",
"Rerun": "Rerun",
"Resource is being fetched from Tekton Results.": "Resource is being fetched from Tekton Results.",
"Route": "Route",
"Routes": "Routes",
Expand All @@ -161,10 +169,12 @@
"Showing {{count}} event_plural": "Showing {{count}} event",
"Showing most recent {{count}} event": "Showing most recent {{count}} event",
"Showing most recent {{count}} event_plural": "Showing most recent {{count}} event",
"Signed": "Signed",
"Skipped": "Skipped",
"Start streaming events": "Start streaming events",
"Started": "Started",
"Status": "Status",
"Stop": "Stop",
"Streaming events...": "Streaming events...",
"Succeeded": "Succeeded",
"Success rate": "Success rate",
Expand Down Expand Up @@ -194,6 +204,7 @@
"Value": "Value",
"View logs": "View logs",
"VolumeClaimTemplate Resources": "VolumeClaimTemplate Resources",
"Vulnerabilities": "Vulnerabilities",
"Workspace Resources": "Workspace Resources",
"Workspaces": "Workspaces",
"YAML": "YAML"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
"hookProvider": "./components/hooks",
"pipelinesComponent": "./components/pipelines-overview",
"pipelinesList": "./components/pipelines-list",
"pipelineRunsList": "./components/pipelineRuns-list",
"repositoriesList": "./components/repositories-list",
"metricsComponent": "./components/pipelines-metrics",
"tasksComponent": "./components/pipelines-tasks",
"triggersDetails": "./components/triggers-details",
Expand Down
30 changes: 13 additions & 17 deletions src/components/hooks/useTektonResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
getGroupVersionKindForModel,
K8sResourceCommon,
Selector,
useK8sWatchResource,
Expand All @@ -10,13 +11,14 @@ import {
RepositoryLabels,
TektonResourceLabel,
} from '../../consts';
import { PipelineRunModel } from '../../models';
import { PipelineRunKind, TaskRunKind } from '../../types';
import {
RecordsList,
TektonResultsOptions,
getPipelineRuns,
getTaskRunLog,
getTaskRuns,
RecordsList,
TektonResultsOptions,
} from '../utils/tekton-results';
import { useTaskRuns } from './useTaskRuns';

Expand Down Expand Up @@ -126,7 +128,7 @@ export const useTRTaskRuns = (
export const useGetPipelineRuns = (
ns: string,
options?: { name: string; kind: string },
) => {
): [PipelineRunKind[], boolean, unknown, GetNextPage] => {
let selector: Selector;

if (options?.kind === 'Pipeline') {
Expand All @@ -139,31 +141,25 @@ export const useGetPipelineRuns = (
},
};
}
const [resultPlrs, resultPlrsLoaded, resultPlrsLoadError, getNextPage] =
useTRPipelineRuns(
ns,
options && {
selector,
},
);
const [resultPlrs, resultPlrsLoaded, , getNextPage] = useTRPipelineRuns(
ns,
options && {
selector,
},
);
const [k8sPlrs, k8sPlrsLoaded, k8sPlrsLoadError] = useK8sWatchResource<
PipelineRunKind[]
>({
isList: true,
kind: 'PipelineRun',
groupVersionKind: getGroupVersionKindForModel(PipelineRunModel),
namespace: ns,
...(options ? { selector } : {}),
});
const mergedPlrs =
(resultPlrsLoaded || k8sPlrsLoaded) && !k8sPlrsLoadError
? uniqBy([...k8sPlrs, ...resultPlrs], (r) => r.metadata.name)
: [];
return [
mergedPlrs,
resultPlrsLoaded || k8sPlrsLoaded,
resultPlrsLoadError || k8sPlrsLoadError,
getNextPage,
];
return [mergedPlrs, k8sPlrsLoaded, k8sPlrsLoadError, getNextPage];
};

export const useGetTaskRuns = (
Expand Down
20 changes: 17 additions & 3 deletions src/components/list-pages/ListPageCreateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ type ListPageCreateButtonProps = {
hideTitle: boolean;
};

const getCreateLink = (model: K8sKind, namespace: string) => {
if (model.kind === 'Pipeline') {
return `/k8s/ns/${namespace || 'default'}/${getReferenceForModel(
model,
)}/~new/builder`;
}
if (model.kind === 'Repository') {
return `/k8s/ns/${namespace || 'default'}/${getReferenceForModel(
model,
)}/~new/form`;
}
return `/k8s${
namespace ? `/ns/${namespace}` : `/cluster`
}/${getReferenceForModel(model)}/~new`;
};

const ListPageCreateButton: React.FC<ListPageCreateButtonProps> = ({
model,
namespace,
Expand All @@ -32,9 +48,7 @@ const ListPageCreateButton: React.FC<ListPageCreateButtonProps> = ({
groupVersionKind: getGroupVersionKindForModel(model),
namespace,
}}
to={`/k8s${
namespace ? `/ns/${namespace}` : `/cluster`
}/${getReferenceForModel(model)}/~new`}
to={getCreateLink(model, namespace)}
>
{t('Create {{name}}', { name: model.label })}
</ListPageCreateLink>
Expand Down
Loading

0 comments on commit 29965e5

Please sign in to comment.