Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Edit Collection & NFT UI #11171

Merged
merged 50 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ebbf6c5
add(collectinos): init new edit collection modal
hassnian Oct 28, 2024
b90b894
add(collection): edit collection transaction
hassnian Oct 29, 2024
c7d369c
add(transactionUpdateCollection.ts): collection banner in metadata
hassnian Oct 30, 2024
193601f
ref(transactionUpdateCollection.ts): one liner
hassnian Oct 30, 2024
3d9ec0c
fix(useTransaction.ts): api param type
hassnian Oct 30, 2024
57c820a
fix(EditModal.vue): disabled computed
hassnian Oct 30, 2024
b1d22cf
add(HeroButtonEditCollection.vue): refresh page on collection data in…
hassnian Oct 30, 2024
cecd403
fix(EditModal.vue): collection max overriden on image upload
hassnian Oct 30, 2024
8ec7cbc
add(HeroButtons.vue): refresh collection metadata
hassnian Oct 30, 2024
ebe3879
Merge branch 'main' into issue-5286-1
hassnian Oct 31, 2024
fea4527
add(EditModal.vue): into translation keys
hassnian Oct 31, 2024
b0b7ce5
Merge branch 'issue-5286-1' of https://github.com/hassnian/nft-galler…
hassnian Oct 31, 2024
5b5f880
add(EditModal.vue): capitalize text
hassnian Oct 31, 2024
dd0d332
add(GalleryItem): set collection metadata
hassnian Nov 1, 2024
0991b28
fix(EditNftModal.vue): disabled computed and attributes updating
hassnian Nov 2, 2024
b7c6d17
add(GalleryItem): refresh page on metadata update
hassnian Nov 2, 2024
a9b7c25
ref(GalleryItemEditNftButton.vue): cleaner code
hassnian Nov 2, 2024
7a873f3
update: edit collection and edit nft sign transaction modal
hassnian Nov 2, 2024
3a47685
fix(EditModal.vue): submit button disabled on image change
hassnian Nov 4, 2024
ececa74
ref(transactionUpdateCollection.ts): update collection max if supply …
hassnian Nov 4, 2024
be4edc9
fix(HeroButtonEditCollection.vue): collection data refresh subscription
hassnian Nov 4, 2024
64c8b89
fix(GalleryItemEditNftButton.vue): invalid metadata case
hassnian Nov 4, 2024
33cc62d
fix(useGalleryItem.ts): refresh token on metdata update
hassnian Nov 4, 2024
01d1051
fix: translation key typo
hassnian Nov 4, 2024
c4bdec1
ref: reuse logo field section
hassnian Nov 4, 2024
d824cc6
ref: add prefix form to common/form
hassnian Nov 5, 2024
509dcdf
ref(EditNftModal.vue): remove required optional hint from label
hassnian Nov 5, 2024
2a7c157
ref(FormLogoField.vue): add `title` and `hint` props
hassnian Nov 5, 2024
ee4728f
fix(CollectionCard.vue): use `banner` metadata field
hassnian Nov 5, 2024
be7198b
fix(transactionUpdateCollection.ts): `unSanitizeIpfsUrl` banner field
hassnian Nov 5, 2024
17809c3
ref: Sonarcloud Remove redundant type alias and replace its occurrenc…
hassnian Nov 5, 2024
01a4280
fix: sonarcloud issues
hassnian Nov 5, 2024
d2aecb8
fix: sonarcloud img alt issue
hassnian Nov 5, 2024
2c0db4c
fix(transaction/types.ts): `UpdateCollection` missing export
hassnian Nov 5, 2024
e8afcb1
ref(EditNftModal.vue): cleaner and more efficient deep clonning
hassnian Nov 5, 2024
d699fba
ref: remove unused `data-testid`
hassnian Nov 5, 2024
3bc2422
ref(GalleryItemEditNftButton.vue): move composable above
hassnian Nov 5, 2024
5ca5ef7
fix(GalleryItemEditNftButton.vue): fetch metadata when nft is provided
hassnian Nov 5, 2024
3084239
ref: remove nullish props from edit modals
hassnian Nov 5, 2024
06a61e0
ref(CollectionCard.vue): use from
hassnian Nov 18, 2024
cb1fbd3
ref(CollectionCard.vue): use `CollectionMetadata` from `hyperdata`
hassnian Nov 18, 2024
9c1706a
Merge branch 'issue-5286-1' of https://github.com/hassnian/nft-galler…
hassnian Nov 18, 2024
9db9aa4
Merge branch 'feature/init/swapLanding' of https://github.com/roiLeo/…
hassnian Nov 23, 2024
8907dc0
fix(GalleryItemEditNftButton.vue): key nft metadata
hassnian Nov 23, 2024
492f13b
ref(transaction): `transactionUpdateCollection` optional update metadata
hassnian Nov 23, 2024
46a84dd
Trigger Build
hassnian Nov 23, 2024
2723532
fix: pnpm-lock.yaml failing build
hassnian Nov 23, 2024
3b977bc
Merge branch 'main' into issue-5286-1
vikiival Nov 24, 2024
f84802d
ref: update pnpm-lock.yaml
hassnian Nov 25, 2024
da9cd4b
ref: soft update `pnpm-lock.yaml`
hassnian Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions components/collection/CollectionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:to="`/${urlPrefix}/collection/${collection.id}`"
>
<BasicImage
:src="image"
:src="banner"
:alt="collection.name"
:lazy="lazyLoading"
sizes="300px md:350px"
Expand Down Expand Up @@ -40,7 +40,7 @@

<script setup lang="ts">
import { NeoSkeleton } from '@kodadot1/brick'
import type { TokenMetadata } from '@kodadot1/hyperdata'
import type { CollectionMetadata } from '@kodadot1/hyperdata'
import CollectionDetail from './CollectionDetail.vue'
import type { CollectionWithMeta } from '@/types'
import BasicImage from '@/components/shared/view/BasicImage.vue'
Expand All @@ -55,17 +55,21 @@ const props = defineProps<{

const isLoadingMeta = ref(false)
const image = ref('')
const banner = ref('')

const { urlPrefix } = usePrefix()

const getImageFromMetadata = async (collectionMetadata: string) => {
isLoadingMeta.value = true

const metadata = (await processSingleMetadata(
collectionMetadata,
)) as TokenMetadata
const metadata = await processSingleMetadata<CollectionMetadata>(collectionMetadata)

const metadataImage = getCollectionImage(metadata) || ''
const metadataBanner = metadata.banner || metadataImage

image.value = sanitizeIpfsUrl(metadataImage)
banner.value = sanitizeIpfsUrl(metadataBanner)

image.value = sanitizeIpfsUrl(getCollectionImage(metadata) || '')
isLoadingMeta.value = false
}

Expand All @@ -76,9 +80,11 @@ onMounted(async () => {

const meta = props.collection.meta
const metaImage = meta ? getCollectionImage(meta) : undefined
const metaBanner = meta?.banner || metaImage

if (metaImage) {
if (metaImage && metaBanner) {
image.value = sanitizeIpfsUrl(metaImage)
banner.value = sanitizeIpfsUrl(metaBanner)
}
else {
getImageFromMetadata(props.collection.metadata)
Expand Down
20 changes: 20 additions & 0 deletions components/collection/CollectionHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<section class="pt-5">
<div class="container is-fluid">
<CollectionInfo
ref="collectionInfo"
:collection-id="collectionId"
:collection="collection"
/>
Expand All @@ -21,12 +22,31 @@ import { useCollectionMinimal } from '@/components/collection/utils/useCollectio
import CollectionInfo from '@/components/collection/CollectionInfo.vue'
import CollectionBanner from '@/components/collection/CollectionHeader/CollectionBanner.vue'

const collectionInfo = ref()

const { toast } = useToast()
const { $i18n } = useNuxtApp()
const route = useRoute()
const collectionId = computed(() => route.params.id.toString())

const { collection, refetch } = useCollectionMinimal({
collectionId,
})

useSubscriptionGraphql({
query: `
collectionEntity: collectionEntityById(id: "${collectionId.value}") {
max
metadata
}
`,
onChange: () => {
toast($i18n.t('edit.collection.updated'))
refetch()
collectionInfo.value?.refetch()
},
immediate: false,
})

watch(collectionId, () => refetch())
</script>
4 changes: 3 additions & 1 deletion components/collection/CollectionInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ const visibleDescription = computed(() => {
)
})

const { stats } = useCollectionDetails({
const { stats, refetch } = useCollectionDetails({
collectionId: computed(() => props.collectionId),
})

defineExpose({ refetch })
</script>
93 changes: 0 additions & 93 deletions components/collection/CustomizeModal.vue

This file was deleted.

182 changes: 182 additions & 0 deletions components/collection/EditModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
<template>
<NeoModal
:value="isModalActive"
@close="isModalActive = false"
>
<ModalBody
:title="$t('edit.collection.title')"
:scrollable="false"
@close="isModalActive = false"
>
<form
class="flex flex-col gap-6"
@submit.prevent
>
<CollectionEditSection :title="$t('edit.collection.image.label')">
<FormLogoField
v-model:file="image"
v-model:url="imageUrl"
:title="$t('edit.collection.image.message')"
/>
</CollectionEditSection>

<CollectionEditSection :title="$t('edit.collection.banner.label')">
<p class="text-xs !mb-4 capitalize">
{{ $t('edit.collection.banner.message') }}
</p>

<div
v-if="bannerUrl"
class="flex flex-col gap-2"
>
<img
alt="collection banner"
:src="bannerUrl"
class="h-[167px] border border-border-color object-cover"
>

<p class="text-xs text-k-grey !mt-2 capitalize">
{{ $t('edit.collection.banner.hint') }}
</p>

<FormOverrideFile
@clear="() => {
banner = undefined
bannerUrl = undefined
}"
@select="value => banner = value"
/>
</div>

<div
v-else
>
<DropUpload
v-model="banner"
required
expanded
preview
:label="$t('edit.collection.drop')"
/>

<p class="text-xs text-k-grey !mt-4 capitalize">
{{ $t('edit.collection.banner.hint') }}
</p>
</div>
</CollectionEditSection>

<!-- collection max nfts -->
<NeoField
:label="$t('edit.collection.max.label')"
required
>
<div class="w-full">
<div class="flex justify-between">
<p>{{ $t('mint.unlimited') }}</p>
<NeoSwitch
v-model="unlimited"
position="left"
/>
</div>
<NeoInput
v-if="!unlimited"
v-model="max"
class="mt-3"
type="number"
:placeholder="`${min} is the minimum`"
:min="min"
/>

<div class="text-k-grey text-xs !mt-2">
{{ $t('edit.collection.max.hint') }}
</div>
</div>
</NeoField>
</form>

<div class="flex flex-col !mt-6">
<NeoButton
variant="primary"
size="large"
:disabled="disabled"
no-shadow
:label="$t('edit.collection.saveChanges')"
@click="editCollection"
/>
</div>
</ModalBody>
</NeoModal>
</template>

<script setup lang="ts">
import { NeoButton, NeoField, NeoInput, NeoModal, NeoSwitch } from '@kodadot1/brick'
import ModalBody from '@/components/shared/modals/ModalBody.vue'
import type { UpdateCollection } from '@/composables/transaction/types'

export type CollectionEditMetadata = {
name: string
description: string
image: string
imageType: string
banner?: string
max: number | null
}

const emit = defineEmits(['submit'])
const props = defineProps<{
modelValue: boolean
collection: CollectionEditMetadata
min?: number
}>()

const isModalActive = useVModel(props, 'modelValue')

const image = ref<File>()
const banner = ref<File>()
const imageUrl = ref<string>()
const bannerUrl = ref<string>()
const unlimited = ref(true)

const min = computed(() => props.min || 1)
const max = ref<number | null>(null)

const disabled = computed(() => {
const hasImage = imageUrl.value

const hasImagechanged = (!imageUrl.value && Boolean(props.collection?.image)) || Boolean(image.value)
const hasBannerChanged = (!bannerUrl.value && Boolean(props.collection?.banner)) || Boolean(banner.value)
const hasMaxChanged = max.value !== props.collection?.max

return !hasImage || (!hasImagechanged && !hasBannerChanged && !hasMaxChanged)
})

const editCollection = async () => {
emit('submit', {
name: props.collection.name,
description: props.collection.description,
image: image.value || props.collection.image,
imageType: props.collection.imageType,
banner: bannerUrl.value ? banner.value || props.collection.banner : undefined,
max: max.value,
} as UpdateCollection)
}

watch(isModalActive, (value) => {
if (value && props.collection) {
imageUrl.value = sanitizeIpfsUrl(props.collection.image)
bannerUrl.value = props.collection.banner && sanitizeIpfsUrl(props.collection.banner)
image.value = undefined
banner.value = undefined
unlimited.value = !props.collection.max
max.value = props.collection.max
}
})

watch([banner, unlimited], ([banner, unlimited]) => {
if (banner) {
bannerUrl.value = URL.createObjectURL(banner)
}

max.value = unlimited ? null : max.value || props.collection.max
})
</script>
Loading
Loading