-
-
Notifications
You must be signed in to change notification settings - Fork 625
Expand file tree
/
Copy pathAddonDetails.vue
More file actions
137 lines (123 loc) · 4.74 KB
/
AddonDetails.vue
File metadata and controls
137 lines (123 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<template>
<div>
<ui-header :title="addon.name" icon="addons">
<ui-button :text="__('Back')" icon="arrow-left" @click="$emit('close')" />
<ui-button
variant="primary"
:href="addon.url"
target="_blank"
icon="external-link"
:text="__('View on Marketplace')"
/>
</ui-header>
<div class="flex flex-col-reverse gap-6 space-y-6 xl:grid xl:grid-cols-3 xl:space-y-0">
<div class="lg:col-span-2">
<div class="card prose max-w-full p-6" v-html="description" />
</div>
<div class="flex flex-col space-y-6 xl:col-span-1">
<div class="card flex flex-col space-y-6 p-6">
<div class="flex-1 text-lg">
<div class="little-heading mb-2 p-0 text-gray-700" v-text="__('Seller')" />
<a :href="addon.seller.website" target="_blank" class="relative flex items-center">
<img
:src="addon.seller.avatar"
:alt="addon.seller.name"
class="w-6 rounded-full ltr:mr-2 rtl:ml-2"
/>
<span class="font-bold">{{ addon.seller.name }}</span>
</a>
</div>
<div class="flex-1 text-lg">
<div class="little-heading mb-2 p-0 text-gray-700" v-text="__('Price')" />
<div class="font-bold" v-text="priceRange" />
</div>
<div class="flex-1 text-lg" v-if="downloads">
<div class="little-heading mb-2 p-0 text-gray-700" v-text="__('Downloads')" />
<div class="font-bold">{{ downloads }}</div>
</div>
</div>
<div class="card p-6">
<div class="prose">
<template v-if="addon.installed">
<p class="leading-snug" v-text="`${__('messages.addon_uninstall_command')}:`" />
<code-block class="text-xs" copyable :text="`composer remove ${package}`" />
</template>
<template v-else>
<p v-text="`${__('messages.addon_install_command')}:`" />
<code-block copyable :text="installCommand" />
</template>
<p v-html="link"></p>
</div>
</div>
<addon-editions v-if="addon.editions.length" :addon="addon" />
</div>
</div>
</div>
</template>
<script>
import AddonEditions from './addons/Editions.vue';
export default {
components: {
AddonEditions,
},
emits: ['close'],
props: ['addon'],
data() {
return {
waitingForRefresh: false,
modalOpen: false,
downloads: null,
};
},
computed: {
package() {
return this.addon.package;
},
description() {
return this.addon.description;
},
priceRange() {
let [low, high] = this.addon.price_range;
low = low ? `$${low}` : __('Free');
high = high ? `$${high}` : __('Free');
return low == high ? low : `${low} - ${high}`;
},
link() {
return (
__('Learn more about :link', {
link: `<a href="https://statamic.dev/addons" target="_blank">${__('Addons')}</a>`,
}) + '.'
);
},
installCommand() {
switch (this.package) {
case 'statamic/collaboration':
return 'php please install:collaboration';
case 'statamic/eloquent-driver':
return 'php please install:eloquent-driver';
case 'statamic/ssg':
return 'php please install:ssg';
default:
return `composer require ${this.package}`;
}
},
},
created() {
this.$events.$on('addon-refreshed', this.addonRefreshed);
this.getDownloadCount();
},
unmounted() {
this.$events.$off('addon-refreshed', this.addonRefreshed);
},
methods: {
addonRefreshed() {
this.waitingForRefresh = false;
},
getDownloadCount() {
this.$axios.get(`https://packagist.org/packages/${this.addon.package}.json`).then((response) => {
this.downloads = response.data.package.downloads.total;
});
},
},
};
</script>