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: Item Edit: Limit Name and Image Update #11200

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
30 changes: 17 additions & 13 deletions components/common/EditNftModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
:label="$t('mint.nft.art.label')"
required
>
<FormLogoField
v-model:file="image"
v-model:url="imageUrl"
/>
<NonRecommendFieldNotification :show="imageChanged">
<FormLogoField
v-model:file="image"
v-model:url="imageUrl"
/>
</NonRecommendFieldNotification>
</NeoField>
hassnian marked this conversation as resolved.
Show resolved Hide resolved

<!-- nft name -->
Expand All @@ -28,11 +30,13 @@
required
:error="!name"
>
<NeoInput
v-model="name"
required
:placeholder="$t('mint.nft.name.placeholder')"
/>
<NonRecommendFieldNotification :show="name && nameChanged">
<NeoInput
v-model="name"
required
:placeholder="$t('mint.nft.name.placeholder')"
/>
</NonRecommendFieldNotification>
</NeoField>

<!-- nft description -->
Expand Down Expand Up @@ -91,17 +95,17 @@ const image = ref<File>()
const imageUrl = ref<string>()
const attributes = ref<Attribute[]>([])

const nameChanged = computed(() => props.metadata?.name !== name.value)
const imageChanged = computed(() => Boolean(image.value))

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

const nameChanged = props.metadata?.name !== name.value
const descriptionChanged = props.metadata?.description !== description.value
const imageChanged = Boolean(image.value)
const attributesChanged = JSON.stringify(attributes.value) !== JSON.stringify(props.metadata?.attributes || [])

return !hasImage || !isNameFilled
|| (!nameChanged && !descriptionChanged && !imageChanged && !attributesChanged)
|| (!nameChanged.value && !descriptionChanged && !imageChanged.value && !attributesChanged)
})

const editCollection = async () => {
Expand Down
26 changes: 26 additions & 0 deletions components/common/NonRecommendFieldNotification.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<div class="flex flex-col w-full">
<slot />
<div
v-if="show"
class="flex items-center gap-2 bg-yellow-50 border border-yellow-200 rounded-md p-3 !mt-2"
>
<NeoIcon
icon="warning"
class="text-yellow-500 flex-shrink-0"
size="small"
/>
<p class="text-sm text-yellow-700">
{{ $t('mint.notRecommendedModify') }}
</p>
</div>
</div>
</template>

<script lang="ts" setup>
import { NeoIcon } from '@kodadot1/brick'

defineProps<{
show: boolean
}>()
</script>
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,7 @@
"message": "People will be able to buy your NFT."
}
},
"notRecommendedModify": "Please note that this value is not recommended to be modified as it may lead to misuse and confusion",
Jarsen136 marked this conversation as resolved.
Show resolved Hide resolved
"progress": "In Progress",
"requiredDeposit": "A deposit of <strong>{0}</strong> is required to create a {1}. Please note, this initial deposit is refundable.",
"royalty": {
Expand Down