From 12ac4a661b0b7715b8ceb48976090dee8d097ae1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Mon, 5 Sep 2022 13:39:48 +0200 Subject: [PATCH] If clipboard is unavailable, show actions dialogs --- pages/get-playlist-id.vue | 41 +++++++------ .../snapshots/show/[commitSha].vue | 59 +++++++++++-------- 2 files changed, 58 insertions(+), 42 deletions(-) diff --git a/pages/get-playlist-id.vue b/pages/get-playlist-id.vue index 4d2d049..3ab4ae2 100644 --- a/pages/get-playlist-id.vue +++ b/pages/get-playlist-id.vue @@ -2,17 +2,18 @@ import ProgressSpinner from 'primevue/progressspinner'; import InputText from 'primevue/inputtext'; import Button from 'primevue/button'; +import Dialog from 'primevue/dialog'; import { useToast } from 'primevue/usetoast'; const toast = useToast(); const getPlaylistId = useGetPlaylistId(); const { copy } = useClipboard(); -const { isSupported, clipboardWirtePermission, canCopyToClipboard } = - useCanCopyToClipboard(); +const { canCopyToClipboard } = useCanCopyToClipboard(); const playlistUrl = ref(''); const idToShow = ref(''); +const canShowFallbackDialog = ref(false); const actionButtonLabel = computed(() => canCopyToClipboard.value ? 'Copy ID' : 'Show ID' @@ -23,11 +24,13 @@ const copyOrShowPlaylistId = async () => { const playlistId = getPlaylistId(playlistUrl.value); - if (!canCopyToClipboard.value) return (idToShow.value = playlistId); + if (!canCopyToClipboard.value) { + idToShow.value = playlistId; + canShowFallbackDialog.value = true; + return; + } await copy(playlistId); - playlistUrl.value = ''; - toast.add({ severity: 'success', summary: 'Success', @@ -40,22 +43,13 @@ const copyOrShowPlaylistId = async () => {