Skip to content

Commit

Permalink
Merge branch 'next' of https://github.com/codeinwp/optimole-wp into f…
Browse files Browse the repository at this point in the history
…ix/issue-941

� Conflicts:
�	inc/admin.php
  • Loading branch information
abaicus committed Aug 2, 2023
2 parents e05b3cd + 547c94d commit 8e12555
Show file tree
Hide file tree
Showing 67 changed files with 3,653 additions and 809 deletions.
15 changes: 14 additions & 1 deletion .github/ISSUE_TEMPLATE/Feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,17 @@ body:
label: What is your proposed solution?
description: Can you please specify the desired feature or improvement and how it resolves the problem mentioned?
validations:
required: false
required: false
- type: dropdown
id: doc-needed
attributes:
label: Will this feature require documentation? (Optional)
description: |
Does this feature require the creation or update of documentation? If you're unsure, feel free to skip this.
multiple: false
options:
- 'I dont know.'
- 'No.'
- 'Yes, it requires documentation.'
validations:
required: false
5 changes: 4 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ regression:
- '(Yes, this is a regression)'

customer report:
- '(helpscout)'
- '(helpscout|wordpress.org/support)'

doc-needed:
- '(Yes, it requires documentation.)'
Binary file added .wordpress-org/icon-128x128.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/icon-128x128.png
Binary file not shown.
Binary file added .wordpress-org/icon-256x256.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wordpress-org/icon-256x256.png
Binary file not shown.
74 changes: 0 additions & 74 deletions assets/js/optimole_media.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 52 additions & 2 deletions assets/src/parts/Main.js → assets/src/dashboard/parts/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useSelect } from '@wordpress/data';

import { useState } from '@wordpress/element';
import { useEffect, useState } from '@wordpress/element';

/**
* Internal dependencies.
Expand All @@ -14,9 +14,24 @@ import ConnectLayout from './connect';
import ConnectingLayout from './connecting';
import ConnectedLayout from './connected';
import Footer from './Footer';
import { highlightSidebarLink } from '../utils/helpers';

const Main = () => {
const [ tab, setTab ] = useState( 'dashboard' );
const allowedTabs = [ 'dashboard', 'settings', 'help' ];
const hash = window.location.hash.replace( '#', '' );
let defaultTab = allowedTabs.includes( hash ) ? hash : 'dashboard';

const [ tab, setTab ] = useState( defaultTab );

const switchToSettings = ( e ) => {
e.preventDefault();
setTab( 'settings' );
};

const switchToDashboard = ( e ) => {
e.preventDefault();
setTab( 'dashboard' );
};

const {
showDisconnect,
Expand All @@ -39,6 +54,41 @@ const Main = () => {
};
});


useEffect( () => {
if ( ! isConnected ) {
return;
}
window.location.hash = `#${ tab }`;
highlightSidebarLink();
}, [ tab ]);

useEffect( () => {

if ( ! isConnected ) {
return;
}

const dashLink = document.querySelector( 'a[href*="page=optimole"]' );
const settingsLink = document.querySelector( 'a[href*="page=optimole#settings"]' );

if ( ! dashLink || ! settingsLink ) {
return;
}

dashLink.addEventListener( 'click', switchToDashboard );
settingsLink.addEventListener( 'click', switchToSettings );

return () => {
if ( ! dashLink || ! settingsLink ) {
return;
}
dashLink.removeEventListener( 'click', switchToDashboard );
settingsLink.removeEventListener( 'click', switchToSettings );
};
}, []);


return (
<>
<Header
Expand Down
File renamed without changes.
File renamed without changes.
144 changes: 144 additions & 0 deletions assets/src/dashboard/parts/connected/CSAT.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* External dependencies.
*/
import { info } from '@wordpress/icons';

/**
* WordPress dependencies.
*/
import {
Button,
Icon,
TextareaControl,
Tooltip
} from '@wordpress/components';

import { useSelect } from '@wordpress/data';

import {
useEffect,
useState
} from '@wordpress/element';

/**
* Internal dependencies.
*/
import CSAT from './csat/index';
import useSettings from '../../utils/use-settings';

const CSATList = () => {
const [ isVisible, setIsVisible ] = useState( false );
const [ getOption, updateOption, status ] = useSettings();

const settings = ( 'loaded' === status && undefined !== getOption( 'optml_csat' ) ) && JSON.parse( getOption( 'optml_csat' ) );

const {
hasImages,
isFirstSite
} = useSelect( select => {
const { getUserData } = select( 'optimole' );

return {
hasImages: 0 < getUserData()?.images_number,
isFirstSite: 1 === getUserData()?.whitelist?.length
};
});

const visits = localStorage.getItem( 'optimole_settings_visits' );

useEffect( () => {
setIsVisible( hasImages && isFirstSite && 3 <= parseInt( visits ) && false !== settings && true !== settings?.firstImpressions );
}, [ visits, settings ]);

return (
<>
<CSAT
id="first-impressions"
show={ isVisible }
onDismiss={ () => updateOption( 'optml_csat', JSON.stringify({ ...settings, firstImpressions: true }) ) }
strings={ {
title: optimoleDashboardApp.strings.csat.title,
close: optimoleDashboardApp.strings.csat.close
} }
pages={ [
{
showHeader: true,
content: ( props ) => (
<div className="flex flex-col gap-5 px-8 pb-8">
<div className="font-bold text-lg">
{ optimoleDashboardApp.strings.csat.heading_one }
</div>

<div className="flex gap-5">
{ [ 1, 2, 3, 4, 5 ].map( value => (
<Button
key={ value }
onClick={ () => props.changeData({ score: value }, true ) }
className="optml__button basis-full justify-center rounded font-bold min-h-40"
>
{ value }
</Button>
) ) }
</div>

<div className="flex justify-between">
<span className="text-purple-gray text-sm">{ optimoleDashboardApp.strings.csat.low }</span>
<span className="text-purple-gray text-sm">{ optimoleDashboardApp.strings.csat.high }</span>
</div>
</div>
)
},
{
showHeader: true,
content: ( props ) => (
<div className="flex flex-col gap-5 px-8 pb-8">
<div className="font-bold text-lg">
{ optimoleDashboardApp.strings.csat.heading_two }
</div>

<TextareaControl
label={ optimoleDashboardApp.strings.csat.heading_two }
hideLabelFromVision={ true }
value={ props.data?.feedback }
placeholder={ optimoleDashboardApp.strings.csat.feedback_placeholder }
onChange={ feedback => props.changeData({ feedback }) }
/>

<div className="flex justify-between">
<Tooltip
text={ optimoleDashboardApp.strings.csat.privacy_tooltip }
>
<div className="flex items-center cursor-pointer text-info">
<Icon icon={ info } className="mr-2 fill-info" />

{ optimoleDashboardApp.strings.csat.privacy }
</div>
</Tooltip>

<div className="flex gap-2">
<Button
onClick={ () => props.onSubmit() }
className="optml__button basis-full justify-center rounded font-bold min-h-40"
>
{ optimoleDashboardApp.strings.csat.skip }
</Button>

<Button
variant="primary"
onClick={ () => props.onSubmit() }
className="optml__button basis-full justify-center rounded font-bold min-h-40"
>
{ optimoleDashboardApp.strings.csat.submit }
</Button>
</div>
</div>
</div>
)
}
] }
/>
</>
);
};

export default CSATList;
File renamed without changes.
Loading

0 comments on commit 8e12555

Please sign in to comment.