Skip to content

Commit

Permalink
Merge pull request #3373 from zhengow/main
Browse files Browse the repository at this point in the history
feat: Keep top border only on action buttons for on-chain actions
  • Loading branch information
petersopko committed Jul 17, 2022
2 parents 03cc54c + 7e382e6 commit 935d3de
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 78 deletions.
16 changes: 1 addition & 15 deletions components/bsx/Gallery/Item/AvailableActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<script lang="ts">
import { NFTAction } from '@/components/unique/NftUtils'
import { createTokenId } from '@/components/unique/utils'
import { isSameAccount } from '@/utils/account'
import { bsxParamResolver, getApiCall } from '@/utils/gallery/abstractCalls'
import AuthMixin from '@/utils/mixins/authMixin'
import KeyboardEventsMixin from '@/utils/mixins/keyboardEventsMixin'
Expand Down Expand Up @@ -69,6 +68,7 @@ export default class AvailableActions extends mixins(
@Prop(String) public nftId!: string
@Prop(String) public collectionId!: string
@Prop(Boolean) public isMakeOffersAllowed!: boolean
@Prop(Boolean) public isOwner!: boolean
@Prop({ type: Array, default: () => [] }) public ipfsHashes!: string[]
private selectedAction: ShoppingActions | '' = ''
Expand All @@ -94,20 +94,6 @@ export default class AvailableActions extends mixins(
return false
}
get isOwner(): boolean {
this.$consola.log(
'{ currentOwnerId, accountId }',
this.currentOwnerId,
this.accountId
)
return Boolean(
this.currentOwnerId &&
this.accountId &&
isSameAccount(this.currentOwnerId, this.accountId)
)
}
get showSubmit() {
return this.selectedAction && (!this.showMeta || this.metaValid)
}
Expand Down
10 changes: 8 additions & 2 deletions components/bsx/Gallery/Item/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</p>
</div>
<div class="column">
<Sharing onlyCopyLink />
<Sharing :enableDownload="isOwner" />
</div>
</div>
</b-message>
Expand Down Expand Up @@ -82,6 +82,7 @@
<AvailableActions
ref="actions"
:account-id="accountId"
:is-owner="isOwner"
:current-owner-id="nft.currentOwner"
:price="nft.price"
:nftId="id"
Expand All @@ -102,7 +103,7 @@
<span>{{ $t('general.balance') }}: </span>
<Money :value="balance" inline />
</p>
<Sharing class="mb-4" />
<Sharing :enableDownload="isOwner" class="mb-4" />
</div>
</div>
</template>
Expand Down Expand Up @@ -151,6 +152,7 @@ import resolveQueryPath from '~/utils/queryPathResolver'
import { getMetadata, getOwner, getPrice, hasAllPallets } from './utils'
import { isEmpty } from '@kodadot1/minimark'
import { royaltyOf } from '@/utils/royalty'
import { isOwner } from '~/utils/account'
import { generateNftImage } from '~/utils/seoImageGenerator'
import { formatBsxBalanceEmptyOnZero } from '~/utils/format/balance'
Expand Down Expand Up @@ -217,6 +219,10 @@ export default class GalleryItem extends mixins(
})
}
get isOwner(): boolean {
return isOwner(this.nft.currentOwner, this.accountId)
}
get balance(): string {
return this.$store.getters.getAuthBalance
}
Expand Down
9 changes: 7 additions & 2 deletions components/moonsama/Gallery/Item/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</p>
</div>
<div class="column">
<Sharing onlyCopyLink />
<Sharing :enableDownload="isOwner" />
</div>
</div>
</b-message>
Expand Down Expand Up @@ -78,7 +78,7 @@
<Auth class="mt-4" evm />
</p>
</div>
<Sharing class="mb-4" />
<Sharing :enableDownload="isOwner" class="mb-4" />
</div>
</div>
</template>
Expand Down Expand Up @@ -120,6 +120,7 @@ import PrefixMixin from '~/utils/mixins/prefixMixin'
import resolveQueryPath from '~/utils/queryPathResolver'
import { isEmpty } from '@kodadot1/minimark'
import { royaltyOf } from '@/utils/royalty'
import { isOwner } from '~/utils/account'
@Component<GalleryItem>({
components: {
Expand Down Expand Up @@ -200,6 +201,10 @@ export default class GalleryItem extends mixins(
this.fetchMetadata()
}
get isOwner(): boolean {
return isOwner(this.nft.currentOwner, this.accountId)
}
onImageError(e: any) {
this.$consola.warn('Image error', e)
}
Expand Down
31 changes: 5 additions & 26 deletions components/rmrk/Gallery/AvailableActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ShareNetwork
v-if="identity && identity.twitter && this.isOwner"
tag="button"
class="button is-info is-dark is-outlined is-fullwidth twitter-btn"
class="button is-info is-dark is-outlined is-fullwidth twitter-btn only-border-top"
network="twitter"
:hashtags="'KodaDot'"
:url="realworldFullPath"
Expand All @@ -18,6 +18,7 @@
v-for="action in actions"
:key="action"
:type="iconType(action)[0]"
class="only-border-top"
outlined
@click="handleAction(action)"
expanded>
Expand All @@ -27,6 +28,7 @@
<template v-else-if="isForSale">
<b-tooltip :active="buyDisabled" :label="$t('tooltip.buyDisabled')">
<b-button
class="only-border-top"
:type="iconType(ShoppingActions.BUY)[0]"
:disabled="buyDisabled || !isAvailableToBuy"
style="border-width: 2px"
Expand Down Expand Up @@ -78,7 +80,6 @@ import { get } from 'idb-keyval'
import { identityStore } from '@/utils/idbStore'
import { emptyObject } from '~/utils/empty'
import { isAddress } from '@polkadot/util-crypto'
import { downloadImage } from '@/utils/download'
import { createInteraction, JustInteraction } from '@kodadot1/minimark'
import {
ShoppingActions,
Expand All @@ -97,7 +98,6 @@ const iconResolver: Record<string, DescriptionTuple> = {
[ShoppingActions.CONSUME]: ['is-danger'],
[ShoppingActions.LIST]: ['is-light'],
[ShoppingActions.BUY]: ['is-success is-dark'],
[ShoppingActions.DOWNLOAD]: ['is-warning'],
}
const components = {
Expand All @@ -118,6 +118,7 @@ export default class AvailableActions extends mixins(
@Prop() public originialOwner!: string
@Prop() public price!: string
@Prop() public nftId!: string
@Prop(Boolean) public isOwner!: boolean
@Prop({ default: () => [] }) public ipfsHashes!: string[]
@Prop({ default: false }) public buyDisabled!: boolean
private selectedAction: ShoppingActions | '' = ''
Expand Down Expand Up @@ -208,11 +209,6 @@ export default class AvailableActions extends mixins(
case ShoppingActions.SEND:
this.addressInput?.focusInput()
break
case ShoppingActions.DOWNLOAD: {
const { image, name } = this.currentGalleryItemImage
image && downloadImage(image, name)
break
}
default:
break
}
Expand All @@ -238,20 +234,6 @@ export default class AvailableActions extends mixins(
return this.selectedAction === ''
}
get isOwner(): boolean {
this.$consola.log(
'{ currentOwnerId, accountId }',
this.currentOwnerId,
this.accountId
)
return Boolean(
this.currentOwnerId &&
this.accountId &&
this.currentOwnerId === this.accountId
)
}
get isAvailableToBuy(): boolean {
const { price, accountId } = this
return Boolean(accountId && Number(price) > 0)
Expand Down Expand Up @@ -291,10 +273,6 @@ export default class AvailableActions extends mixins(
return `${window.location.origin}${this.$route.fullPath}`
}
get currentGalleryItemImage(): { image: string; name: string } {
return this.$store.getters['history/getCurrentlyViewedItem'] || {}
}
@Watch('originialOwner', { immediate: true })
async watchOwnerAddress(newAddress: Address, oldAddress: Address) {
if (shouldUpdate(newAddress, oldAddress)) {
Expand Down Expand Up @@ -419,6 +397,7 @@ export default class AvailableActions extends mixins(
}
</script>
<style scoped lang="scss">
@import '@/styles/border';
.joy {
font-size: 16px;
margin-top: 2px;
Expand Down
10 changes: 8 additions & 2 deletions components/rmrk/Gallery/GalleryItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</p>
</div>
<div class="column">
<Sharing onlyCopyLink />
<Sharing :enableDownload="isOwner" />
</div>
</div>
</b-message>
Expand Down Expand Up @@ -86,6 +86,7 @@
<AvailableActions
ref="actions"
:current-owner-id="nft.currentOwner"
:is-owner="isOwner"
:price="nft.price"
:originialOwner="nft.issuer"
:nft-id="nft.id"
Expand All @@ -105,7 +106,7 @@
</p>
</div>

<Sharing class="mb-4" />
<Sharing :enableDownload="isOwner" class="mb-4" />
</div>
</div>
</div>
Expand Down Expand Up @@ -160,6 +161,7 @@ import Orientation from '@/utils/directives/DeviceOrientation'
import PrefixMixin from '~/utils/mixins/prefixMixin'
import { Debounce } from 'vue-debounce-decorator'
import AvailableActions from './AvailableActions.vue'
import { isOwner } from '~/utils/account'
@Component<GalleryItem>({
name: 'GalleryItem',
Expand Down Expand Up @@ -298,6 +300,10 @@ export default class GalleryItem extends mixins(PrefixMixin) {
this.priceChartData = data
}
get isOwner(): boolean {
return isOwner(this.nft.currentOwner, this.accountId)
}
@Debounce(500)
private async updateEventList() {
const { data } = await this.$apollo.query<{ nft }>({
Expand Down
5 changes: 5 additions & 0 deletions components/rmrk/Gallery/Item/ActionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"
outlined
expanded
class="only-border-top"
@click="handleActionSelect(action)">
{{ actionLabel(action) }}
</b-button>
Expand Down Expand Up @@ -51,3 +52,7 @@ export default class ActionList extends Vue {
}
}
</script>

<style scoped lang="scss">
@import '@/styles/border';
</style>
19 changes: 18 additions & 1 deletion components/rmrk/Gallery/Item/Sharing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
<b-icon size="is-small" pack="fas" icon="link" />
</b-button>

<b-button
v-if="enableDownload"
@click="downloadImage()"
type="is-primary is-bordered-light share-button">
<b-icon size="is-small" pack="fas" icon="download" />
</b-button>

<b-tooltip
position="is-left"
class="share__tooltip"
Expand Down Expand Up @@ -82,6 +89,7 @@
<script lang="ts">
import { Component, Prop, Vue } from 'nuxt-property-decorator'
import { IFrame, emptyIframe } from '../../types'
import { downloadImage } from '~/utils/download'
const components = {
ShowQRModal: () => import('@/components/shared/modals/ShowQRModal.vue'),
Expand All @@ -92,7 +100,7 @@ const components = {
export default class Sharing extends Vue {
@Prop({ default: 'Check out this cool NFT on KodaDot' }) label!: string
@Prop({ default: () => emptyIframe }) iframe!: IFrame
@Prop(Boolean) onlyCopyLink!: boolean
@Prop(Boolean) enableDownload!: boolean
private active = false
Expand Down Expand Up @@ -138,6 +146,10 @@ export default class Sharing extends Vue {
this.$buefy.toast.open(message)
}
get currentGalleryItemImage(): { image: string; name: string } {
return this.$store.getters['history/getCurrentlyViewedItem'] || {}
}
public async shareTooltip(): Promise<void> {
this.openFallbackShareTooltip()
if (navigator.share) {
Expand All @@ -154,6 +166,11 @@ export default class Sharing extends Vue {
}
}
protected downloadImage() {
const { image, name } = this.currentGalleryItemImage
image && downloadImage(image, name)
}
public openFallbackShareTooltip(): void {
// only call this when share api is not available, example on web
if (!navigator.share) {
Expand Down
20 changes: 6 additions & 14 deletions components/unique/Gallery/Item/AvailableActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:type="iconType(action)[0]"
outlined
expanded
class="only-border-top"
@click="handleAction(action)">
{{ action }}
</b-button>
Expand Down Expand Up @@ -78,6 +79,7 @@ export default class AvailableActions extends mixins(RmrkVersionMixin) {
@Prop() public nftId!: string
@Prop(String) public collectionId!: string
@Prop(Boolean) public frozen!: boolean
@Prop(Boolean) public isOwner!: boolean
@Prop({ type: Array, default: () => [] }) public ipfsHashes!: string[]
private selectedAction: NFTAction = NFTAction.NONE
Expand Down Expand Up @@ -132,20 +134,6 @@ export default class AvailableActions extends mixins(RmrkVersionMixin) {
)
}
get isOwner() {
this.$consola.log(
'{ currentOwnerId, accountId }',
this.currentOwnerId,
this.accountId
)
return (
this.currentOwnerId &&
this.accountId &&
this.currentOwnerId === this.accountId
)
}
get isAvailableToBuy() {
const { price, accountId } = this
return accountId && Number(price) > 0
Expand Down Expand Up @@ -311,3 +299,7 @@ export default class AvailableActions extends mixins(RmrkVersionMixin) {
}
}
</script>

<style scoped lang="scss">
@import '@/styles/border';
</style>
Loading

0 comments on commit 935d3de

Please sign in to comment.