PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.2
JetFormBuilder — Dynamic Blocks Form Builder v3.1.2
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / assets / src / admin / pages / jfb-addons / components / AddonItem.vue
jetformbuilder / assets / src / admin / pages / jfb-addons / components Last commit date
AddonItem.vue 2 years ago
AddonItem.vue
459 lines
1 <template>
2 <div
3 class="jfb-addons__item"
4 :class="{
5 'activated': addonData.isActivated,
6 'update-avaliable': updateAvaliable,
7 }"
8 >
9 <div
10 class="jfb-addons__item-inner"
11 :class="{ 'proccesing-state': proccesingState }"
12 >
13 <div class="jfb-addons__item-thumb">
14 <div class="pro-badge" v-if="!addonData.isInstalled">
15 <svg width="40" height="20" viewBox="0 0 40 20" fill="none" xmlns="http://www.w3.org/2000/svg">>
16 <rect width="40" height="20" rx="4" fill="#EE7B16"/>
17 <path
18 d="M10.625 10.8301V14H9.14258V5.46875H12.4062C13.3594 5.46875 14.1152 5.7168 14.6738 6.21289C15.2363 6.70898 15.5176 7.36523 15.5176 8.18164C15.5176 9.01758 15.2422 9.66797 14.6914 10.1328C14.1445 10.5977 13.377 10.8301 12.3887 10.8301H10.625ZM10.625 9.64062H12.4062C12.9336 9.64062 13.3359 9.51758 13.6133 9.27148C13.8906 9.02148 14.0293 8.66211 14.0293 8.19336C14.0293 7.73242 13.8887 7.36523 13.6074 7.0918C13.3262 6.81445 12.9395 6.67188 12.4473 6.66406H10.625V9.64062ZM19.9531 10.7129H18.3008V14H16.8184V5.46875H19.8184C20.8027 5.46875 21.5625 5.68945 22.0977 6.13086C22.6328 6.57227 22.9004 7.21094 22.9004 8.04688C22.9004 8.61719 22.7617 9.0957 22.4844 9.48242C22.2109 9.86523 21.8281 10.1602 21.3359 10.3672L23.252 13.9238V14H21.6641L19.9531 10.7129ZM18.3008 9.52344H19.8242C20.3242 9.52344 20.7148 9.39844 20.9961 9.14844C21.2773 8.89453 21.418 8.54883 21.418 8.11133C21.418 7.6543 21.2871 7.30078 21.0254 7.05078C20.7676 6.80078 20.3809 6.67188 19.8652 6.66406H18.3008V9.52344ZM31.1152 9.95703C31.1152 10.793 30.9707 11.5273 30.6816 12.1602C30.3926 12.7891 29.9785 13.2734 29.4395 13.6133C28.9043 13.9492 28.2871 14.1172 27.5879 14.1172C26.8965 14.1172 26.2793 13.9492 25.7363 13.6133C25.1973 13.2734 24.7793 12.791 24.4824 12.166C24.1895 11.541 24.041 10.8203 24.0371 10.0039V9.52344C24.0371 8.69141 24.1836 7.95703 24.4766 7.32031C24.7734 6.68359 25.1895 6.19727 25.7246 5.86133C26.2637 5.52148 26.8809 5.35156 27.5762 5.35156C28.2715 5.35156 28.8867 5.51953 29.4219 5.85547C29.9609 6.1875 30.377 6.66797 30.6699 7.29688C30.9629 7.92188 31.1113 8.65039 31.1152 9.48242V9.95703ZM29.6328 9.51172C29.6328 8.56641 29.4531 7.8418 29.0938 7.33789C28.7383 6.83398 28.2324 6.58203 27.5762 6.58203C26.9355 6.58203 26.4336 6.83398 26.0703 7.33789C25.7109 7.83789 25.5273 8.54688 25.5195 9.46484V9.95703C25.5195 10.8945 25.7012 11.6191 26.0645 12.1309C26.4316 12.6426 26.9395 12.8984 27.5879 12.8984C28.2441 12.8984 28.748 12.6484 29.0996 12.1484C29.4551 11.6484 29.6328 10.918 29.6328 9.95703V9.51172Z"
19 fill="white"/>
20 </svg>
21 </div>
22 <img :src="addonData.thumb" alt="">
23 </div>
24 <div class="jfb-addons__item-info">
25 <div class="jfb-addons__item-name">
26 <span class="label">{{ addonData.name }}</span>
27 <span class="version">{{ addonData.currentVersion }}</span>
28 </div>
29 <div
30 class="jfb-addons__item-update"
31 v-if="$parent.isLicenseActivated"
32 >
33 <div v-if="!updateAvaliable">Your plugin is up to date</div>
34 <div v-if="updateAvaliable">
35 Version <span class="latest-version">{{ addonData.version }}</span> available
36 <cx-vui-button
37 button-style="link-accent"
38 size="link"
39 :loading="updatePluginProcessed"
40 @click="updatePlugin"
41 v-if="!activateLicenceActionAvaliable && isLicenseMode"
42 >
43 <span slot="label">
44 <span>Update Now</span>
45 </span>
46 </cx-vui-button>
47 </div>
48 </div>
49 <div
50 class="jfb-addons__item-license"
51 v-if="activateLicenceActionAvaliable"
52 >
53 <span>License not activated</span>
54 <cx-vui-button
55 button-style="link-accent"
56 size="link"
57 @click="activateLicense"
58 >
59 <span slot="label">
60 <span>Activate Now</span>
61 </span>
62 </cx-vui-button>
63 </div>
64 <div
65 class="jfb-addons__item-desc"
66 >
67 <span v-html="addonData.desc"></span>
68 <a :href="learnMoreUrl" target="_blank">Learn More</a>
69 </div>
70 <div class="jfb-addons__item-actions">
71
72 <cx-vui-button
73 button-style="link-accent"
74 size="link"
75 :loading="actionPluginProcessed"
76 v-if="installActionAvaliable"
77 @click="installPlugin"
78 >
79 <span slot="label">
80 <span>Install Addon</span>
81 </span>
82 </cx-vui-button>
83 <cx-vui-button
84 button-style="link-accent"
85 size="link"
86 :loading="actionPluginProcessed"
87 v-if="activateActionAvaliable"
88 @click="activatePlugin"
89 >
90 <span slot="label">
91 <span>Activate Addon</span>
92 </span>
93 </cx-vui-button>
94 <cx-vui-button
95 button-style="link-error"
96 size="link"
97 :loading="actionPluginProcessed"
98 v-if="deactivateActionAvaliable"
99 @click="deactivatePlugin"
100 >
101 <span slot="label">
102 <span>Deactivate Addon</span>
103 </span>
104 </cx-vui-button>
105 </div>
106 </div>
107 </div>
108
109 </div>
110 </template>
111
112 <script>
113
114 export default {
115 name: 'addon-item',
116 props: {
117 addonData: Object,
118 },
119 data() {
120 return {
121 actionPlugin: false,
122 actionPluginRequest: null,
123 actionPluginProcessed: false,
124 updatePluginProcessed: false,
125 };
126 },
127 computed: {
128 classList: function () {
129 return [
130 'jfb-addons__item',
131 this.updateAvaliable ? 'update-avaliable' : false,
132 this.activateAvaliable ? 'activate-avaliable' : false,
133 ];
134 },
135
136 learnMoreAvaliable() {
137 return (
138 !this.$parent.isLicenseActivated
139 ) ? true : false;
140 },
141
142 activateLicenceActionAvaliable() {
143 return (
144 !this.$parent.isLicenseActivated && this.$parent.isLicenseMode
145 ) ? true : false;
146 },
147
148 installActionAvaliable() {
149 return (
150 !this.addonData[ 'isInstalled' ] && this.$parent.isLicenseActivated
151 ) ? true : false;
152 },
153
154 activateActionAvaliable() {
155 return (
156 this.addonData[ 'isInstalled' ] && !this.addonData[ 'isActivated' ]
157 ) ? true : false;
158 },
159
160 deactivateActionAvaliable() {
161 return (
162 this.addonData[ 'isInstalled' ] && this.addonData[ 'isActivated' ]
163 ) ? true : false;
164 },
165
166 updateAvaliable() {
167 return (
168 this.addonData[ 'updateAvaliable' ]
169 ) ? true : false;
170 },
171
172 isLicenseMode() {
173 return this.$parent.isLicenseMode;
174 },
175
176 proccesingState() {
177 return this.actionPluginProcessed || this.updatePluginProcessed;
178 },
179
180 learnMoreUrl() {
181 const license = this.$parent.isLicenseActivated ? 'jetformbuilder-license' : 'license-not-activated';
182
183 let demoUrl = this.addonData.demo,
184 utmParams = this.$parent.getUtmParamsString( {
185 utm_source: `jetformbuilder-dashboard/addons`,
186 utm_medium: `${ license }/${ this.$parent.themeInfo.authorSlug }`,
187 utm_campaign: 'addon-learn-more',
188 } );
189
190 return `${ demoUrl }?${ utmParams }`;
191 },
192
193 },
194 methods: {
195
196 activateLicense() {
197 window.jfbEventBus.$emit( 'showLicensePopup' );
198 },
199
200 installPlugin() {
201 this.actionPlugin = 'install';
202 this.pluginAction();
203 },
204
205 deactivatePlugin() {
206 this.actionPlugin = 'deactivate';
207 this.pluginAction();
208 },
209
210 activatePlugin() {
211 this.actionPlugin = 'activate';
212 this.pluginAction();
213 },
214
215 updatePlugin() {
216
217 if ( this.updateAvaliable ) {
218 this.actionPlugin = 'update';
219 this.pluginAction();
220 }
221 },
222
223 pluginAction: function () {
224 let self = this;
225
226 self.actionPluginRequest = jQuery.ajax( {
227 type: 'POST',
228 url: window.JetFBPageConfig.ajaxUrl,
229 dataType: 'json',
230 data: {
231 action: `jfb_addon_${ self.actionPlugin }_action`,
232 data: {
233 plugin: self.addonData[ 'slug' ],
234 },
235 },
236 beforeSend: function ( jqXHR, ajaxSettings ) {
237
238 if ( null !== self.actionPluginRequest ) {
239 self.actionPluginRequest.abort();
240 }
241
242 switch ( self.actionPlugin ) {
243 case 'install':
244 case 'activate':
245 case 'deactivate':
246 self.actionPluginProcessed = true;
247 break;
248 case 'update':
249 self.updatePluginProcessed = true;
250 break;
251 }
252 },
253 success: function ( responce, textStatus, jqXHR ) {
254 if ( responce.success ) {
255 self.$CXNotice.add( {
256 message: responce.message,
257 type: 'success',
258 duration: 4000,
259 } );
260
261 window.jfbEventBus.$emit( 'updateAddonData', {
262 slug: self.addonData[ 'slug' ],
263 addonData: responce.data,
264 action: self.actionPlugin,
265 } );
266
267 }
268 else {
269 self.$CXNotice.add( {
270 message: responce.message,
271 type: 'error',
272 duration: 4000,
273 } );
274 }
275 },
276 error: function ( jqXHR, textStatus, errorThrown ) {
277 self.$CXNotice.add( {
278 message: errorThrown,
279 type: 'error',
280 duration: 4000,
281 } );
282 },
283 complete: () => this.onEndRequest(),
284 } );
285 },
286 onEndRequest() {
287 switch ( this.actionPlugin ) {
288 case 'install':
289 case 'activate':
290 case 'deactivate':
291 this.actionPluginProcessed = false;
292 break;
293 case 'update':
294 this.updatePluginProcessed = false;
295 break;
296 }
297 },
298 },
299 };
300 </script>
301
302 <style lang="scss">
303
304 .jfb-addons {
305 margin-bottom: 50px;
306
307 &:last-child {
308 margin-bottom: 0;
309 }
310
311 a {
312 color: #007cba;
313 }
314
315 &__header {
316 margin-bottom: 20px;
317 }
318
319 &__list {
320 display: grid;
321 grid-template-columns: repeat(4, 1fr);
322 gap: 40px;
323
324 @media (max-width: 1140px) {
325 grid-template-columns: repeat(2, 1fr);
326 }
327 }
328
329 &__item {
330 transition: box-shadow .3s ease-out;
331 border-radius: 10px;
332
333 &:hover {
334 box-shadow: 0px 4px 28px rgba(15, 23, 42, 0.1);
335 }
336
337 &.activated {
338 .jfb-addons__item-info {
339 background-color: white;
340 }
341 }
342
343 &.update-avaliable {
344 .jfb-addons__item-name {
345 .version {
346 background-color: #D6336C;
347 }
348 }
349
350 .jfb-addons__item-update {
351 .latest-version {
352 color: white;
353 background-color: #46B450;
354 padding: 2px 8px;
355 border-radius: 4px;
356 }
357 }
358 }
359 }
360
361 &__item-inner {
362 display: flex;
363 flex-direction: column;
364 align-items: stretch;
365 height: 100%;
366 }
367
368 &__item-thumb {
369 border-radius: 10px 10px 0 0;
370 line-height: 0;
371 overflow: hidden;
372 position: relative;
373
374 .pro-badge {
375 position: absolute;
376 top: 12px;
377 left: 12px;
378 }
379
380 img {
381 width: 100%;
382 height: auto;
383 }
384 }
385
386 &__item-info {
387 display: flex;
388 flex-direction: column;
389 align-items: stretch;
390 flex: 1 1 auto;
391 padding: 20px;
392 border-radius: 0 0 10px 10px;
393 border-width: 0 1px 1px 1px;
394 border-color: #DCDCDD;
395 border-style: solid;
396 background-color: white;
397 }
398
399 &__item-name {
400 display: flex;
401 justify-content: space-between;
402 align-items: flex-start;
403 margin-bottom: 10px;
404
405 .label {
406 font-size: 20px;
407 font-weight: 700;
408 line-height: 1.25;
409 }
410
411 .version {
412 padding: 1px 8px;
413 border-radius: 4px;
414 color: white;
415 background-color: #46B450;
416 margin-left: 10px;
417 }
418 }
419
420 &__item-update {
421 color: #7b7e81;
422 margin-bottom: 10px;
423 }
424
425 &__item-license {
426 margin-bottom: 10px;
427 color: #7b7e81;
428
429 .cx-vui-button {
430 margin-left: 3px;
431 }
432 }
433
434 &__item-desc {
435 flex: 1 1 auto;
436
437 a {
438 text-decoration: none;
439 }
440 }
441
442 &__item-actions {
443 display: flex;
444 justify-content: flex-start;
445 align-items: center;
446 flex-wrap: wrap;
447 margin-top: 20px;
448
449 &:empty {
450 display: none;
451 }
452
453 .cx-vui-button {
454 margin-right: 20px;
455 }
456 }
457 }
458
459 </style>