Skip to content

Commit 05b0b6a

Browse files
committed
add footer action button text props
1 parent 446fd02 commit 05b0b6a

4 files changed

Lines changed: 52 additions & 5 deletions

File tree

packages/module/src/AttachmentEdit/AttachmentEdit.test.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,22 @@ describe('AttachmentEdit', () => {
5151
fireEvent.click(screen.getByText('Cancel'));
5252
expect(onCancelHandler).toHaveBeenCalled();
5353
});
54+
55+
it('should render custom button text for footer actions buttons', () => {
56+
render(
57+
<AttachmentEdit
58+
code="Hello world"
59+
fileName="greetings.txt"
60+
isModalOpen={true}
61+
onCancel={jest.fn()}
62+
onSave={jest.fn()}
63+
handleModalToggle={jest.fn()}
64+
primaryActionButtonText="Save"
65+
secondaryActionButtonText="Close"
66+
/>
67+
);
68+
69+
screen.getByText('Save');
70+
screen.getByText('Close');
71+
});
5472
});

packages/module/src/AttachmentEdit/AttachmentEdit.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export interface AttachmentEditProps {
2424
displayMode?: ChatbotDisplayMode;
2525
/** Sets modal to compact styling. */
2626
isCompact?: boolean;
27+
/** Primary action button text */
28+
primaryActionButtonText?: string;
29+
/** Secondary action button text */
30+
secondaryActionButtonText?: string;
2731
}
2832

2933
export const AttachmentEdit: FunctionComponent<AttachmentEditProps> = ({
@@ -35,7 +39,9 @@ export const AttachmentEdit: FunctionComponent<AttachmentEditProps> = ({
3539
onSave,
3640
title = 'Edit attachment',
3741
displayMode = ChatbotDisplayMode.default,
38-
isCompact
42+
isCompact,
43+
primaryActionButtonText = 'Save',
44+
secondaryActionButtonText = 'Cancel'
3945
}: AttachmentEditProps) => {
4046
const handleSave = (_event: ReactMouseEvent | MouseEvent | KeyboardEvent, code) => {
4147
handleModalToggle(_event);
@@ -55,8 +61,8 @@ export const AttachmentEdit: FunctionComponent<AttachmentEditProps> = ({
5561
isModalOpen={isModalOpen}
5662
onPrimaryAction={handleSave}
5763
onSecondaryAction={handleCancel}
58-
primaryActionBtn="Save"
59-
secondaryActionBtn="Cancel"
64+
primaryActionBtn={primaryActionButtonText}
65+
secondaryActionBtn={secondaryActionButtonText}
6066
title={title}
6167
displayMode={displayMode}
6268
isCompact={isCompact}

packages/module/src/PreviewAttachment/PreviewAttachment.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,21 @@ describe('PreviewAttachment', () => {
4747

4848
expect(onDismiss).toHaveBeenCalled();
4949
});
50+
51+
it('should render custom button text for footer actions buttons', () => {
52+
render(
53+
<PreviewAttachment
54+
code="Hello world"
55+
fileName="greetings.txt"
56+
isModalOpen={true}
57+
onEdit={jest.fn()}
58+
handleModalToggle={jest.fn()}
59+
primaryActionButtonText="Edit"
60+
secondaryActionButtonText="Close"
61+
/>
62+
);
63+
64+
screen.getByText('Edit');
65+
screen.getByText('Close');
66+
});
5067
});

packages/module/src/PreviewAttachment/PreviewAttachment.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export interface PreviewAttachmentProps {
2424
displayMode?: ChatbotDisplayMode;
2525
/** Sets modal to compact styling. */
2626
isCompact?: boolean;
27+
/** Primary action button text */
28+
primaryActionButtonText?: string;
29+
/** Secondary action button text */
30+
secondaryActionButtonText?: string;
2731
}
2832

2933
export const PreviewAttachment: FunctionComponent<PreviewAttachmentProps> = ({
@@ -34,6 +38,8 @@ export const PreviewAttachment: FunctionComponent<PreviewAttachmentProps> = ({
3438
onDismiss = undefined,
3539
onEdit,
3640
title = 'Preview attachment',
41+
primaryActionButtonText = 'Edit',
42+
secondaryActionButtonText = 'Dismiss',
3743
displayMode = ChatbotDisplayMode.default,
3844
isCompact
3945
}: PreviewAttachmentProps) => {
@@ -58,8 +64,8 @@ export const PreviewAttachment: FunctionComponent<PreviewAttachmentProps> = ({
5864
isModalOpen={isModalOpen}
5965
onPrimaryAction={handleEdit}
6066
onSecondaryAction={handleDismiss}
61-
primaryActionBtn="Edit"
62-
secondaryActionBtn="Dismiss"
67+
primaryActionBtn={primaryActionButtonText}
68+
secondaryActionBtn={secondaryActionButtonText}
6369
title={title}
6470
isReadOnly
6571
displayMode={displayMode}

0 commit comments

Comments
 (0)