Skip to content

Commit

Permalink
fix(esl-share): rename copy action alertText param to copyAlertMsg
Browse files Browse the repository at this point in the history
Co-authored-by: Dmitry Shovchko <dshovchko@exadel.com>
(cherry picked from commit 3ba61ac)
  • Loading branch information
ala-n committed Apr 9, 2024
1 parent b9b4e5f commit d3e3c3a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/modules/esl-share/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ or for example the configuration of the copy button
"name": "copy",
"title": "Copy",
"additional": {
"alertText": "Copied to clipboard"
"copyAlertMsg": "Copied to clipboard"
}
}
```
Expand Down Expand Up @@ -221,7 +221,7 @@ The group may include another group. So this configuration describing nested gro
### Share actions available for use

ESLShare provides several actions available for you to use:
- `copy` - action for copying to the clipboard. It can use additional params `alertText` (with message text) to show an alert to indicate a successful operation
- `copy` - action for copying to the clipboard. It can use additional params `copyAlertMsg` (with message text) to show an alert to indicate a successful operation
- `external` - action for sharing via an external application. It is used to produce actions via external applications linked via schema in URL (for example mailto:, news: or tel: )
- `media` - action for sharing via a link to share on a social media
- `native` - action for sharing that invokes the native sharing mechanism of Web Share API
Expand Down
8 changes: 4 additions & 4 deletions src/modules/esl-share/actions/copy-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ export class ESLShareCopyAction extends ESLShareBaseAction {
if (!this.isAvailable || !url) return;

await navigator.clipboard.writeText(url);
this.showCopyAlert($button.shareAdditional?.alertText);
this.showCopyAlert($button.shareAdditional?.copyAlertMsg);
}

/** Shows alert about the successful action completion */
protected showCopyAlert(alertText: string): void {
if (!alertText) return;
protected showCopyAlert(msg: string): void {
if (!msg) return;
const detail = {
cls: 'esl-share-alert',
html: `<span>${alertText}</span>`
html: `<span>${msg}</span>`
};
ESLEventUtils.dispatch(document.body, 'esl:alert:show', {detail});
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/esl-share/buttons/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const copy: ESLShareButtonConfig = {
name: 'copy',
title: 'Copy',
additional: {
alertText: 'Copied to clipboard'
copyAlertMsg: 'Copied to clipboard'
}
};
ESLShareConfig.append(copy);
4 changes: 2 additions & 2 deletions src/modules/esl-share/test/actions/copy-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('ESLShare: "copy" action public API', () => {
document.body.appendChild($button);
$button.setAttribute('share-title', 'Test button title');
$button.setAttribute('share-url', '/test/button/url');
$button.setAttribute('additional', '{"alertText": "Copied to clipboard"}');
$button.setAttribute('additional', '{"copyAlertMsg": "Copied to clipboard"}');
});

afterEach(() => {
Expand All @@ -44,7 +44,7 @@ describe('ESLShare: "copy" action public API', () => {
expect(mockClipboard.writeText).toBeCalledWith('http://localhost/test/button/url');
});

test('should dispatch esl:alert:show with shareAdditional.alertText when share() calls', (done) => {
test('should dispatch esl:alert:show with shareAdditional.copyAlertMsg when share() calls', (done) => {
document.body.addEventListener('esl:alert:show', (e) => {
expect((e as CustomEvent).detail).toEqual({
cls: 'esl-share-alert',
Expand Down
2 changes: 1 addition & 1 deletion src/modules/esl-share/test/esl-share-button.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('ESLShareButton tests', () => {
});

test('shareAdditional getter available', () => {
expect($copyButton.shareAdditional).toEqual({alertText: 'Copied to clipboard'});
expect($copyButton.shareAdditional).toEqual({copyAlertMsg: 'Copied to clipboard'});
});
test('shareLink getter available', () => {
expect($facebookButton.shareLink).toBe('//www.facebook.com/sharer.php?u={u}');
Expand Down

0 comments on commit d3e3c3a

Please # to comment.