Skip to content

Commit 18d6b65

Browse files
authored
release: fixes
- Fix edge cases when the user data has a corrupted format. - Unify image size resize to both DAM and non-DAM contexts - Improve dashboard layout on various screen sizes - Update dependencies.
2 parents 7695bdd + 39d13a6 commit 18d6b65

26 files changed

+577
-334
lines changed

.github/workflows/test-php.yml

Lines changed: 25 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ concurrency:
88
cancel-in-progress: true
99
jobs:
1010
phplint:
11-
name: Phplint
11+
name: PHPCS on PHP 8.0
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Setup PHP version
@@ -17,62 +17,45 @@ jobs:
1717
php-version: '8.0'
1818
extensions: simplexml
1919
- name: Checkout source code
20-
uses: actions/checkout@v2
21-
- name: Get Composer Cache Directory
22-
id: composer-cache
23-
run: |
24-
echo "::set-output name=dir::$(composer config cache-files-dir)"
25-
- name: Setup Composer cache
26-
uses: actions/cache@v1
27-
with:
28-
path: ${{ steps.composer-cache.outputs.dir }}
29-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
30-
restore-keys: |
31-
${{ runner.os }}-composer-
32-
- name: Install composer
20+
uses: actions/checkout@v4
21+
- name: Install Composer dependencies
3322
run: composer install --prefer-dist --no-progress --no-suggest
3423
- name: Run PHPCS
35-
run: composer run lint
24+
run: composer phpcs
3625
phpunit:
37-
name: Phpunit
26+
name: PHPUnit tests on ${{ matrix.php-versions }}
3827
runs-on: ubuntu-latest
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
3932
services:
40-
mysql:
41-
image: mysql:5.7
33+
database:
34+
image: mysql:latest
4235
env:
36+
MYSQL_DATABASE: wordpress_tests
4337
MYSQL_ROOT_PASSWORD: root
4438
ports:
45-
- 3306/tcp
46-
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
39+
- 3306:3306
4740
steps:
4841
- name: Setup PHP version
4942
uses: shivammathur/setup-php@v2
5043
with:
51-
php-version: '8.0'
44+
php-version: ${{ matrix.php-version }}
5245
extensions: simplexml, mysql
53-
tools: phpunit-polyfills
46+
tools: phpunit-polyfills:1.1
47+
- name: Install Subversion
48+
run: sudo apt-get update && sudo apt-get install -y subversion
5449
- name: Checkout source code
55-
uses: actions/checkout@v2
50+
uses: actions/checkout@v4
5651
- name: Install WordPress Test Suite
57-
run: |
58-
bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
59-
- name: Get Composer Cache Directory
60-
id: composer-cache
61-
run: |
62-
echo "::set-output name=dir::$(composer config cache-files-dir)"
63-
- name: Setup Composer cache
64-
uses: actions/cache@v1
65-
with:
66-
path: ${{ steps.composer-cache.outputs.dir }}
67-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
68-
restore-keys: |
69-
${{ runner.os }}-composer-
70-
- name: Install composer
71-
run: composer install --prefer-dist --no-progress --no-suggest --no-dev
52+
run: composer install-wp-tests
53+
- name: Install Composer dependencies
54+
run: composer install --prefer-dist --no-progress --no-suggest
7255
- name: Run phpunit
73-
run: phpunit
56+
run: composer phpunit
7457
phpstan:
75-
name: PHPStan
58+
name: PHPStan on PHP 8.0
7659
runs-on: ubuntu-latest
7760
steps:
7861
- name: Setup PHP version
@@ -81,19 +64,8 @@ jobs:
8164
php-version: '8.0'
8265
extensions: simplexml, mysql
8366
- name: Checkout source code
84-
uses: actions/checkout@v2
85-
- name: Get Composer Cache Directory
86-
id: composer-cache
87-
run: |
88-
echo "::set-output name=dir::$(composer config cache-files-dir)"
89-
- name: Setup Composer cache
90-
uses: actions/cache@v1
91-
with:
92-
path: ${{ steps.composer-cache.outputs.dir }}
93-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
94-
restore-keys: |
95-
${{ runner.os }}-composer-
96-
- name: Install composer
67+
uses: actions/checkout@v4
68+
- name: Install Composer dependencies
9769
run: composer install --prefer-dist --no-progress --no-suggest
9870
- name: PHPStan Static Analysis
9971
run: composer phpstan

assets/img/bf-bg.jpg

12.8 KB
Loading
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { Button } from '@wordpress/components';
2+
import { close } from '@wordpress/icons';
3+
import { useEffect, useState } from '@wordpress/element';
4+
import classNames from 'classnames';
5+
import { dismissNotice } from '../../utils/api';
6+
7+
export default () => {
8+
const { urgency, title, subtitle, cta_link, cta_text, dismiss_key } = optimoleDashboardApp.bf_notices.banner;
9+
const [ isVisible, setIsVisible ] = useState( true );
10+
const [ shouldRender, setShouldRender ] = useState( true );
11+
12+
const onClose = () => {
13+
dismissNotice( dismiss_key, () => {
14+
setIsVisible( false );
15+
});
16+
};
17+
18+
useEffect( () => {
19+
if ( ! isVisible ) {
20+
const timer = setTimeout( () => {
21+
setShouldRender( false );
22+
}, 300 );
23+
return () => clearTimeout( timer );
24+
}
25+
}, [ isVisible ]);
26+
27+
const wrapClasses = classNames(
28+
'relative flex flex-col items-center text-center xl:flex-row gap-5 justify-between xl:items-center bg-black text-white p-5 py-4 pr-7 box-border rounded-lg mt-5 bg-no-repeat transition-all duration-300',
29+
{
30+
'opacity-0': ! isVisible,
31+
'opacity-100': isVisible
32+
}
33+
);
34+
35+
if ( ! shouldRender ) {
36+
return null;
37+
}
38+
39+
return (
40+
<div className={wrapClasses}
41+
style={{
42+
backgroundImage: `url(${optimoleDashboardApp.assets_url}/img/bf-bg.jpg)`,
43+
backgroundPosition: 'right 0',
44+
backgroundSize: 'auto 100%'
45+
}}
46+
>
47+
<Button
48+
icon={close}
49+
onClick={onClose}
50+
label={optimoleDashboardApp.strings.csat.close}
51+
className="absolute right-1 top-1 cursor-pointer text-white hover:text-promo-orange"
52+
/>
53+
<div className="flex flex-col gap-3 xl:items-start items-center">
54+
<div className="text-sm lg:text-base border-b border-0 border-dashed uppercase pb-1 font-semibold">{urgency}</div>
55+
<div className="text-4xl lg:text-5xl italic uppercase font-extrabold" dangerouslySetInnerHTML={{ __html: title }}/>
56+
<div className="text-sm lg:text-base font-extrabold" dangerouslySetInnerHTML={{ __html: subtitle }}/>
57+
</div>
58+
59+
<a href={cta_link} target="_blank" className="bg-promo-orange text-white px-7 py-3 uppercase text-base font-bold grow flex justify-center max-w-[150px] text-center cursor-pointer hover:bg-white hover:text-orange-400 transition-colors">{cta_text}</a>
60+
</div>
61+
);
62+
};

assets/src/dashboard/parts/connected/Sidebar.js

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ const Sidebar = () => {
4141
});
4242

4343
return (
44-
<div
45-
className="flex flex-col mt-8 mb-5 p-0 transition-all ease-in-out duration-700 gap-5 basis-3/12"
46-
>
44+
<div className="grid md:grid-cols-2 xl:flex xl:flex-col xl:mt-8 xl:mb-5 p-0 transition-all ease-in-out duration-700 gap-5 basis-4/12 2xl:basis-3/12">
4745
<div className="bg-white gap-5 flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
4846
<TextControl
4947
label={ optimoleDashboardApp.strings.logged_in_as }
@@ -73,33 +71,41 @@ const Sidebar = () => {
7371

7472
{ 'free' === plan ? (
7573
<div
76-
className="bg-info flex flex-col text-white border-0 rounded-lg shadow-md p-8 bg-promo bg-no-repeat"
74+
className="bg-info flex flex-col text-white border-0 rounded-lg overflow-hidden shadow-md bg-promo bg-no-repeat"
7775
style={ {
7876
backgroundImage: `url( ${ optimoleDashboardApp.assets_url }/img/logo2.png )`
7977
} }
8078
>
81-
<h3 className="mt-0 text-white text-lg">{ optimoleDashboardApp.strings.upgrade.title_long }</h3>
82-
83-
<ul>
84-
{ reasons.map( ( reason, index ) => (
85-
<li
86-
key={ index }
87-
className="flex items-center gap-2"
88-
>
89-
<Icon icon="yes-alt" className="text-white" />
90-
<span className="text-white font-normal text-base">{ reason }</span>
91-
</li>
92-
) ) }
93-
</ul>
94-
95-
<Button
96-
variant="link"
97-
className="optml__button flex w-full justify-center font-bold min-h-40 !no-underline !text-white !bg-opaque-black !rounded"
98-
href={ optimoleDashboardApp.optimoleHome + 'pricing' }
99-
target="_blank"
100-
>
101-
{ optimoleDashboardApp.strings.upgrade.cta }
102-
</Button>
79+
{optimoleDashboardApp?.bf_notices?.sidebar && (
80+
<a href={optimoleDashboardApp.bf_notices.sidebar.cta_link} className="flex flex-col gap-3 p-3 bg-black !no-underline text-center cursor-pointer hover:opacity-90 transition-opacity" target="_blank">
81+
<span className="font-extrabold text-[17px] uppercase italic" dangerouslySetInnerHTML={{ __html: optimoleDashboardApp.bf_notices.sidebar.title }}/>
82+
<span className="text-[11px] font-bold" dangerouslySetInnerHTML={{ __html: optimoleDashboardApp.bf_notices.sidebar.subtitle }}/>
83+
</a>
84+
)}
85+
86+
<div className="p-8 flex flex-col">
87+
<h3 className="mt-0 text-white text-lg">{ optimoleDashboardApp.strings.upgrade.title_long }</h3>
88+
<ul>
89+
{ reasons.map( ( reason, index ) => (
90+
<li
91+
key={ index }
92+
className="flex items-center gap-2"
93+
>
94+
<Icon icon="yes-alt" className="text-white" />
95+
<span className="text-white font-normal text-base">{ reason }</span>
96+
</li>
97+
) ) }
98+
</ul>
99+
100+
<Button
101+
variant="link"
102+
className="optml__button flex w-full justify-center font-bold min-h-40 !no-underline !text-white !bg-opaque-black !rounded"
103+
href={ optimoleDashboardApp.optimoleHome + 'pricing' }
104+
target="_blank"
105+
>
106+
{ optimoleDashboardApp.strings.upgrade.cta }
107+
</Button>
108+
</div>
103109
</div>
104110
) : (
105111
<Button

assets/src/dashboard/parts/connected/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Sidebar from './Sidebar';
2222
import CSAT from './CSAT';
2323
import { retrieveConflicts } from '../../utils/api';
2424
import formbricks from '@formbricks/js/app';
25+
import BlackFridayBanner from '../components/BlackFridayBanner';
2526
if ( 'undefined' !== typeof window && optimoleDashboardApp.user_data.plan ) {
2627
formbricks.init({
2728
environmentId: 'clo8wxwzj44orpm0gjchurujm',
@@ -32,9 +33,9 @@ if ( 'undefined' !== typeof window && optimoleDashboardApp.user_data.plan ) {
3233
status: optimoleDashboardApp.user_data.status,
3334
language: optimoleDashboardApp.language,
3435
cname_assigned: optimoleDashboardApp.user_data.is_cname_assigned || 'no',
35-
connected_websites: optimoleDashboardApp.user_data.whitelist.length.toString(),
36-
traffic: convertToCategory( optimoleDashboardApp.user_data.traffic, 500 ).toString(),
37-
images_number: convertToCategory( optimoleDashboardApp.user_data.images_number, 100 ).toString(),
36+
connected_websites: optimoleDashboardApp.user_data.whitelist && optimoleDashboardApp.user_data.whitelist.length.toString(),
37+
traffic: convertToCategory( optimoleDashboardApp.user_data.traffic || 0, 500 ).toString(),
38+
images_number: convertToCategory( optimoleDashboardApp.user_data.images_number || 0, 100 ).toString(),
3839
days_since_install: convertToCategory( optimoleDashboardApp.days_since_install ).toString()
3940
}
4041
});
@@ -144,10 +145,12 @@ const ConnectedLayout = ({
144145
}, [ canSave ]);
145146

146147
return (
147-
<>
148-
<div className="optml-connected max-w-screen-xl flex flex-col lg:flex-row mx-auto gap-5">
148+
<div className="optml-connected 2xl:max-w-screen-xl max-w-screen px-4 mx-auto">
149+
{optimoleDashboardApp?.bf_notices?.banner && <BlackFridayBanner/>}
150+
151+
<div className="flex flex-col xl:flex-row mx-auto gap-5">
149152
<div
150-
className="flex flex-col justify-between mt-8 mb-5 p-0 transition-all ease-in-out duration-700 relative text-gray-700 basis-9/12"
153+
className="flex flex-col justify-between mt-8 xl:mb-5 p-0 transition-all ease-in-out duration-700 relative text-gray-700 basis-8/12 2xl:basis-9/12"
151154
>
152155
{ 'dashboard' === tab && <Dashboard /> }
153156

@@ -171,7 +174,7 @@ const ConnectedLayout = ({
171174
</div>
172175

173176
<CSAT />
174-
</>
177+
</div>
175178
);
176179
};
177180

assets/src/dashboard/utils/api.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,4 +603,26 @@ export const addNotice = ( text ) => {
603603
);
604604
};
605605

606+
export const dismissNotice = ( key, callback = () => {}) => {
607+
apiFetch({
608+
path: optimoleDashboardApp.routes[ 'dismiss_notice' ],
609+
method: 'POST',
610+
data: {
611+
key
612+
}
613+
}).then( response => {
614+
if ( 'success' !== response.code ) {
615+
addNotice( response?.data?.error || optimoleDashboardApp.strings.options_strings.settings_saved_error );
616+
617+
return;
618+
}
619+
620+
if ( callback ) {
621+
callback( response );
622+
}
623+
}).catch( err => {
624+
addNotice( optimoleDashboardApp.strings.options_strings.settings_saved_error );
625+
});
626+
};
627+
606628

0 commit comments

Comments
 (0)