Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/block-meta-translation
Browse files Browse the repository at this point in the history
  • Loading branch information
merkushin committed Feb 2, 2024
2 parents fba38b8 + e982589 commit d139af5
Show file tree
Hide file tree
Showing 546 changed files with 37,104 additions and 7,707 deletions.
8 changes: 7 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ trim_trailing_whitespace = true
[*.{md,txt,json,yml}]
trim_trailing_whitespace = false

[*.{json}]
[*.json]
indent_size = 2
tab_width = 2

[*.{json,yml}]
insert_final_newline = false
indent_style = space

[composer.json]
indent_size = 4
tab_width = 4
indent_style = tab
insert_final_newline = true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: "[Type] Bug"
labels: "[Status] Needs Triage, [Type] Bug"
assignees: ''

---
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: "[Type] Enhancement"
labels: "[Status] Needs Triage, [Type] Enhancement"
assignees: ''

---
Expand Down
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Both the PR author and reviewer are responsible for ensuring the checklist is co
- [ ] New UIs are responsive and use a [mobile-first approach](https://zellwk.com/blog/how-to-write-mobile-first-css/)
- [ ] New UIs match the designs
- [ ] Different user privileges (admin, teacher, subscriber) are tested as appropriate
- [ ] Legacy courses (course without blocks) are tested
- [ ] Code is tested on the minimum supported PHP and WordPress versions
- [ ] User interface changes have been tested on the latest versions of Chrome, Firefox and Safari
- [ ] "Needs Documentation" label is added if this change requires updates to documentation
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/install-php/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
php-version:
description: 'The PHP version to use'
required: false
default: '7.3'
default: '7.4'

extensions:
description: 'The PHP extensions to use'
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ jobs:
name: sensei-lms-${{ github.event.pull_request.head.sha }}
path: ${{ github.workspace }}/sensei-lms/
retention-days: 7

syntax-check:
name: PHP Syntax Check
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [7.4, 8.1]
steps:
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: sensei-lms-${{ github.event.pull_request.head.sha }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: phplint
coverage: none

- name: Check Syntax
run: phplint ./sensei-lms
14 changes: 7 additions & 7 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.3'
php-version: '7.4'
tools: composer
coverage: none

Expand Down Expand Up @@ -59,16 +59,16 @@ jobs:
matrix:
wp: ['latest']
wpmu: [0]
php: ['7.3', '7.4', '8.0']
php: ['7.4', '8.0']
include:
- php: 7.3
wp: '6.0'
- php: 7.3
- php: 7.4
wp: '6.1'
- php: 7.3
- php: 7.4
wp: '6.2'
- php: 7.4
wp: latest
wpmu: 1
- php: 7.3
- php: 7.4
wp: nightly
env:
WP_VERSION: ${{ matrix.wp }}
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/psalm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Psalm Test

on:
pull_request:
workflow_call:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Psalm
runs-on: ubuntu-latest
strategy:
fail-fast: true
max-parallel: 10
matrix:
php: ['7.4', '8.2']
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get cached composer directories
uses: actions/cache@v3
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
- uses: actions/cache@v3
with:
path: vendor/
key: ${{ runner.os }}-vendor-${{ hashFiles('composer.lock') }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: composer
coverage: none

- name: Install
run: composer install --no-ansi --no-interaction --prefer-dist --no-progress

- name: Run Psalm
run: ./vendor/bin/psalm
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Before submitting a pull request, make sure that your changes follow the followi
Test your code on the minimum supported PHP and WordPress versions.
- Please ensure that any dependencies are properly handled and documented.

## Composer

- Because of possible conflicts, all required composer packages should be `scoped`. Scoping is done by copying the package to the `third-party` folder and changing its namespace to `Sensei\ThirdParty\...`. To do so, first, add the package as a dev dependency - `composer require --dev vendor/package`. Then, edit `config/scoper.inc.php` to include the new package. Keep in mind that some packages may have their dependencies, so add those as well. Finally, run `composer dump-autoload` which will initialize the scoping process.

## JavaScript and CSS

- JavaScript, JSX, and SCSS files (using [SASS](https://sass-lang.com/documentation/file.SASS_REFERENCE.html)) need to be compiled before using the plugin.
Expand Down
25 changes: 23 additions & 2 deletions assets/admin/editor-wizard/editor-wizard-modal.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* WordPress dependencies
*/
import { useDispatch } from '@wordpress/data';
import { useDispatch, useSelect } from '@wordpress/data';
import { Modal } from '@wordpress/components';
import { useState } from '@wordpress/element';
import { useEffect, useState } from '@wordpress/element';
import { store as editorStore } from '@wordpress/editor';

/**
Expand Down Expand Up @@ -47,6 +47,27 @@ const EditorWizardModal = () => {
onWizardCompletion();
};

const { setShowWelcomeGuide } =
useDispatch( 'automattic/wpcom-welcome-guide' ) ?? {};

const { isShowWelcomeGuide } = useSelect( ( select ) => {
const { isWelcomeGuideShown } =
select( 'automattic/wpcom-welcome-guide' ) ?? {};
return {
isShowWelcomeGuide: isWelcomeGuideShown
? isWelcomeGuideShown()
: false,
};
}, [] );

useEffect( () => {
if ( setShowWelcomeGuide && isShowWelcomeGuide ) {
setShowWelcomeGuide( undefined, {
onlyLocal: true,
} );
}
}, [ setShowWelcomeGuide, isShowWelcomeGuide ] );

return (
open && (
<Modal
Expand Down
2 changes: 1 addition & 1 deletion assets/admin/editor-wizard/patterns-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const PatternsList = ( { onChoose } ) => {
>
<div className="sensei-patterns-list__item-preview">
<BlockPreview
__experimentalPadding={ 10 }
__experimentalPadding={ 30 }
blocks={ blocks
.filter( withoutLessonActions )
.map( withBlockExample ) }
Expand Down
6 changes: 0 additions & 6 deletions assets/admin/editor-wizard/patterns-list.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
$thumbnail-height: 235px;
$preview-padding: 5px;
$preview-max-height: $thumbnail-height + 5px;

.sensei-patterns-list {
@media ( min-width: 600px ) {
Expand All @@ -22,11 +20,7 @@ $preview-max-height: $thumbnail-height + 5px;
height: $thumbnail-height;
overflow: hidden;

padding-top: $preview-padding;
padding-bottom: $preview-padding;

.block-editor-block-preview__container {
max-height: $preview-max-height;
margin-top: -17px;
}
}
Expand Down
3 changes: 2 additions & 1 deletion assets/admin/editor-wizard/steps/course-details-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ const CourseDetailsStep = ( { wizardData, setWizardData } ) => {
value={ wizardData.title ?? '' }
onChange={ updateCourseTitle }
maxLength={ 40 }
autoFocus // eslint-disable-line jsx-a11y/no-autofocus
/>
<LimitedTextControl
className="sensei-editor-wizard-step__form-control"
label={ __( 'Course Description', 'sensei-lms' ) }
value={ wizardData.description ?? '' }
onChange={ updateCourseDescription }
maxLength={ 350 }
multiline={ true }
multiline
/>
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions assets/admin/editor-wizard/steps/course-details-step.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ describe( '<CourseDetailsStep />', () => {
description: NEW_DESCRIPTION,
} );
} );

it( 'Focuses the Course Title input.', () => {
const { queryByLabelText } = render(
<CourseDetailsStep wizardData={ {} } setWizardData={ () => {} } />
);

expect( queryByLabelText( 'Course Title' ) ).toHaveFocus();
} );
} );

describe( '<CourseDetailsStep.Actions />', () => {
Expand Down
4 changes: 2 additions & 2 deletions assets/admin/editor-wizard/steps/lesson-patterns-step.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const LessonPatternsStep = ( { wizardData, ...props } ) => {
return (
<Fragment>
<PatternsStep
title={ __( 'Lesson Type', 'sensei-lms' ) }
title={ __( 'Lesson Layout', 'sensei-lms' ) }
replaces={ replaces }
{ ...props }
/>
Expand All @@ -48,7 +48,7 @@ const UpsellBlock = () => (
<LogoTreeIcon className="sensei-editor-wizard-patterns-upsell__logo" />
<div className="sensei-editor-wizard-patterns-upsell__text">
<b className="sensei-editor-wizard-patterns-upsell__title">
{ __( 'Want More Lesson Types?', 'sensei-lms' ) }
{ __( 'Want More Lesson Layouts?', 'sensei-lms' ) }
</b>
<br />
{ __(
Expand Down
11 changes: 6 additions & 5 deletions assets/admin/editor-wizard/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
height: 100%;

&__footer {
position: sticky;
bottom: 0;
width: 100%;
align-items: center;
background: #ffffff;
border-top: 1px solid rgba(30, 30, 30, 0.12);
bottom: 0;
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
border-top: 1px solid rgba(30, 30, 30, 0.12);
padding: 18px;
position: sticky;
width: 100%;
z-index: 10;

@media ( min-width: 600px ) {
padding: 18px 30px;
Expand Down
15 changes: 15 additions & 0 deletions assets/admin/exit-survey/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* WordPress dependencies
*/
import apiFetch from '@wordpress/api-fetch';
import { render } from '@wordpress/element';

/**
Expand All @@ -20,6 +21,7 @@ import { ExitSurveyForm } from './form';

const deactivateLinks = [
getDeactivateLinkElement( 'sensei-lms' ),
getDeactivateLinkElement( 'sensei-pro-wc-paid-courses' ),
getDeactivateLinkElement( 'sensei-with-woocommerce-paid-courses' ),
getDeactivateLinkElement(
'woocommerce-com-woocommerce-paid-courses'
Expand Down Expand Up @@ -52,6 +54,7 @@ import { ExitSurveyForm } from './form';
constructor( { href } ) {
this.href = href;
}

/**
* Create and open a modal with an exit survey form.
*
Expand Down Expand Up @@ -82,11 +85,23 @@ import { ExitSurveyForm } from './form';
*/
submitExitSurvey = async ( data ) => {
const body = new window.FormData();

body.append( 'action', 'exit_survey' );
body.append( '_wpnonce', window.sensei_exit_survey?.nonce );
body.append( 'reason', data.reason );
body.append( 'details', data.details );

// Get the name of the active theme.
try {
const result = await apiFetch( {
path: '/wp/v2/themes?status=active',
} );

if ( result.length > 0 ) {
body.append( 'theme', result[ 0 ].name?.raw || '' );
}
} catch ( e ) {}

await window.fetch( window.ajaxurl, {
method: 'POST',
body,
Expand Down
2 changes: 1 addition & 1 deletion assets/blocks/button/color-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const removeColorProps = ( props ) => ( {
''
),
style: omitBy( props?.style, ( value, key ) =>
key.match( /(color|background|background-color)/ )
key.match( /(color|background|background-color|border)/ )
),
} );

Expand Down
Loading

0 comments on commit d139af5

Please sign in to comment.