Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi select in StandardPage component #504

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/common/src/components/TableView/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface RowProps<T> {
resourceData: T;
resourceIndex: number;
namespace: string;
isSelected?: boolean;
toggleSelect?: () => void;
}

export interface TableViewHeaderProps {
Expand Down
4 changes: 4 additions & 0 deletions packages/common/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ export type ResourceFieldFactory = { (t: (string) => string): ResourceField[] };

export const K8sConditionStatusValues = ['True', 'False', 'Unknown'] as const;
export type K8sConditionStatus = (typeof K8sConditionStatusValues)[number];

export interface GlobalActionToolbarProps<T> {
dataOnScreen: T[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
defaultValueMatchers,
FilterGroup,
FilterRenderer,
GlobalActionToolbarProps,
toFieldFilter,
useUrlFilters,
ValueMatcher,
Expand Down Expand Up @@ -147,6 +148,11 @@ export interface StandardPageProps<T> {
* Alerts section below the page title
*/
alerts?: ReactNode;

/**
* Toolbar items with global actions.
*/
GlobalActionToolbarItems?: ((props: GlobalActionToolbarProps<T>) => JSX.Element)[];
}

/**
Expand All @@ -167,6 +173,7 @@ export function StandardPage<T>({
filterPrefix = '',
extraSupportedMatchers,
HeaderMapper = DefaultHeader,
GlobalActionToolbarItems = [],
alerts,
}: StandardPageProps<T>) {
const {
Expand Down Expand Up @@ -259,6 +266,10 @@ export function StandardPage<T>({
defaultColumns={fieldsMetadata}
setColumns={setFields}
/>
{GlobalActionToolbarItems?.length > 0 &&
GlobalActionToolbarItems.map((Action, index) => (
<Action key={index} dataOnScreen={showPagination ? pageData : filteredData} />
))}
</ToolbarToggleGroup>
{showPagination && (
<ToolbarItem variant="pagination">
Expand Down