Skip to content

Commit

Permalink
Copy URL option in dashboard dropdown (#374)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai authored Feb 21, 2025
1 parent 7761a59 commit b1a7747
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ function initMoreOptions(props, config, eventObj, row) {

const previewPre = buildTool(toolBox, 'Preview pre-event', 'preview-eye');
const previewPost = buildTool(toolBox, 'Preview post-event', 'preview-eye');
const copyUrl = buildTool(toolBox, 'Copy URL', 'copy');
const edit = buildTool(toolBox, 'Edit', 'edit-pencil');
const clone = buildTool(toolBox, 'Clone', 'clone');
const deleteBtn = buildTool(toolBox, 'Delete', 'delete-wire-round');
Expand Down Expand Up @@ -353,9 +354,25 @@ function initMoreOptions(props, config, eventObj, row) {
return '#';
})();
previewPost.target = '_blank';

copyUrl.addEventListener('click', (e) => {
let url;
try {
url = new URL(`${eventObj.detailPagePath}`);
} catch (err) {
url = new URL(`${getEventPageHost()}${eventObj.detailPagePath}`);
}

if (url) {
e.preventDefault();
navigator.clipboard.writeText(url.href);
showToast(props, config['copy-url-toast-msg'] || 'The URL has been added to the clipboard', { variant: 'positive', timeout: 6000 });
}
});
} else {
previewPre.classList.add('disabled');
previewPost.classList.add('disabled');
copyUrl.classList.add('disabled');
}

// edit
Expand Down
31 changes: 31 additions & 0 deletions ecc/icons/copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b1a7747

Please sign in to comment.