Skip to content

Commit 4c7a8e4

Browse files
release: fixes
- Fixed the permissions of the plans
2 parents c6392de + 5a5cecb commit 4c7a8e4

File tree

4 files changed

+36
-19
lines changed

4 files changed

+36
-19
lines changed

classes/Visualizer/Module.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,11 +738,20 @@ public static function can_show_feature( $feature ) {
738738
* Gets the features for the provided license type.
739739
*/
740740
public static final function get_features_for_license( $plan ) {
741+
$is_new_personal = apply_filters( 'visualizer_is_new_personal', false );
741742
switch ( $plan ) {
742743
case 1:
743-
return array( 'import-wp', 'import-wc-report', 'import-file', 'import-url' );
744+
$features = array( 'import-wp', 'import-wc-report', 'import-file', 'import-url' );
745+
if ( ! $is_new_personal ) {
746+
$features[] = 'db-query';
747+
}
748+
return $features;
744749
case 2:
745-
return array( 'db-query', 'schedule-chart', 'chart-permissions', 'import-chart', 'data-filter-configuration', 'frontend-actions' );
750+
$features = array( 'schedule-chart', 'chart-permissions', 'import-chart', 'data-filter-configuration', 'frontend-actions' );
751+
if ( $is_new_personal ) {
752+
$features[] = 'db-query';
753+
}
754+
return $features;
746755
}
747756
}
748757

classes/Visualizer/Module/Sources.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,14 @@ public function addProUpsell( $old, $feature = null ) {
139139
( in_array( $feature, $pro_features, true ) && ! Visualizer_Module::is_pro() )
140140
) {
141141
$msg = sprintf( __( 'Upgrade to %s to activate this feature!', 'visualizer' ), 'PRO' );
142-
if ( in_array( $feature, $biz_features, true ) ) {
143-
$msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Developer' );
142+
$plus_msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Plus' );
143+
if ( in_array( $feature, $biz_features, true ) && Visualizer_Module::is_pro() ) {
144+
$msg = $plus_msg;
144145
}
146+
if ( in_array( $feature, [ 'db-query', 'chart-permissions' ], true ) ) {
147+
$msg = $plus_msg;
148+
}
149+
145150
$return = '<div class="only-pro-content">';
146151
$return .= ' <div class="only-pro-container">';
147152
$return .= ' <div class="only-pro-inner">';

js/frame.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
(function ($) {
1010
$(window).on('load', function(){
11-
// scroll to the selected chart type.
12-
$('#chart-select').scrollIntoView();
11+
let chart_select = $('#chart-select');
12+
if(chart_select.length > 0){
13+
// scroll to the selected chart type.
14+
$('#chart-select')[0].scrollIntoView();
15+
}
1316
});
1417

1518
$(document).ready(function () {
@@ -154,7 +157,7 @@
154157

155158
/**
156159
* Initialize/Update the available chart list based on their supported renderer libraries.
157-
*
160+
*
158161
* @returns {void}
159162
*/
160163
function init_available_chart_list() {
@@ -172,7 +175,7 @@
172175
const rendererTypesMapping = JSON.parse( rendererTypesMappingData );
173176

174177
document.querySelectorAll('input.type-radio').forEach( chartTypeRadio => {
175-
178+
176179
// Init the lib based on the default selected chart type.
177180
if ( chartTypeRadio.checked ) {
178181
const chartType = chartTypeRadio.value;
@@ -201,14 +204,14 @@
201204
}
202205
});
203206
});
204-
207+
205208
// Update the chart list on user interaction.
206209
rendererSelect.addEventListener('change', (event) => {
207210
disable_renderer_select_placeholder();
208211
toggle_renderer_type( event.target.value );
209212
toggle_chart_types_by_render( event.target.value );
210213
});
211-
214+
212215
}
213216

214217
/**
@@ -223,24 +226,24 @@
223226

224227
/**
225228
* Toggle the renderer type class based on the given renderer type.
226-
*
229+
*
227230
* The class is used to style the chart type picker based on the given renderer library.
228-
*
231+
*
229232
* @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to toggle the class.
230233
*/
231234
function toggle_renderer_type( rendererType ) {
232235
const typePicker = document.querySelector('#type-picker');
233236
if ( ! typePicker ) {
234237
return;
235238
}
236-
239+
237240
typePicker.classList.remove('lib-GoogleCharts', 'lib-ChartJS', 'lib-DataTable');
238241
typePicker.classList.add(`lib-${rendererType}`);
239242
}
240243

241244
/**
242245
* Toggle chart types based on the given renderer type.
243-
*
246+
*
244247
* @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to filter the chart types.
245248
*/
246249
function toggle_chart_types_by_render( rendererType ) {
@@ -786,11 +789,11 @@
786789
if( chartTypes ) {
787790
document.querySelector('.push-right[type=submit]')?.addEventListener('click', async function (event) {
788791
if ( typeof window.tiTrk !== 'undefined' ) {
789-
event.preventDefault();
792+
event.preventDefault();
790793
try {
791794
const formData = new FormData(document.querySelector('#viz-types-form'));
792795
const savedData = Object.fromEntries(formData);
793-
796+
794797
tiTrk?.with('visualizer')?.add({
795798
feature: 'chart-create',
796799
featureComponent: 'saved-data',
@@ -800,7 +803,7 @@
800803
},
801804
groupId
802805
});
803-
806+
804807
// Do not make the user to wait too long for the event to be uploaded.
805808
const timer = new Promise((resolve) => setTimeout(resolve, 500));
806809
await Promise.race([timer, tiTrk?.uploadEvents()]);

tests/e2e/specs/upsell.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test.describe( 'Upsell', () => {
7070
expect( searchParams.get('utm_campaign') ).toBe('db-query');
7171

7272
await page.frameLocator('iframe').getByRole('heading', { name: /Import from database/ }).click();
73-
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Developer plan to activate this feature!');
73+
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Plus plan to activate this feature!');
7474
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade Now');
7575

7676
await page.frameLocator('iframe').getByRole('link', { name: 'Settings' }).click();
@@ -90,7 +90,7 @@ test.describe( 'Upsell', () => {
9090
searchParams = new URLSearchParams(href);
9191
expect( searchParams.get('utm_campaign') ).toBe('chart-permissions');
9292
await page.frameLocator('iframe').getByRole('heading', { name: /Permissions/ }).click();
93-
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Developer plan to activate this feature!');
93+
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade to Plus plan to activate this feature!');
9494
await expect(page.frameLocator('iframe').locator('#vz-db-wizard')).toContainText('Upgrade Now');
9595
});
9696

0 commit comments

Comments
 (0)