Skip to content

Commit ecc5f02

Browse files
committed
use friendlyId for payload copy operations in side bars
1 parent 398dccd commit ecc5f02

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

app/pages/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ const confirmDeleteToken = async () => {
9999
100100
const copyPayloadURL = async (id: string) => {
101101
const origin = typeof window !== 'undefined' ? window.location.origin : ''
102-
const url = `${origin}/api/payload/${id}`
102+
const token = tokens.value?.find(t => t.id === id)
103+
const friendlyId = token?.friendlyId ?? shortSlug(id)
104+
const url = `${origin}/api/payload/${friendlyId}`
103105
await copyText(url)
104106
notify({ title: 'URL copied', description: url, color: 'success', })
105107
}

app/pages/token/[id].vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { ref, computed, watch, onMounted, onUnmounted } from 'vue'
5454
import { useRoute } from 'vue-router'
5555
import type { LocationQueryRaw } from 'vue-router'
5656
import { useRequestsStore } from '~/stores/requests'
57+
import { useTokensStore } from '~/stores/tokens'
5758
import { useSSE } from '~/composables/useSSE'
5859
import type { SSEEventPayload, RequestSummary } from '~~/shared/types'
5960
import { notify } from '~/composables/useNotificationBridge'
@@ -62,12 +63,14 @@ import ResponseSettingsCard from '~/components/token/ResponseSettingsCard.vue'
6263
import RequestDetailsCard from '~/components/token/RequestDetailsCard.vue'
6364
import RawRequestCard from '~/components/token/RawRequestCard.vue'
6465
import IngestRequestModal from '~/components/IngestRequestModal.vue'
65-
import { copyText } from '~/utils'
66+
import { copyText, shortSlug } from '~/utils'
6667
6768
const route = useRoute()
6869
6970
const tokenId = computed(() => String(route.params.id || ''))
7071
72+
const { data: token } = useTokensStore().useToken(tokenId)
73+
7174
const requestsStore = useRequestsStore()
7275
const { data: requests } = requestsStore.useRequestsList(tokenId)
7376
const { mutateAsync: deleteRequestMutation } = requestsStore.useDeleteRequest()
@@ -164,7 +167,8 @@ const handleDeleteRequest = async (id: string) => {
164167
165168
const copyPayloadURL = async () => {
166169
const origin = typeof window !== 'undefined' ? window.location.origin : ''
167-
const url = `${origin}/api/payload/${tokenId.value}`
170+
const friendlyId = token.value?.friendlyId ?? shortSlug(tokenId.value)
171+
const url = `${origin}/api/payload/${friendlyId}`
168172
169173
try {
170174
await copyText(url)

0 commit comments

Comments
 (0)