Skip to content

Commit

Permalink
qa fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
HardeepAsrani committed Nov 16, 2023
1 parent 53b2838 commit 3c0b8a1
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 119 deletions.
3 changes: 2 additions & 1 deletion inc/css/blocks/class-posts-css.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ public function render_css( $block ) {
return CSS_Utility::box_values(
$value,
array(
'top' => '10px',
'top' => '10px',
'bottom' => '30px',
)
);
},
Expand Down
1 change: 0 additions & 1 deletion otter-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function( $links ) {
function( $products ) {
$already_registered = false;

// Since Otter can use Neve license, the SDK might not detected it so we need to update it manually.
$license = apply_filters( 'product_otter_license_key', 'free' );
$track_hash = 'free' === $license ? 'free' : wp_hash( $license );

Expand Down
13 changes: 6 additions & 7 deletions src/animation/count/inline-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ import { format as settings } from './index.js';

import { updateAnimConfig } from '../editor.js';

// Fitler out 'custom' value from delayList and speedList
delayList.pop();
speedList.pop();
const delayListInline = delayList.filter( ( i ) => 'o-anim-custom-delay' !== i.value );
const speedListInline = speedList.filter( ( i ) => 'o-anim-custom-speed' !== i.value );

const InlineControls = ({
value,
Expand All @@ -50,11 +49,11 @@ const InlineControls = ({
classes = attributes.className;
classes = classes.split( ' ' );

const countDelayClass = Array.from( delayList ).find( ( i ) => {
const countDelayClass = Array.from( delayListInline ).find( ( i ) => {
return classes.find( ( o ) => o === `o-count-${ i.value }` );
});

const countSpeedClass = Array.from( speedList ).find( ( i ) => {
const countSpeedClass = Array.from( speedListInline ).find( ( i ) => {
return classes.find( ( o ) => o === `o-count-${ i.value }` );
});

Expand Down Expand Up @@ -102,14 +101,14 @@ const InlineControls = ({
<SelectControl
label={ __( 'Delay', 'otter-blocks' ) }
value={ countDelay || 'none' }
options={ delayList }
options={ delayListInline }
onChange={ value => updateAnimConfig( 'count', countDelay, value, () => setCountDelay( value ), attributes, setAttributes ) }
/>

<SelectControl
label={ __( 'Speed', 'otter-blocks' ) }
value={ countSpeed || 'none' }
options={ speedList }
options={ speedListInline }
onChange={ value => updateAnimConfig( 'count', countSpeed, value, () => setCountSpeed( value ), attributes, setAttributes ) }
/>

Expand Down
13 changes: 6 additions & 7 deletions src/animation/typing/inline-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ import { format as settings } from './index.js';

import { updateAnimConfig } from '../editor.js';

// Fitler out 'custom' value from delayList and speedList
delayList.pop();
speedList.pop();
const delayListInline = delayList.filter( ( i ) => 'o-anim-custom-delay' !== i.value );
const speedListInline = speedList.filter( ( i ) => 'o-anim-custom-speed' !== i.value );

const InlineControls = ({
value,
Expand All @@ -50,11 +49,11 @@ const InlineControls = ({
classes = attributes.className;
classes = classes.split( ' ' );

const typingDelayClass = Array.from( delayList ).find( ( i ) => {
const typingDelayClass = Array.from( delayListInline ).find( ( i ) => {
return classes.find( ( o ) => o === `o-typing-${ i.value }` );
});

const typingSpeedClass = Array.from( speedList ).find( ( i ) => {
const typingSpeedClass = Array.from( speedListInline ).find( ( i ) => {
return classes.find( ( o ) => o === `o-typing-${ i.value }` );
});

Expand Down Expand Up @@ -102,14 +101,14 @@ const InlineControls = ({
<SelectControl
label={ __( 'Delay', 'otter-blocks' ) }
value={ typingDelay || 'none' }
options={ delayList }
options={ delayListInline }
onChange={ value => updateAnimConfig( 'typing', typingDelay, value, () => setTypingDelay( value ), attributes, setAttributes ) }
/>

<SelectControl
label={ __( 'Speed', 'otter-blocks' ) }
value={ typingSpeed || 'none' }
options={ speedList }
options={ speedListInline }
onChange={ value => updateAnimConfig( 'typing', typingSpeed, value, () => setTypingSpeed( value ), attributes, setAttributes ) }
/>

Expand Down
12 changes: 12 additions & 0 deletions src/blocks/blocks/advanced-heading/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@
font-weight: bold;
min-width: 40px;
}

.wp-block-themeisle-blocks-advanced-heading {
margin: var(--margin) !important;

@media ( min-width: 600px ) and ( max-width: 960px ) {
margin: var(--margin-tablet) !important;
}

@media ( max-width: 600px ) {
margin: var(--margin-mobile) !important;
}
}
1 change: 0 additions & 1 deletion src/blocks/blocks/content-generator/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ const ContentGenerator = ({
/>

<div { ...blockProps }>

{
attributes.promptID === undefined ? (
<VariationPicker
Expand Down
1 change: 0 additions & 1 deletion src/blocks/blocks/content-generator/editor.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.wp-block-themeisle-blocks-content-generator {
padding: 10px;
border-radius: 10px;

.o-preview {
Expand Down
1 change: 0 additions & 1 deletion src/blocks/blocks/deprecated/about-author/style.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
section {
&.wp-block-themeisle-blocks-about-author {
border: 0;
margin-bottom: 30px;
border-radius: 6px;
width: 100%;
position: relative;
Expand Down
6 changes: 1 addition & 5 deletions src/blocks/blocks/posts/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ const Edit = ({
dispatch( 'otter-store' ).setPostsSlugs( slugs );
}, [ slugs ]);

useEffect( () => {
console.log( attributes );
}, [ attributes ]);

useDarkBackground( attributes.backgroundColor, attributes, setAttributes );

const getValue = field => getDefaultValueByField({ name, field, defaultAttributes, attributes });
Expand Down Expand Up @@ -280,7 +276,7 @@ const Edit = ({
'--pag-padding': boxValues( attributes.pagPadding, { top: '5px', right: '15px', bottom: '5px', left: '15px' }),
'--pag-gap': attributes.pagGap,
'--pag-size': attributes.pagSize,
'--pag-cont-margin': boxValues( attributes.pagContMargin, { top: '10px' })
'--pag-cont-margin': boxValues( attributes.pagContMargin, { top: '10px', bottom: '30px' })
};

const blockProps = useBlockProps();
Expand Down
4 changes: 2 additions & 2 deletions src/blocks/blocks/posts/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ const Inspector = ({
/>
<BoxControl
label={ __( 'Pagination Container Margin', 'otter-blocks' ) }
values={ attributes.pagContMargin ?? { top: '10px' } }
values={ attributes.pagContMargin ?? { top: '10px', 'bottom': '30px' } }
onChange={ pagContMargin => setAttributes({ pagContMargin }) }
sides={[ 'top' ]}
sides={[ 'top', 'bottom' ]}
allowReset
/>
</Fragment>
Expand Down
2 changes: 0 additions & 2 deletions src/blocks/blocks/posts/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,6 @@
}

.o-posts-grid-pag {
margin-bottom: 30px;

display: flex;
flex-direction: row;
flex-wrap: wrap;
Expand Down
3 changes: 1 addition & 2 deletions src/blocks/components/prompt/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@
display: flex;
flex-direction: column;
gap: 10px;
margin-top: 10px;

background-color: white;
border-radius: 2px;
border: 1px solid #1E1E1E;
width: 100%;
width: auto;
max-width: 1200px;
padding: 10px;

Expand Down
81 changes: 3 additions & 78 deletions src/blocks/components/prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,42 +125,12 @@ const PromptBlockEditor = (
);
};

const TrackingConsentToggle = ( props: {onToggle: ( value: boolean ) => void, value: boolean, onClose: () => void}) => {
return (
<div className="o-tracking-consent-toggle">
<div className="o-tracking-consent-toggle__toggle">
<input
type="checkbox"
checked={ props.value }
onChange={ ( event ) => {
props.onToggle( event.target.checked );
}}
name="o-tracking-consent-toggle"
/>
</div>
<label className="o-tracking-consent-toggle__label" htmlFor="o-tracking-consent-toggle">
{ __( 'Help us improve the AI block by allowing anonymous usage tracking.', 'otter-blocks' ) }
</label>
<div className="o-tracking-consent-toggle__close">
<Button
variant="tertiary"
onClick={ props.onClose }
icon={closeSmall}
/>
</div>
</div>
);
};

const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
const { title, value, onValueChange, promptID } = props;

const [ getOption, updateOption, status ] = useSettings();
const [ apiKey, setApiKey ] = useState<string | null>( null );

const [ showTrackingConsent, setShowTrackingConsent ] = useState<boolean>( false );
const [ trackingConsent, setTrackingConsent ] = useState<boolean>( false );

const [ generationStatus, setGenerationStatus ] = useState<'loading' | 'loaded' | 'error'>( 'loaded' );

const [ apiKeyStatus, setApiKeyStatus ] = useState<'checking' | 'missing' | 'present' | 'error'>( window.themeisleGutenberg?.hasOpenAiKey ? 'present' : 'checking' );
Expand All @@ -176,28 +146,6 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
const [ errorMessage, setErrorMessage ] = useState<string>( '' );
const [ tokenUsageDescription, setTokenUsageDescription ] = useState<string>( '' );

const onSuccessActions = {
clearHistory: () => {
setResult( undefined );
setResultHistory([]);
setResultHistoryIndex( 0 );
}
};

const onToggleTrackingConsent = ( value: boolean ) => {
updateOption( 'otter_blocks_logger_flag', value ? 'yes' : '', __( 'Tracking consent saved.', 'otter-blocks' ), 'o-tracking-consent', () => {
if ( value ) {
setShowTrackingConsent( false );
}
});

setTrackingConsent( value );
};

useEffect( () => {
setShowTrackingConsent( ! Boolean( localStorage.getItem( 'o-tracking-consent' ) ) );
}, []);

useEffect( () => {
const getEmbeddedPrompt = async() => {
retrieveEmbeddedPrompt( promptID ).then( ( promptServer ) => {
Expand All @@ -220,11 +168,6 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
} else {
setApiKeyStatus( 'missing' );
}

if ( window.themeisleGutenberg?.canTrack ) {
setTrackingConsent( true );
setShowTrackingConsent( false );
}
}

if ( 'error' === status ) {
Expand Down Expand Up @@ -254,10 +197,6 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {

function onPromptSubmit( regenerate = false ) {

console.log( 'onPromptSubmit', promptID );

console.log( embeddedPrompts );

let embeddedPrompt = embeddedPrompts?.find( ( prompt ) => prompt.otter_name === promptID );

if ( undefined === embeddedPrompt ) {
Expand Down Expand Up @@ -349,7 +288,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
return (
<Placeholder
className="prompt-placeholder"
label={__( 'OpenAI API Key', 'otter-blocks' )}
label={ __( 'OpenAI API Key', 'otter-blocks' ) }
>
{
'checking' === apiKeyStatus && (
Expand Down Expand Up @@ -421,7 +360,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
}

return (
<div>
<Fragment>
{
( 0 < resultHistory?.length ) ? (
<PromptBlockEditor
Expand Down Expand Up @@ -458,19 +397,6 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
placeholder={ props.promptPlaceholder }
/>

{/*{*/}
{/* showTrackingConsent && (*/}
{/* <TrackingConsentToggle*/}
{/* onToggle={ onToggleTrackingConsent }*/}
{/* value={ trackingConsent }*/}
{/* onClose={() => {*/}
{/* setShowTrackingConsent( false );*/}
{/* localStorage.setItem( 'o-tracking-consent', 'true' );*/}
{/* }}*/}
{/* />*/}
{/* )*/}
{/*}*/}

{props.children}
</PromptBlockEditor>
) : (
Expand All @@ -497,8 +423,7 @@ const PromptPlaceholder = ( props: PromptPlaceholderProps ) => {
</Notice>
)
}
</div>

</Fragment>
);
};

Expand Down
3 changes: 0 additions & 3 deletions src/blocks/frontend/leaflet-map/leaflet-gesture-handling.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ const t = setInterval( () => {
}

if ( ! languageContent ) {

// If still nothing, default to English
// console.log("No lang found for", lang);
lang = 'en';
languageContent = LanguageContent[lang];
}
Expand Down
1 change: 0 additions & 1 deletion src/blocks/frontend/sticky/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,6 @@ domReady( () => {

// create an Observer instance
const resizeObserver = new ResizeObserver( entries => {
console.log( 'Body height changed:', entries?.[0]?.target.clientHeight );
if ( entries?.[0]?.target.clientHeight ) {
runner.updateTriggers();
}
Expand Down
2 changes: 0 additions & 2 deletions src/blocks/helpers/defered-wp-options-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ class DeferredWpOptionsSave {
}

const fieldIndex = fieldOptions.findIndex( ( field ) => {

// console.log( field.fieldOptionName, change.value.fieldOptionName );
return field.fieldOptionName === payload.fieldOptionName;
});

Expand Down
5 changes: 0 additions & 5 deletions src/blocks/test/e2e/global-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,12 @@ async function globalSetup( config: FullConfig ) {
const storageStatePath =
'string' === typeof storageState ? storageState : undefined;

console.log( `[INFO] Base URL Test Instance: ${baseURL}` );

const requestContext = await request.newContext({
baseURL
});

const r = await requestContext.head( baseURL );

console.log( '[Info] Request Status', r.status() );
console.log( '[INFO] Endpoint Link', r.headers().link );

if ( r.headers().link === undefined ) {
console.warn( '[Warning] No links header found. The connection might be invalid.' );
}
Expand Down

0 comments on commit 3c0b8a1

Please sign in to comment.