From 27eef06b2e7276b1985425d6afa05b105772bf8f Mon Sep 17 00:00:00 2001 From: Vikram Raj Date: Wed, 13 Dec 2023 04:30:13 +0530 Subject: [PATCH] Change per Pipeline and per Repository toggle button order --- .../en/plugin__pipeline-console-plugin.json | 4 +- .../list-pages/PipelineRunsListPage.tsx | 69 ++++++++++++------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/locales/en/plugin__pipeline-console-plugin.json b/locales/en/plugin__pipeline-console-plugin.json index 14b5fc12..491613ff 100644 --- a/locales/en/plugin__pipeline-console-plugin.json +++ b/locales/en/plugin__pipeline-console-plugin.json @@ -29,8 +29,8 @@ "Others": "Others", "Overview": "Overview", "Pending": "Pending", - "Per pipeline": "Per pipeline", - "Per repository": "Per repository", + "Per Pipeline": "Per Pipeline", + "Per Repository": "Per Repository", "Pipeline": "Pipeline", "Pipeline metrics configuration defaults to pipelines and task level": "Pipeline metrics configuration defaults to pipelines and task level", "PipelineRun status": "PipelineRun status", diff --git a/src/components/pipelines-overview/list-pages/PipelineRunsListPage.tsx b/src/components/pipelines-overview/list-pages/PipelineRunsListPage.tsx index 973d83cf..917d8cdc 100644 --- a/src/components/pipelines-overview/list-pages/PipelineRunsListPage.tsx +++ b/src/components/pipelines-overview/list-pages/PipelineRunsListPage.tsx @@ -30,12 +30,14 @@ const PipelineRunsListPage: React.FC = ({ bordered, namespace, timespan, - interval + interval, }) => { const { t } = useTranslation('plugin__pipeline-console-plugin'); const [pageFlag, setPageFlag] = React.useState(1); const [summaryData, setSummaryData] = React.useState([]); - const [summaryDataFiltered, setSummaryDataFiltered] = React.useState([]); + const [summaryDataFiltered, setSummaryDataFiltered] = React.useState< + SummaryProps[] + >([]); const date = getDropDownDate(timespan).toISOString(); if (namespace == ALL_NAMESPACES_KEY) { @@ -44,18 +46,19 @@ const PipelineRunsListPage: React.FC = ({ const getSummaryData = () => { getResultsSummary( namespace, - pageFlag === 1 ? { - summary: 'total_duration,avg_duration,total,succeeded,last_runtime', - data_type: DataType.PipelineRun, - groupBy: 'pipeline', - filter: `data.status.startTime>timestamp("${date}")&&!data.metadata.labels.contains('pipelinesascode.tekton.dev/repository')`, - } : - { - summary: 'total_duration,avg_duration,total,succeeded,last_runtime', - data_type: DataType.PipelineRun, - groupBy: 'repository', - filter: `data.status.startTime>timestamp("${date}")&&data.metadata.labels.contains('pipelinesascode.tekton.dev/repository')`, - }, + pageFlag === 1 + ? { + summary: 'total_duration,avg_duration,total,succeeded,last_runtime', + data_type: DataType.PipelineRun, + groupBy: 'pipeline', + filter: `data.status.startTime>timestamp("${date}")&&!data.metadata.labels.contains('pipelinesascode.tekton.dev/repository')`, + } + : { + summary: 'total_duration,avg_duration,total,succeeded,last_runtime', + data_type: DataType.PipelineRun, + groupBy: 'repository', + filter: `data.status.startTime>timestamp("${date}")&&data.metadata.labels.contains('pipelinesascode.tekton.dev/repository')`, + }, ) .then((response) => { setSummaryData(response.summary); @@ -74,9 +77,14 @@ const PipelineRunsListPage: React.FC = ({ setPageFlag(pageNumber); }; const handleNameChange = (value: string) => { - const filteredData = summaryData.filter((summary) => summary.group_value.split('/')[1].toLowerCase().includes(value.toLowerCase())) + const filteredData = summaryData.filter((summary) => + summary.group_value + .split('/')[1] + .toLowerCase() + .includes(value.toLowerCase()), + ); setSummaryDataFiltered(filteredData); - } + }; return ( = ({ - + handlePageChange(2)} - /> - handlePageChange(1)} /> + handlePageChange(2)} + /> {pageFlag === 1 ? ( - + ) : ( - + )}