Änderungen von Dokument Licensed Extensions

Zuletzt geändert von xwikiadmin am 2025/07/14 15:59

Von Version 2.1
bearbeitet von xwikiadmin
am 2023/04/25 10:57
Änderungskommentar: Install extension [com.xwiki.licensing:application-licensing-licensor-ui/1.24.1]
Auf Version 4.1
bearbeitet von xwikiadmin
am 2025/07/14 15:59
Änderungskommentar: Install extension [com.xwiki.licensing:application-licensing-licensor-ui/1.29]

Zusammenfassung

Details

Seiteneigenschaften
Inhalt
... ... @@ -6,11 +6,14 @@
6 6   <fieldset class="header">
7 7   <legend>$services.localization.render('licensor.licenseManager.heading')</legend>
8 8   $services.localization.render('licensor.licenseManager.hint')
9 + <div class="required-by-hint">
10 + $services.icon.renderHTML('warning') : $services.localization.render('licensor.licenseManager.installedAsDependency.hint')
11 + </div
9 9   </fieldset>
10 10   {{/html}}
11 11   #set ($columns = ['name', 'version', 'status', 'support', 'userLimit', 'wiki', 'actions'])
12 12   #set ($columnsProperties = {
13 - 'name': {'filterable': false, 'sortable': false, 'link': 'auto'},
16 + 'name': {'filterable': false, 'sortable': false, 'link': 'auto', 'html': true},
14 14   'version': {'filterable': false, 'sortable': false},
15 15   'status': {'filterable': false, 'sortable': false, 'html': true},
16 16   'support': {'filterable': false, 'sortable': false},
... ... @@ -21,7 +21,7 @@
21 21   #set ($options = {
22 22   'resultPage':'Licenses.Code.LicenseJSON',
23 23   'translationPrefix' : 'licensor.',
24 - 'extraParams': "&showAllPaidExtensions=$!escapetool.url($request.showAllPaidExtensions)"
27 + 'extraParams': "&showTopLevelExtensions=$!escapetool.url($request.showTopLevelExtensions)"
25 25   })
26 26   #livetable('licenseManager' $columns $columnsProperties $options)
27 27   {{html clean="false"}}
... ... @@ -70,5 +70,7 @@
70 70   #displayOwnerDetailsForm
71 71   #displayLicensesLiveTable
72 72   #displayAddLicenseForm
76 + #feedbackForm
77 + #installedAsDependency
73 73  #end
74 74  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -159,7 +159,7 @@
159 159   // xwiki:livetable:displayComplete might be triggered before the code from this jsx is executed. In this case, the
160 160   // livetable is also loaded before, because it is using Prototype.js which is loading before the page loads.
161 161   // Make sure that the livetable is loaded by checking for a row with some data.
162 - if ($('#licenseManager-display td.type').size() > 0) {
162 + if ($('#licenseManager-display td.type').length > 0) {
163 163   updateLivetableButtons();
164 164   }
165 165   $(document).on('xwiki:livetable:displayComplete', updateLivetableButtons);
... ... @@ -208,19 +208,10 @@
208 208   });
209 209   };
210 210  
211 - // Manages the license buttons from the licenses livetable. If a trial is requested, it is automatically generated
212 - // and installed, else the user is redirected to a page to buy a license.
213 - $('#licenseManager').on('click', '.licenseButton', function(e) {
214 - e.preventDefault();
211 + // Trigger Get Trial / Extend trial or Buy license actions.
212 + var triggerLicenseAction = function(buttonData) {
215 215   var ownerDetailsForm = $('#ownerDetails');
216 - if (!validateOwnerDetails(ownerDetailsForm)) {
217 - return;
218 - }
219 - // Update the owner details.
220 - var ownerDetails = ownerDetailsForm.serializeArray();
221 - licensor.updateOwnerDetails(ownerDetails);
222 - // Get the data from the license button.
223 - var buttonData = JSON.parse($(this).attr('data-button'));
214 + let ownerDetails = ownerDetailsForm.serializeArray();
224 224   if (buttonData.licenseType === 'TRIAL') {
225 225   ownerDetails.push.apply(ownerDetails, $.map(buttonData, function(value, name) {
226 226   return {name: name, value: value};
... ... @@ -233,6 +233,35 @@
233 233   ownerDetailsForm.append(extraFields).submit();
234 234   extraFields.remove();
235 235   };
227 + };
228 +
229 + // Manages the license buttons from the licenses livetable. If a trial is requested, it is automatically generated
230 + // and installed, else the user is redirected to a page to buy a license.
231 + $('#licenseManager').on('click', '.licenseButton', function(e) {
232 + e.preventDefault();
233 + var ownerDetailsForm = $('#ownerDetails');
234 + if (!validateOwnerDetails(ownerDetailsForm)) {
235 + return;
236 + }
237 + // Update the owner details.
238 + var ownerDetails = ownerDetailsForm.serializeArray();
239 + licensor.updateOwnerDetails(ownerDetails);
240 + // Get data from the license button.
241 + var buttonData = JSON.parse($(this).attr('data-button'));
242 + // If this extension was installed as dependency, ask for a confirmation before continuing this action, since it
243 + // would be better for the user to get a license for the top level licensed extension.
244 + const requiredByInfo = $($($(this).parents('td.actions')[0]).siblings('td.name')[0]).find('.required-by-info');
245 + if (requiredByInfo.size() > 0) {
246 + const parentExtensionNode = $('#installed-as-dependency').find('.parent-extensions');
247 + parentExtensionNode.empty();
248 + requiredByInfo.data('parent-extensions').split(',').forEach((extension) => {
249 + parentExtensionNode.append("<li>"+ extension.trim() + "</li>");
250 + });
251 + $('#installed-as-dependency').data('buttonData', buttonData);
252 + $('#installed-as-dependency').modal('show');
253 + } else {
254 + triggerLicenseAction(buttonData);
255 + }
236 236   });
237 237  
238 238   // Show a popover on the "Check for Updates" button to let the user know what to do after he pays for the license.
... ... @@ -285,8 +285,51 @@
285 285   });
286 286   });
287 287  
308 + $(document).on('click', '.licenseButton-feedback', function(e) {
309 + // Get the data needed in the form.
310 + const buttonData = JSON.parse($(this).attr('data-button'));
311 + const ownerDetails = {};
312 + $('#ownerDetails').serializeArray().map(x => ownerDetails[x.name] = x.value);
313 + if (typeof MauticSDK !== 'undefined') {
314 + // Make sure no messages or errors remained from the previous submit.
315 + const formName = $('#feedbackFormModal').find('.webmecanikForm form').attr('data-mautic-form');
316 + MauticSDK.getValidator(formName).clearErrors();
317 + MauticSDK.getValidator(formName).setMessage('', 'message');
318 + // Prefill values.
319 + const fieldPrefix = '#mauticform_input_' + formName + '_';
320 + $(fieldPrefix + 'email').val(ownerDetails['email']);
321 + const instanceId = $(fieldPrefix + 'instance_id');
322 + instanceId.val(ownerDetails['instanceId']);
323 + const featureId = $(fieldPrefix + 'name_of_the_app');
324 + featureId.val(buttonData['featureId']);
325 +
326 + // Show the feedback form modal.
327 + $('#feedbackFormModal').modal('show');
328 + } else {
329 + const params = $.param({
330 + 'email': ownerDetails['email'],
331 + 'instanceId': ownerDetails['instanceId'],
332 + 'featureId': buttonData['featureId']
333 + });
334 +
335 + const feedbackURL = buttonData['storeFeedbackURL'] + '?' + params;
336 + window.open(feedbackURL, '_blank').focus();
337 + }
338 + });
339 +
340 + // Continue license action after user confirmation.
341 + $(document).on('click', '#installed-as-dependency .btn-primary', function(e) {
342 + e.preventDefault();
343 + triggerLicenseAction($('#installed-as-dependency').data('buttonData'));
344 + });
345 +
346 + $(document).on('hide.bs.modal', '#installed-as-dependency', function() {
347 + $('#installed-as-dependency').removeData('buttonData');
348 + $('#installed-as-dependency').find('.parent-extensions').empty();
349 + });
350 +
288 288   // Set the documentation links to open in new tab.
289 289   $('#licenseManager-display td.name a').each(function() {
290 - $(this).attr('target', '_blank')
353 + $(this).attr('target', '_blank');
291 291   });
292 292  });
XWiki.StyleSheetExtension[0]
Code
... ... @@ -12,6 +12,19 @@
12 12   left: auto;
13 13  }
14 14  
15 +#licenseManager-display .required-by-info:hover {
16 + color: @gray;
17 +}
18 +
19 +.required-by-hint {
20 + padding-top: 2%;
21 +}
22 +
23 +#installed-as-dependency .parent-extensions li {
24 + padding-top: 1%;
25 + font-weight: bold;
26 +}
27 +
15 15  .licenseButton-paid .action-icon, .licenseButton-extendPaid .action-icon, .isAutoUpgrade {
16 16   color: @brand-success;
17 17  }
... ... @@ -18,3 +18,6 @@
18 18  .licenseButton-trial .action-icon, .licenseButton-extendTrial .action-icon {
19 19   color: @link-color;
20 20  }
34 +.webmecanikForm input[type=text], .webmecanikForm input[type=email] {
35 + width: 100%;
36 +}