add dialog for copy to clipboard fallback (fixes #152)

This commit is contained in:
Henry Dollman
2024-09-02 19:37:44 -04:00
parent aa3866c8ed
commit 202a506485
6 changed files with 105 additions and 17 deletions

View File

@@ -25,3 +25,6 @@ export const $chartTime = atom('1h') as WritableAtom<ChartTimes>
/** Container chart filter */
export const $containerFilter = atom('')
/** Fallback copy to clipboard dialog content */
export const $copyContent = atom('')

View File

@@ -1,7 +1,7 @@
import { toast } from '@/components/ui/use-toast'
import { type ClassValue, clsx } from 'clsx'
import { twMerge } from 'tailwind-merge'
import { $alerts, $systems, pb } from './stores'
import { $alerts, $copyContent, $systems, pb } from './stores'
import { AlertRecord, ChartTimeData, ChartTimes, SystemRecord } from '@/types'
import { RecordModel, RecordSubscription } from 'pocketbase'
import { WritableAtom } from 'nanostores'
@@ -22,10 +22,7 @@ export async function copyToClipboard(content: string) {
description: 'Copied to clipboard',
})
} catch (e: any) {
prompt(
'Automatic copy requires a secure context (https, localhost, or *.localhost). Please copy manually:',
content
)
$copyContent.set(content)
}
}