Skip to content

Commit ee8c263

Browse files
committed
feat: updated package claim visibility
1 parent 29158b6 commit ee8c263

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

app/components/Package/ClaimPackageModal.vue

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { checkPackageName } from '~/utils/package-name'
33
44
const props = defineProps<{
55
packageName: string
6+
packageScope?: string | null
7+
canPublishToScope: boolean
68
}>()
79
810
const {
@@ -221,9 +223,19 @@ const previewPackageJson = computed(() => {
221223
</div>
222224

223225
<!-- Availability status -->
224-
<div v-if="checkResult.valid">
226+
<template v-if="checkResult.valid">
225227
<div
226-
v-if="checkResult.available"
228+
v-if="isConnected && !canPublishToScope"
229+
class="flex items-center gap-3 p-4 bg-red-500/10 border border-red-500/20 rounded-lg"
230+
>
231+
<span class="i-lucide:x text-red-500 w-5 h-5" aria-hidden="true" />
232+
<p class="font-mono text-sm text-fg">
233+
{{ $t('claim.modal.missing_permission', { scope: packageScope }) }}
234+
</p>
235+
</div>
236+
237+
<div
238+
v-else-if="checkResult.available"
227239
class="flex items-center gap-3 p-4 bg-green-500/10 border border-green-500/20 rounded-lg"
228240
>
229241
<span class="i-lucide:check text-green-500 w-5 h-5" aria-hidden="true" />
@@ -237,10 +249,10 @@ const previewPackageJson = computed(() => {
237249
<span class="i-lucide:x text-red-500 w-5 h-5" aria-hidden="true" />
238250
<p class="font-mono text-sm text-fg">{{ $t('claim.modal.taken') }}</p>
239251
</div>
240-
</div>
252+
</template>
241253

242254
<!-- Similar packages warning -->
243-
<div v-if="checkResult.similarPackages?.length && checkResult.available">
255+
<template v-if="checkResult.similarPackages?.length && checkResult.available">
244256
<div
245257
:class="
246258
hasDangerousSimilarPackages
@@ -290,7 +302,7 @@ const previewPackageJson = computed(() => {
290302
</li>
291303
</ul>
292304
</div>
293-
</div>
305+
</template>
294306

295307
<!-- Error message -->
296308
<div
@@ -336,7 +348,7 @@ const previewPackageJson = computed(() => {
336348
</div>
337349

338350
<!-- Claim button -->
339-
<div v-else class="space-y-3">
351+
<div v-else-if="isConnected && canPublishToScope" class="space-y-3">
340352
<p class="text-sm text-fg-muted">
341353
{{ $t('claim.modal.publish_hint') }}
342354
</p>

app/pages/search.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,13 @@ const canPublishToScope = computed(() => {
332332
return orgMembership.value[scope] === true
333333
})
334334
335-
// Show claim prompt when valid name, available, connected, and has permission
335+
// Show claim prompt when valid name, available, either not connected or connected and has permission
336336
const showClaimPrompt = computed(() => {
337337
return (
338-
isConnected.value &&
339338
isValidPackageName.value &&
340339
packageAvailability.value?.available === true &&
341340
packageAvailability.value.name === query.value.trim() &&
342-
canPublishToScope.value &&
341+
(!isConnected.value || (isConnected.value && canPublishToScope.value)) &&
343342
status.value !== 'pending'
344343
)
345344
})
@@ -569,7 +568,7 @@ defineOgImageComponent('Default', {
569568
<!-- Claim prompt - shown at top when valid name but no exact match -->
570569
<div
571570
v-if="showClaimPrompt && visibleResults.total > 0"
572-
class="mb-6 p-4 bg-bg-subtle border border-border rounded-lg flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4"
571+
class="mb-6 p-4 bg-bg-subtle border border-border rounded-lg sm:flex hidden flex-row sm:items-center gap-3 sm:gap-4"
573572
>
574573
<div class="flex-1 min-w-0">
575574
<p class="font-mono text-sm text-fg">
@@ -687,7 +686,7 @@ defineOgImageComponent('Default', {
687686
</div>
688687

689688
<!-- Offer to claim the package name if it's valid -->
690-
<div v-if="showClaimPrompt" class="max-w-md mx-auto text-center">
689+
<div v-if="showClaimPrompt" class="max-w-md mx-auto text-center hidden sm:block">
691690
<div class="p-4 bg-bg-subtle border border-border rounded-lg">
692691
<p class="text-sm text-fg-muted mb-3">{{ $t('search.want_to_claim') }}</p>
693692
<button
@@ -741,6 +740,11 @@ defineOgImageComponent('Default', {
741740
</div>
742741

743742
<!-- Claim package modal -->
744-
<PackageClaimPackageModal ref="claimPackageModalRef" :package-name="query" />
743+
<PackageClaimPackageModal
744+
ref="claimPackageModalRef"
745+
:package-name="query"
746+
:package-scope="packageScope"
747+
:can-publish-to-scope="canPublishToScope"
748+
/>
745749
</main>
746750
</template>

0 commit comments

Comments
 (0)