Skip to content

Commit a89adfd

Browse files
committed
feat: add clear selection button label config
1 parent 92b7439 commit a89adfd

File tree

5 files changed

+32
-4
lines changed

5 files changed

+32
-4
lines changed

packages/pluggableWidgets/datagrid-web/src/Datagrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ const Container = observer((props: Props): ReactElement => {
117117
pageSize={props.pageSize}
118118
paginationType={props.pagination}
119119
loadMoreButtonCaption={props.loadMoreButtonCaption?.value}
120+
clearSelectionButtonLabel={props.clearSelectionButtonLabel?.value}
120121
paging={paginationCtrl.showPagination}
121122
pagingPosition={props.pagingPosition}
122123
showPagingButtons={props.showPagingButtons}

packages/pluggableWidgets/datagrid-web/src/Datagrid.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
<caption>Show refresh indicator</caption>
6666
<description>Show a refresh indicator when the data is being loaded.</description>
6767
</property>
68+
<property key="clearSelectionButtonLabel" type="textTemplate" required="false">
69+
<caption>Clear selection</caption>
70+
<description>Customize the label of the 'Clear section' button</description>
71+
<translations>
72+
<translation lang="en_US">Clear selection</translation>
73+
</translations>
74+
</property>
6875
</propertyGroup>
6976
<propertyGroup caption="Columns">
7077
<property key="columns" type="object" isList="true">

packages/pluggableWidgets/datagrid-web/src/components/Widget.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface WidgetProps<C extends GridColumn, T extends ObjectItem = Object
4848
page: number;
4949
paginationType: PaginationEnum;
5050
loadMoreButtonCaption?: string;
51+
clearSelectionButtonLabel?: string;
5152
pageSize: number;
5253
paging: boolean;
5354
pagingPosition: PagingPositionEnum;
@@ -118,6 +119,7 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
118119
headerContent,
119120
headerTitle,
120121
loadMoreButtonCaption,
122+
clearSelectionButtonLabel,
121123
numberOfItems,
122124
page,
123125
pageSize,
@@ -235,6 +237,7 @@ const Main = observer(<C extends GridColumn>(props: WidgetProps<C>): ReactElemen
235237
pagingPosition={pagingPosition}
236238
paginationType={paginationType}
237239
loadMoreButtonCaption={loadMoreButtonCaption}
240+
clearSelectionButtonLabel={clearSelectionButtonLabel}
238241
hasMoreItems={hasMoreItems}
239242
setPage={setPage}
240243
/>

packages/pluggableWidgets/datagrid-web/src/components/WidgetFooter.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@ type WidgetFooterProps = {
99
pagination: ReactNode;
1010
paginationType: PaginationEnum;
1111
loadMoreButtonCaption?: string;
12+
clearSelectionButtonLabel?: string;
1213
hasMoreItems: boolean;
1314
setPage?: (computePage: (prevPage: number) => number) => void;
1415
} & JSX.IntrinsicElements["div"];
1516

1617
export function WidgetFooter(props: WidgetFooterProps): ReactElement | null {
17-
const { pagingPosition, pagination, paginationType, loadMoreButtonCaption, hasMoreItems, setPage, ...rest } = props;
18+
const {
19+
pagingPosition,
20+
pagination,
21+
paginationType,
22+
loadMoreButtonCaption,
23+
clearSelectionButtonLabel,
24+
hasMoreItems,
25+
setPage,
26+
...rest
27+
} = props;
28+
1829
return (
1930
<div {...rest} className="widget-datagrid-footer table-footer">
2031
<div className="widget-datagrid-paging-bottom">
2132
<div className="widget-datagrid-pb-start">
22-
<SelectionCounter />
33+
<SelectionCounter clearSelectionButtonLabel={clearSelectionButtonLabel} />
2334
</div>
2435
{hasMoreItems && paginationType === "loadMore" && (
2536
<div className="widget-datagrid-pb-middle">
@@ -40,14 +51,18 @@ export function WidgetFooter(props: WidgetFooterProps): ReactElement | null {
4051
);
4152
}
4253

43-
const SelectionCounter = observer(function SelectionCounter() {
54+
const SelectionCounter = observer(function SelectionCounter({
55+
clearSelectionButtonLabel
56+
}: {
57+
clearSelectionButtonLabel?: string;
58+
}) {
4459
const { selectionCountStore, selectActionHelper } = useDatagridRootScope();
4560

4661
return (
4762
<If condition={selectionCountStore.displayCount !== ""}>
4863
<span className="widget-datagrid-selection-count">{selectionCountStore.displayCount}</span>&nbsp;|&nbsp;
4964
<button className="widget-datagrid-clear-selection" onClick={selectActionHelper.onClearSelection}>
50-
Clear selection
65+
{clearSelectionButtonLabel || "Clear selection"}
5166
</button>
5267
</If>
5368
);

packages/pluggableWidgets/datagrid-web/typings/DatagridProps.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export interface DatagridContainerProps {
9898
keepSelection: boolean;
9999
loadingType: LoadingTypeEnum;
100100
refreshIndicator: boolean;
101+
clearSelectionButtonLabel?: DynamicValue<string>;
101102
columns: ColumnsType[];
102103
columnsFilterable: boolean;
103104
pageSize: number;
@@ -150,6 +151,7 @@ export interface DatagridPreviewProps {
150151
keepSelection: boolean;
151152
loadingType: LoadingTypeEnum;
152153
refreshIndicator: boolean;
154+
clearSelectionButtonLabel: string;
153155
columns: ColumnsPreviewType[];
154156
columnsFilterable: boolean;
155157
pageSize: number | null;

0 commit comments

Comments
 (0)