PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.3
JetFormBuilder — Dynamic Blocks Form Builder v3.1.3
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
460 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 nonce: window.JetFBPageConfig.nonce,
233 data: {
234 plugin: self.addonData[ 'slug' ],
235 },
236 },
237 beforeSend: function ( jqXHR, ajaxSettings ) {
238
239 if ( null !== self.actionPluginRequest ) {
240 self.actionPluginRequest.abort();
241 }
242
243 switch ( self.actionPlugin ) {
244 case 'install':
245 case 'activate':
246 case 'deactivate':
247 self.actionPluginProcessed = true;
248 break;
249 case 'update':
250 self.updatePluginProcessed = true;
251 break;
252 }
253 },
254 success: function ( responce, textStatus, jqXHR ) {
255 if ( responce.success ) {
256 self.$CXNotice.add( {
257 message: responce.message,
258 type: 'success',
259 duration: 4000,
260 } );
261
262 window.jfbEventBus.$emit( 'updateAddonData', {
263 slug: self.addonData[ 'slug' ],
264 addonData: responce.data,
265 action: self.actionPlugin,
266 } );
267
268 }
269 else {
270 self.$CXNotice.add( {
271 message: responce.message,
272 type: 'error',
273 duration: 4000,
274 } );
275 }
276 },
277 error: function ( jqXHR, textStatus, errorThrown ) {
278 self.$CXNotice.add( {
279 message: errorThrown,
280 type: 'error',
281 duration: 4000,
282 } );
283 },
284 complete: () => this.onEndRequest(),
285 } );
286 },
287 onEndRequest() {
288 switch ( this.actionPlugin ) {
289 case 'install':
290 case 'activate':
291 case 'deactivate':
292 this.actionPluginProcessed = false;
293 break;
294 case 'update':
295 this.updatePluginProcessed = false;
296 break;
297 }
298 },
299 },
300 };
301 </script>
302
303 <style lang="scss">
304
305 .jfb-addons {
306 margin-bottom: 50px;
307
308 &:last-child {
309 margin-bottom: 0;
310 }
311
312 a {
313 color: #007cba;
314 }
315
316 &__header {
317 margin-bottom: 20px;
318 }
319
320 &__list {
321 display: grid;
322 grid-template-columns: repeat(4, 1fr);
323 gap: 40px;
324
325 @media (max-width: 1140px) {
326 grid-template-columns: repeat(2, 1fr);
327 }
328 }
329
330 &__item {
331 transition: box-shadow .3s ease-out;
332 border-radius: 10px;
333
334 &:hover {
335 box-shadow: 0px 4px 28px rgba(15, 23, 42, 0.1);
336 }
337
338 &.activated {
339 .jfb-addons__item-info {
340 background-color: white;
341 }
342 }
343
344 &.update-avaliable {
345 .jfb-addons__item-name {
346 .version {
347 background-color: #D6336C;
348 }
349 }
350
351 .jfb-addons__item-update {
352 .latest-version {
353 color: white;
354 background-color: #46B450;
355 padding: 2px 8px;
356 border-radius: 4px;
357 }
358 }
359 }
360 }
361
362 &__item-inner {
363 display: flex;
364 flex-direction: column;
365 align-items: stretch;
366 height: 100%;
367 }
368
369 &__item-thumb {
370 border-radius: 10px 10px 0 0;
371 line-height: 0;
372 overflow: hidden;
373 position: relative;
374
375 .pro-badge {
376 position: absolute;
377 top: 12px;
378 left: 12px;
379 }
380
381 img {
382 width: 100%;
383 height: auto;
384 }
385 }
386
387 &__item-info {
388 display: flex;
389 flex-direction: column;
390 align-items: stretch;
391 flex: 1 1 auto;
392 padding: 20px;
393 border-radius: 0 0 10px 10px;
394 border-width: 0 1px 1px 1px;
395 border-color: #DCDCDD;
396 border-style: solid;
397 background-color: white;
398 }
399
400 &__item-name {
401 display: flex;
402 justify-content: space-between;
403 align-items: flex-start;
404 margin-bottom: 10px;
405
406 .label {
407 font-size: 20px;
408 font-weight: 700;
409 line-height: 1.25;
410 }
411
412 .version {
413 padding: 1px 8px;
414 border-radius: 4px;
415 color: white;
416 background-color: #46B450;
417 margin-left: 10px;
418 }
419 }
420
421 &__item-update {
422 color: #7b7e81;
423 margin-bottom: 10px;
424 }
425
426 &__item-license {
427 margin-bottom: 10px;
428 color: #7b7e81;
429
430 .cx-vui-button {
431 margin-left: 3px;
432 }
433 }
434
435 &__item-desc {
436 flex: 1 1 auto;
437
438 a {
439 text-decoration: none;
440 }
441 }
442
443 &__item-actions {
444 display: flex;
445 justify-content: flex-start;
446 align-items: center;
447 flex-wrap: wrap;
448 margin-top: 20px;
449
450 &:empty {
451 display: none;
452 }
453
454 .cx-vui-button {
455 margin-right: 20px;
456 }
457 }
458 }
459
460 </style>