From 658d282aab723d71f76ed5b6b997f639b8afcade Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 1 Dec 2026 13:25:02 -0500 Subject: [PATCH 1/2] fix: Console-like list toolbar spacing/alignment and Rollout status filter Signed-off-by: Atif Ali --- .../application/ApplicationResourcesView.tsx | 7 +++ .../application/ApplicationSourcesTab.tsx | 12 +++- .../application/ApplicationSyncStatusTab.tsx | 11 +++- .../application/History/History.tsx | 7 +++ .../imageupdater/ImageUpdaterList.tsx | 12 +++- .../ImageUpdaterRecentUpdatesTab.tsx | 11 +++- src/gitops/components/project/ProjectList.tsx | 12 +++- .../components/project/ProjectRolesTab.tsx | 7 +++ .../project/ProjectSyncWindowsTab.tsx | 7 +++ src/gitops/components/rollout/RolloutList.tsx | 12 +++- .../rollout/components/PodList/PodList.tsx | 12 +++- .../components/shared/ApplicationList.tsx | 12 +++- .../shared/ApplicationSetApplicationsView.tsx | 12 +++- .../components/shared/ApplicationSetList.tsx | 12 +++- .../shared/DataView/GitOpsDataViewTable.scss | 27 ++++++--- .../shared/DataView/GitOpsDataViewTable.tsx | 60 ++++++++++--------- .../components/shared/DataView/index.ts | 1 + .../shared/GitOpsListPageToolbar.scss | 59 ++++++++++++------ .../shared/GitOpsListPageToolbar.tsx | 15 ++--- 19 files changed, 236 insertions(+), 72 deletions(-) diff --git a/src/gitops/components/application/ApplicationResourcesView.tsx b/src/gitops/components/application/ApplicationResourcesView.tsx index c657f9a17..795241479 100644 --- a/src/gitops/components/application/ApplicationResourcesView.tsx +++ b/src/gitops/components/application/ApplicationResourcesView.tsx @@ -29,6 +29,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -156,6 +157,11 @@ const ApplicationResourcesView: React.FC = ({ actions={ } + pagination={ + isListView && itemCount > 0 ? ( + + ) : undefined + } /> @@ -174,6 +180,7 @@ const ApplicationResourcesView: React.FC = ({ activeState={isEmptyResources ? DataViewState.empty : null} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> ) : (
diff --git a/src/gitops/components/application/ApplicationSourcesTab.tsx b/src/gitops/components/application/ApplicationSourcesTab.tsx index e4a785572..5438b600e 100644 --- a/src/gitops/components/application/ApplicationSourcesTab.tsx +++ b/src/gitops/components/application/ApplicationSourcesTab.tsx @@ -33,7 +33,11 @@ import { buildManagedDataViewColumns, useGitOpsManagedDataView, } from '../shared/ColumnManagement'; -import { GitOpsDataViewTable, useGitOpsListPagePagination } from '../shared/DataView'; +import { + GitOpsDataViewTable, + GitOpsListPagination, + useGitOpsListPagePagination, +} from '../shared/DataView'; import { GitOpsListPageToolbar } from '../shared/GitOpsListPageToolbar'; type ApplicationDetailsTabProps = RouteComponentProps<{ @@ -214,6 +218,11 @@ export const SourceList: React.FC = ({ sources, obj, argoServer ) : undefined } columnManagement={columnManagement} + pagination={ + itemCount > 0 ? ( + + ) : undefined + } /> = ({ sources, obj, argoServer isEmpty={sources.length === 0} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> ); diff --git a/src/gitops/components/application/ApplicationSyncStatusTab.tsx b/src/gitops/components/application/ApplicationSyncStatusTab.tsx index e24edffb7..1a6cb9614 100644 --- a/src/gitops/components/application/ApplicationSyncStatusTab.tsx +++ b/src/gitops/components/application/ApplicationSyncStatusTab.tsx @@ -45,6 +45,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -283,7 +284,14 @@ const ApplicationSyncStatusTab: React.FC = ({ obj {t('Resources Last Synced')} - + 0 ? ( + + ) : undefined + } + /> = ({ obj activeState={resources.length === 0 ? DataViewState.empty : null} itemCount={itemCount} pagination={pagination} + showTopPagination={false} />
diff --git a/src/gitops/components/application/History/History.tsx b/src/gitops/components/application/History/History.tsx index c1f10eca6..1aa127563 100644 --- a/src/gitops/components/application/History/History.tsx +++ b/src/gitops/components/application/History/History.tsx @@ -26,6 +26,7 @@ import { Tbody, Td, ThProps, Tr } from '@patternfly/react-table'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../../shared/DataView'; @@ -114,6 +115,11 @@ const HistoryList: React.FC = ({ history, obj }) => { ) : undefined } columnManagement={columnManagement} + pagination={ + itemCount > 0 ? ( + + ) : undefined + } /> = ({ history, obj }) => { isEmpty={displayHistory.length === 0} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> ); diff --git a/src/gitops/components/imageupdater/ImageUpdaterList.tsx b/src/gitops/components/imageupdater/ImageUpdaterList.tsx index 01f25b215..d6a9c44d1 100644 --- a/src/gitops/components/imageupdater/ImageUpdaterList.tsx +++ b/src/gitops/components/imageupdater/ImageUpdaterList.tsx @@ -40,6 +40,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -238,7 +239,15 @@ const ImageUpdaterList: React.FC = ({ )} {hasItems && ( - + 0 && !loadError ? ( + + ) : undefined + } + /> )} = ({ errorState={error || undefined} itemCount={itemCount} pagination={pagination} + showTopPagination={!hasItems} /> diff --git a/src/gitops/components/imageupdater/ImageUpdaterRecentUpdatesTab.tsx b/src/gitops/components/imageupdater/ImageUpdaterRecentUpdatesTab.tsx index 680f1c866..2cfb4c865 100644 --- a/src/gitops/components/imageupdater/ImageUpdaterRecentUpdatesTab.tsx +++ b/src/gitops/components/imageupdater/ImageUpdaterRecentUpdatesTab.tsx @@ -27,6 +27,7 @@ import { ImageUpdaterKind, ImageUpdaterRecentUpdate } from '../../models/ImageUp import { useGitOpsTranslation } from '../../utils/hooks/useGitOpsTranslation'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -105,7 +106,14 @@ const ImageUpdaterRecentUpdatesTab: React.FC {t('Recent Updates')} - + 0 ? ( + + ) : undefined + } + /> isEmpty={sortedUpdates.length === 0} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> diff --git a/src/gitops/components/project/ProjectList.tsx b/src/gitops/components/project/ProjectList.tsx index a098778ae..2e4f5e33f 100644 --- a/src/gitops/components/project/ProjectList.tsx +++ b/src/gitops/components/project/ProjectList.tsx @@ -38,6 +38,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -261,7 +262,15 @@ const ProjectList: React.FC = ({ )} {hasProjects && ( - + 0 && !loadError ? ( + + ) : undefined + } + /> )}
= ({ errorState={error || undefined} itemCount={itemCount} pagination={pagination} + showTopPagination={!hasProjects} />
diff --git a/src/gitops/components/project/ProjectRolesTab.tsx b/src/gitops/components/project/ProjectRolesTab.tsx index 7be0f94b8..36746edd9 100644 --- a/src/gitops/components/project/ProjectRolesTab.tsx +++ b/src/gitops/components/project/ProjectRolesTab.tsx @@ -26,6 +26,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -177,6 +178,11 @@ const ProjectRolesTab: React.FC = ({ obj }) => { : undefined} columnManagement={columnManagement} + pagination={ + itemCount > 0 ? ( + + ) : undefined + } /> = ({ obj }) => { emptyState={empty} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> ); diff --git a/src/gitops/components/project/ProjectSyncWindowsTab.tsx b/src/gitops/components/project/ProjectSyncWindowsTab.tsx index 428c05cc8..5d6279331 100644 --- a/src/gitops/components/project/ProjectSyncWindowsTab.tsx +++ b/src/gitops/components/project/ProjectSyncWindowsTab.tsx @@ -26,6 +26,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -134,6 +135,11 @@ const ProjectSyncWindowsTab: React.FC = ({ obj }) => : undefined} columnManagement={columnManagement} + pagination={ + itemCount > 0 ? ( + + ) : undefined + } /> = ({ obj }) => emptyState={empty} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> ); diff --git a/src/gitops/components/rollout/RolloutList.tsx b/src/gitops/components/rollout/RolloutList.tsx index 20f33757d..9078a9b5d 100644 --- a/src/gitops/components/rollout/RolloutList.tsx +++ b/src/gitops/components/rollout/RolloutList.tsx @@ -37,6 +37,7 @@ import { } from '../shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '../shared/DataView'; @@ -245,6 +246,11 @@ const RolloutList: React.FC = ({ 0 && !loadError ? ( + + ) : undefined + } /> )} = ({ errorState={error || undefined} itemCount={itemCount} pagination={pagination} + showTopPagination={!(hasRollouts || !hideNameLabelFilters)} /> @@ -487,11 +494,10 @@ const getFilters = (t: (key: string) => string): RowFilter[] => [ type: 'rollout-status', reducer: (rollout) => rollout.status?.phase, filter: (input, rollout) => { - if (input.selected?.length && rollout?.status?.phase) { - return input.selected.includes(rollout.status.phase); - } else { + if (!input.selected?.length) { return true; } + return !!rollout?.status?.phase && input.selected.includes(rollout.status.phase); }, items: [ { id: RolloutStatus.Healthy, title: RolloutStatus.Healthy }, diff --git a/src/gitops/components/rollout/components/PodList/PodList.tsx b/src/gitops/components/rollout/components/PodList/PodList.tsx index b99c9e639..02c0056e5 100644 --- a/src/gitops/components/rollout/components/PodList/PodList.tsx +++ b/src/gitops/components/rollout/components/PodList/PodList.tsx @@ -8,6 +8,7 @@ import { } from '@gitops/components/shared/ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from '@gitops/components/shared/DataView'; @@ -150,11 +151,10 @@ const getFilters = (t: (key: string) => string): RowFilter[] => [ type: 'app-health', reducer: (pod) => pod.status?.phase, filter: (input, pod) => { - if (input.selected?.length && pod?.status?.phase) { - return input.selected.includes(pod.status.phase); - } else { + if (!input.selected?.length) { return true; } + return !!pod?.status?.phase && input.selected.includes(pod.status.phase); }, items: [ { id: PodStatus.RUNNING, title: PodStatus.RUNNING }, @@ -447,6 +447,11 @@ export const PodList: React.FC = ({ rollout, namespace, selector } /> } columnManagement={columnManagement} + pagination={ + itemCount > 0 && !loadError ? ( + + ) : undefined + } /> = ({ rollout, namespace, selector } isError={!!loadError} itemCount={itemCount} pagination={pagination} + showTopPagination={false} /> diff --git a/src/gitops/components/shared/ApplicationList.tsx b/src/gitops/components/shared/ApplicationList.tsx index af7053e56..baef5f9b7 100644 --- a/src/gitops/components/shared/ApplicationList.tsx +++ b/src/gitops/components/shared/ApplicationList.tsx @@ -60,6 +60,7 @@ import { } from './ColumnManagement'; import { GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, } from './DataView'; @@ -303,7 +304,15 @@ const ApplicationList: React.FC = ({ )} {!appset && hasOwnedApplications && ( - + 0 && !loadError ? ( + + ) : undefined + } + /> )} {appset && ( = ({ isError={!!loadError} itemCount={itemCount} pagination={pagination} + showTopPagination={!hasOwnedApplications} /> )} diff --git a/src/gitops/components/shared/ApplicationSetApplicationsView.tsx b/src/gitops/components/shared/ApplicationSetApplicationsView.tsx index 00418bb1f..3b7348bf4 100644 --- a/src/gitops/components/shared/ApplicationSetApplicationsView.tsx +++ b/src/gitops/components/shared/ApplicationSetApplicationsView.tsx @@ -9,7 +9,11 @@ import { DataViewTh, DataViewTr } from '@patternfly/react-data-view/dist/esm/Dat import { ApplicationSetGraphView } from '../appset/graph/ApplicationSetGraphView'; -import { type GitOpsDataViewPagination, GitOpsDataViewTable } from './DataView'; +import { + type GitOpsDataViewPagination, + GitOpsDataViewTable, + GitOpsListPagination, +} from './DataView'; import { GitOpsListPageToolbar } from './GitOpsListPageToolbar'; import GitOpsViewSwitcher from './GitOpsViewSwitcher'; import { APPLICATION_SET_APPLICATIONS_VIEW_SETTING_KEY, GitOpsViewType } from './GitOpsViewType'; @@ -117,6 +121,11 @@ const ApplicationSetApplicationsView: React.FC } + pagination={ + isListView && itemCount > 0 && !isError ? ( + + ) : undefined + } />
@@ -137,6 +146,7 @@ const ApplicationSetApplicationsView: React.FC = ({ )} {hasApplicationSets && ( - + 0 && !loadError ? ( + + ) : undefined + } + /> )} = ({ errorState={error} itemCount={itemCount} pagination={pagination} + showTopPagination={!hasApplicationSets} activeState={ // eslint-disable-next-line no-nested-ternary !loaded ? DataViewState.loading : isEmptyState ? DataViewState.empty : undefined diff --git a/src/gitops/components/shared/DataView/GitOpsDataViewTable.scss b/src/gitops/components/shared/DataView/GitOpsDataViewTable.scss index bbb78b49d..76d2ba71c 100644 --- a/src/gitops/components/shared/DataView/GitOpsDataViewTable.scss +++ b/src/gitops/components/shared/DataView/GitOpsDataViewTable.scss @@ -1,12 +1,26 @@ -// Keep top/bottom pagination aligned horizontally. PatternFly's bottom -// variant adds spacer--sm inline padding that the top (toolbar) pager does not. .gitops-data-view-table { - .pf-v6-c-toolbar__item.pf-m-pagination .pf-v6-c-pagination.pf-m-bottom { - padding-inline-start: 0; - padding-inline-end: 0; + .pf-v6-l-stack { + height: auto; + } + + &__pagination { + display: flex; + justify-content: flex-end; + + &--top { + margin-block-end: var(--pf-t--global--spacer--sm); + } + + &--bottom { + margin-block-start: var(--pf-t--global--spacer--sm); + + .pf-v6-c-pagination.pf-m-bottom { + padding-inline-start: 0; + padding-inline-end: 0; + } + } } - // Opaque sticky Name/Actions so middle columns don't show through. .pf-v6-c-table .pf-v6-c-table__sticky-cell { --pf-v6-c-table__sticky-cell--BackgroundColor: var( --pf-t--global--background--color--sticky--default, @@ -15,7 +29,6 @@ background-color: var(--pf-v6-c-table__sticky-cell--BackgroundColor); } - // Stop sideways scroll when name/actions folds meet. &--folds-meet .pf-v6-c-scroll-inner-wrapper { overflow-x: hidden; } diff --git a/src/gitops/components/shared/DataView/GitOpsDataViewTable.tsx b/src/gitops/components/shared/DataView/GitOpsDataViewTable.tsx index 77dff2812..053278e23 100644 --- a/src/gitops/components/shared/DataView/GitOpsDataViewTable.tsx +++ b/src/gitops/components/shared/DataView/GitOpsDataViewTable.tsx @@ -9,7 +9,6 @@ import DataViewTable, { DataViewTh, DataViewTr, } from '@patternfly/react-data-view/dist/esm/DataViewTable'; -import DataViewToolbar from '@patternfly/react-data-view/dist/esm/DataViewToolbar'; import { useDataViewPagination, useDataViewSort } from '@patternfly/react-data-view/dist/esm/Hooks'; import { InnerScrollContainer, ThProps } from '@patternfly/react-table'; @@ -87,6 +86,8 @@ export type GitOpsDataViewTableProps = { * Optional PF pagination state. When omitted, the table renders every row. */ pagination?: GitOpsDataViewPagination; + /** When false, only the bottom pager is rendered. Defaults to true. */ + showTopPagination?: boolean; /** Pass to save/restore column widths after refresh. */ tableID?: string; }; @@ -134,6 +135,7 @@ export const GitOpsDataViewTable: React.FC = ({ activeState, itemCount, pagination, + showTopPagination = true, tableID, }) => { const paginationWidgetIdBase = useGitOpsPaginationWidgetIdBase(); @@ -275,45 +277,49 @@ export const GitOpsDataViewTable: React.FC = ({ })} > - {showPagination && pagination && ( - - } - /> + {showPagination && showTopPagination && pagination && ( +
+ +
)} {/* Resizable tables already have one scrollport; don't wrap again. */} {isResizable ? table : {table}} {showPagination && pagination && ( - - } - /> +
+ +
)}
); }; -const GitOpsPagination: React.FC<{ +type GitOpsListPaginationProps = { itemCount: number; pagination: GitOpsDataViewPagination; - variant: PaginationVariant; - widgetId: string; + variant?: PaginationVariant; + widgetId?: string; isStatic?: boolean; -}> = ({ itemCount, pagination, variant, widgetId, isStatic }) => { +}; + +export const GitOpsListPagination: React.FC = ({ + itemCount, + pagination, + variant = PaginationVariant.top, + widgetId, + isStatic, +}) => { const { t } = useGitOpsTranslation(); return ( diff --git a/src/gitops/components/shared/DataView/index.ts b/src/gitops/components/shared/DataView/index.ts index 0a87f5653..ee12b7406 100644 --- a/src/gitops/components/shared/DataView/index.ts +++ b/src/gitops/components/shared/DataView/index.ts @@ -12,6 +12,7 @@ export { type GitOpsDataViewTableProps, type UseGitOpsDataViewSortResult, GitOpsDataViewTable, + GitOpsListPagination, useGitOpsDataViewPagination, useGitOpsDataViewSort, useGitOpsListPagePagination, diff --git a/src/gitops/components/shared/GitOpsListPageToolbar.scss b/src/gitops/components/shared/GitOpsListPageToolbar.scss index 0844ab5c8..f210a66e6 100644 --- a/src/gitops/components/shared/GitOpsListPageToolbar.scss +++ b/src/gitops/components/shared/GitOpsListPageToolbar.scss @@ -1,46 +1,56 @@ .gitops-list-page-toolbar { display: flex; flex-wrap: wrap; - align-items: center; - justify-content: space-between; + align-items: flex-start; gap: var(--pf-t--global--spacer--sm); - margin-bottom: var(--pf-t--global--spacer--sm); - - &__primary { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--pf-t--global--spacer--sm); - min-width: 0; - } + margin-bottom: 0; + width: 100%; &__filters { - flex: 0 1 auto; - min-width: 0; + display: contents; + + > *:has(> .pf-v6-c-toolbar), + > *:has(> .pf-c-toolbar) { + display: contents; + } - // ListPageFilter's toolbar is full-width by default; shrink so columns sit beside search. .pf-v6-c-toolbar, .pf-c-toolbar { + display: contents; width: auto; padding-block: 0; } - .pf-v6-c-toolbar__content, - .pf-c-toolbar__content { + .pf-v6-c-toolbar__content:first-child, + .pf-c-toolbar__content:first-child { + flex: 0 1 auto; + min-width: 0; + order: 1; padding-inline: 0; + padding-block: 0; } .pf-v6-c-toolbar__content-section, .pf-c-toolbar__content-section { flex-wrap: wrap; + width: auto; row-gap: var(--pf-t--global--spacer--sm); } + + .pf-v6-c-toolbar__content:not(:first-child), + .pf-c-toolbar__content:not(:first-child) { + flex: 1 1 100%; + order: 4; + padding-inline: 0; + padding-block-end: 0; + } } &__columns { display: inline-flex; flex: 0 0 auto; align-items: center; + order: 2; gap: var(--pf-t--global--spacer--xs); min-height: var(--pf-t--global--spacer--2xl); } @@ -49,6 +59,21 @@ display: flex; flex: 0 0 auto; align-items: center; - margin-inline-start: auto; + order: 2; + } + + &__pagination { + display: flex; + flex: 1 0 100%; + justify-content: flex-end; + order: 3; + } +} + +.gitops-list-page-toolbar:not(:has(.pf-v6-c-toolbar)):not(:has(.pf-c-toolbar)) { + align-items: center; + + .gitops-list-page-toolbar__columns { + min-height: 0; } } diff --git a/src/gitops/components/shared/GitOpsListPageToolbar.tsx b/src/gitops/components/shared/GitOpsListPageToolbar.tsx index e8086996e..185831084 100644 --- a/src/gitops/components/shared/GitOpsListPageToolbar.tsx +++ b/src/gitops/components/shared/GitOpsListPageToolbar.tsx @@ -6,26 +6,27 @@ export type GitOpsListPageToolbarProps = { filters?: React.ReactNode; columnManagement?: React.ReactNode; actions?: React.ReactNode; + pagination?: React.ReactNode; }; export const GitOpsListPageToolbar: React.FC = ({ filters, columnManagement, actions, + pagination, }) => { - if (!filters && !columnManagement && !actions) { + if (!filters && !columnManagement && !actions && !pagination) { return null; } return (
-
- {filters &&
{filters}
} - {columnManagement && ( -
{columnManagement}
- )} -
+ {filters &&
{filters}
} + {columnManagement && ( +
{columnManagement}
+ )} {actions &&
{actions}
} + {pagination &&
{pagination}
}
); }; From a72d605bb0c332055e2a0e6626f7a15b2c64a747 Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Tue, 1 Dec 2026 17:54:34 -0500 Subject: [PATCH 2/2] add tests and Keith's review comments Signed-off-by: Atif Ali --- src/gitops/components/rollout/RolloutList.tsx | 10 ++---- .../rollout/components/PodList/PodList.tsx | 8 ++--- .../rollout/utils/rollout-utils.test.ts | 33 ++++++++++++++++++- .../components/rollout/utils/rollout-utils.ts | 10 ++++++ .../shared/GitOpsListPageToolbar.scss | 13 ++++++-- 5 files changed, 58 insertions(+), 16 deletions(-) diff --git a/src/gitops/components/rollout/RolloutList.tsx b/src/gitops/components/rollout/RolloutList.tsx index 9078a9b5d..59b3a7969 100644 --- a/src/gitops/components/rollout/RolloutList.tsx +++ b/src/gitops/components/rollout/RolloutList.tsx @@ -56,7 +56,7 @@ import { import { useRolloutActionsProvider } from './hooks/useRolloutActionsProvider'; import { RolloutKind, RolloutModel } from './model/RolloutModel'; -import { RolloutStatus } from './utils/rollout-utils'; +import { matchesSelectedStatusPhase, RolloutStatus } from './utils/rollout-utils'; import { topologyLink } from './utils/TopologyLink'; import { RolloutStatusFragment } from './RolloutStatus'; @@ -493,12 +493,8 @@ const getFilters = (t: (key: string) => string): RowFilter[] => [ filterGroupName: t('Rollout Status'), type: 'rollout-status', reducer: (rollout) => rollout.status?.phase, - filter: (input, rollout) => { - if (!input.selected?.length) { - return true; - } - return !!rollout?.status?.phase && input.selected.includes(rollout.status.phase); - }, + filter: (input, rollout) => + matchesSelectedStatusPhase(input.selected, rollout?.status?.phase), items: [ { id: RolloutStatus.Healthy, title: RolloutStatus.Healthy }, { id: RolloutStatus.Paused, title: RolloutStatus.Paused }, diff --git a/src/gitops/components/rollout/components/PodList/PodList.tsx b/src/gitops/components/rollout/components/PodList/PodList.tsx index 02c0056e5..c6d03ad50 100644 --- a/src/gitops/components/rollout/components/PodList/PodList.tsx +++ b/src/gitops/components/rollout/components/PodList/PodList.tsx @@ -13,6 +13,7 @@ import { useGitOpsListPagePagination, } from '@gitops/components/shared/DataView'; import { GitOpsListPageToolbar } from '@gitops/components/shared/GitOpsListPageToolbar'; +import { matchesSelectedStatusPhase } from '@gitops/components/rollout/utils/rollout-utils'; import { getRolloutPodsManagedColumns, ROLLOUT_PODS_COLUMN_MANAGEMENT_ID, @@ -150,12 +151,7 @@ const getFilters = (t: (key: string) => string): RowFilter[] => [ filterGroupName: t('Health Status'), type: 'app-health', reducer: (pod) => pod.status?.phase, - filter: (input, pod) => { - if (!input.selected?.length) { - return true; - } - return !!pod?.status?.phase && input.selected.includes(pod.status.phase); - }, + filter: (input, pod) => matchesSelectedStatusPhase(input.selected, pod?.status?.phase), items: [ { id: PodStatus.RUNNING, title: PodStatus.RUNNING }, { id: PodStatus.PENDING, title: PodStatus.PENDING }, diff --git a/src/gitops/components/rollout/utils/rollout-utils.test.ts b/src/gitops/components/rollout/utils/rollout-utils.test.ts index 5ceee15f2..86e75015e 100644 --- a/src/gitops/components/rollout/utils/rollout-utils.test.ts +++ b/src/gitops/components/rollout/utils/rollout-utils.test.ts @@ -1,4 +1,4 @@ -import { isDeploying } from './rollout-utils'; +import { isDeploying, matchesSelectedStatusPhase, RolloutStatus } from './rollout-utils'; describe('isDeploying', () => { it('returns true for Progressing', () => { @@ -21,3 +21,34 @@ describe('isDeploying', () => { expect(isDeploying({ status: {} } as any)).toMatchInlineSnapshot(`false`); }); }); + +describe('matchesSelectedStatusPhase', () => { + it('passes all rows when nothing is selected', () => { + expect(matchesSelectedStatusPhase([], RolloutStatus.Healthy)).toBe(true); + expect(matchesSelectedStatusPhase(undefined, undefined)).toBe(true); + expect(matchesSelectedStatusPhase([], undefined)).toBe(true); + }); + + it('keeps rows whose phase is in the selection', () => { + expect( + matchesSelectedStatusPhase([RolloutStatus.Healthy], RolloutStatus.Healthy), + ).toBe(true); + expect( + matchesSelectedStatusPhase( + [RolloutStatus.Healthy, RolloutStatus.Degraded], + RolloutStatus.Degraded, + ), + ).toBe(true); + }); + + it('excludes rows with a different phase', () => { + expect( + matchesSelectedStatusPhase([RolloutStatus.Healthy], RolloutStatus.Progressing), + ).toBe(false); + }); + + it('excludes rows with a missing phase when a status is selected', () => { + expect(matchesSelectedStatusPhase([RolloutStatus.Healthy], undefined)).toBe(false); + expect(matchesSelectedStatusPhase([RolloutStatus.Healthy], '')).toBe(false); + }); +}); diff --git a/src/gitops/components/rollout/utils/rollout-utils.ts b/src/gitops/components/rollout/utils/rollout-utils.ts index 343568d3c..6d37545a7 100644 --- a/src/gitops/components/rollout/utils/rollout-utils.ts +++ b/src/gitops/components/rollout/utils/rollout-utils.ts @@ -25,3 +25,13 @@ export function isDeploying(ro: RolloutKind) { return false; } } + +export const matchesSelectedStatusPhase = ( + selected: string[] | undefined, + phase: string | undefined, +): boolean => { + if (!selected?.length) { + return true; + } + return !!phase && selected.includes(phase); +}; diff --git a/src/gitops/components/shared/GitOpsListPageToolbar.scss b/src/gitops/components/shared/GitOpsListPageToolbar.scss index f210a66e6..9ce33d04d 100644 --- a/src/gitops/components/shared/GitOpsListPageToolbar.scss +++ b/src/gitops/components/shared/GitOpsListPageToolbar.scss @@ -23,7 +23,9 @@ .pf-v6-c-toolbar__content:first-child, .pf-c-toolbar__content:first-child { - flex: 0 1 auto; + flex: 1 1 auto; + width: auto; + max-width: 100%; min-width: 0; order: 1; padding-inline: 0; @@ -34,12 +36,14 @@ .pf-c-toolbar__content-section { flex-wrap: wrap; width: auto; + max-width: 100%; row-gap: var(--pf-t--global--spacer--sm); } .pf-v6-c-toolbar__content:not(:first-child), .pf-c-toolbar__content:not(:first-child) { flex: 1 1 100%; + width: 100%; order: 4; padding-inline: 0; padding-block-end: 0; @@ -50,6 +54,7 @@ display: inline-flex; flex: 0 0 auto; align-items: center; + align-self: flex-start; order: 2; gap: var(--pf-t--global--spacer--xs); min-height: var(--pf-t--global--spacer--2xl); @@ -59,7 +64,10 @@ display: flex; flex: 0 0 auto; align-items: center; + align-self: flex-start; order: 2; + margin-inline-start: auto; + min-height: var(--pf-t--global--spacer--2xl); } &__pagination { @@ -73,7 +81,8 @@ .gitops-list-page-toolbar:not(:has(.pf-v6-c-toolbar)):not(:has(.pf-c-toolbar)) { align-items: center; - .gitops-list-page-toolbar__columns { + .gitops-list-page-toolbar__columns, + .gitops-list-page-toolbar__actions { min-height: 0; } }