Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
- Fixed the permissions of the plans
  • Loading branch information
vytisbulkevicius authored May 14, 2024
2 parents c6392de + 5a5cecb commit 4c7a8e4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
13 changes: 11 additions & 2 deletions classes/Visualizer/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,20 @@ public static function can_show_feature( $feature ) {
* Gets the features for the provided license type.
*/
public static final function get_features_for_license( $plan ) {
$is_new_personal = apply_filters( 'visualizer_is_new_personal', false );
switch ( $plan ) {
case 1:
return array( 'import-wp', 'import-wc-report', 'import-file', 'import-url' );
$features = array( 'import-wp', 'import-wc-report', 'import-file', 'import-url' );
if ( ! $is_new_personal ) {
$features[] = 'db-query';
}
return $features;
case 2:
return array( 'db-query', 'schedule-chart', 'chart-permissions', 'import-chart', 'data-filter-configuration', 'frontend-actions' );
$features = array( 'schedule-chart', 'chart-permissions', 'import-chart', 'data-filter-configuration', 'frontend-actions' );
if ( $is_new_personal ) {
$features[] = 'db-query';
}
return $features;
}
}

Expand Down
9 changes: 7 additions & 2 deletions classes/Visualizer/Module/Sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ public function addProUpsell( $old, $feature = null ) {
( in_array( $feature, $pro_features, true ) && ! Visualizer_Module::is_pro() )
) {
$msg = sprintf( __( 'Upgrade to %s to activate this feature!', 'visualizer' ), 'PRO' );
if ( in_array( $feature, $biz_features, true ) ) {
$msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Developer' );
$plus_msg = sprintf( __( 'Upgrade to %s plan to activate this feature!', 'visualizer' ), 'Plus' );
if ( in_array( $feature, $biz_features, true ) && Visualizer_Module::is_pro() ) {
$msg = $plus_msg;
}
if ( in_array( $feature, [ 'db-query', 'chart-permissions' ], true ) ) {
$msg = $plus_msg;
}

$return = '<div class="only-pro-content">';
$return .= ' <div class="only-pro-container">';
$return .= ' <div class="only-pro-inner">';
Expand Down
29 changes: 16 additions & 13 deletions js/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

(function ($) {
$(window).on('load', function(){
// scroll to the selected chart type.
$('#chart-select').scrollIntoView();
let chart_select = $('#chart-select');
if(chart_select.length > 0){
// scroll to the selected chart type.
$('#chart-select')[0].scrollIntoView();
}
});

$(document).ready(function () {
Expand Down Expand Up @@ -154,7 +157,7 @@

/**
* Initialize/Update the available chart list based on their supported renderer libraries.
*
*
* @returns {void}
*/
function init_available_chart_list() {
Expand All @@ -172,7 +175,7 @@
const rendererTypesMapping = JSON.parse( rendererTypesMappingData );

document.querySelectorAll('input.type-radio').forEach( chartTypeRadio => {

// Init the lib based on the default selected chart type.
if ( chartTypeRadio.checked ) {
const chartType = chartTypeRadio.value;
Expand Down Expand Up @@ -201,14 +204,14 @@
}
});
});

// Update the chart list on user interaction.
rendererSelect.addEventListener('change', (event) => {
disable_renderer_select_placeholder();
toggle_renderer_type( event.target.value );
toggle_chart_types_by_render( event.target.value );
});

}

/**
Expand All @@ -223,24 +226,24 @@

/**
* Toggle the renderer type class based on the given renderer type.
*
*
* The class is used to style the chart type picker based on the given renderer library.
*
*
* @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to toggle the class.
*/
function toggle_renderer_type( rendererType ) {
const typePicker = document.querySelector('#type-picker');
if ( ! typePicker ) {
return;
}

typePicker.classList.remove('lib-GoogleCharts', 'lib-ChartJS', 'lib-DataTable');
typePicker.classList.add(`lib-${rendererType}`);
}

/**
* Toggle chart types based on the given renderer type.
*
*
* @param {('GoogleCharts' | 'ChartJS' | 'DataTable')} rendererType The renderer type to filter the chart types.
*/
function toggle_chart_types_by_render( rendererType ) {
Expand Down Expand Up @@ -786,11 +789,11 @@
if( chartTypes ) {
document.querySelector('.push-right[type=submit]')?.addEventListener('click', async function (event) {
if ( typeof window.tiTrk !== 'undefined' ) {
event.preventDefault();
event.preventDefault();
try {
const formData = new FormData(document.querySelector('#viz-types-form'));
const savedData = Object.fromEntries(formData);

tiTrk?.with('visualizer')?.add({
feature: 'chart-create',
featureComponent: 'saved-data',
Expand All @@ -800,7 +803,7 @@
},
groupId
});

// Do not make the user to wait too long for the event to be uploaded.
const timer = new Promise((resolve) => setTimeout(resolve, 500));
await Promise.race([timer, tiTrk?.uploadEvents()]);
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/specs/upsell.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test.describe( 'Upsell', () => {
expect( searchParams.get('utm_campaign') ).toBe('db-query');

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

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

Expand Down

0 comments on commit 4c7a8e4

Please sign in to comment.