Skip to content

Commit

Permalink
Fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
donnapep committed Apr 22, 2021
1 parent c861242 commit e8c7b8e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
7 changes: 5 additions & 2 deletions assets/blocks/lesson-metadata/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ import edit from './lesson-metadata-edit';

export default {
title: __( 'Lesson Metadata', 'sensei-lms' ),
description: __( 'Add lesson details such as complexity and length.', 'sensei-lms' ),
description: __(
'Add lesson details such as complexity and length.',
'sensei-lms'
),
...metadata,
edit,
save: () => {
return null;
}
},
};
48 changes: 29 additions & 19 deletions assets/blocks/lesson-metadata/lesson-metadata-edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
* WordPress dependencies
*/
import { InspectorControls } from '@wordpress/block-editor';
import {
PanelBody,
SelectControl,
} from '@wordpress/components';
import { PanelBody, SelectControl } from '@wordpress/components';
import { __, _n } from '@wordpress/i18n';

/**
Expand All @@ -23,10 +20,7 @@ import { COMPLEXITIES } from './constants';
const LessonMetadataEdit = ( props ) => {
const {
className,
attributes: {
complexity,
length,
},
attributes: { complexity, length },
setAttributes,
} = props;
return (
Expand All @@ -39,34 +33,50 @@ const LessonMetadataEdit = ( props ) => {
min={ 0 }
step={ 1 }
value={ length }
onChange={ length => setAttributes( { length } ) }
suffix={ _n( 'minute', 'minutes', length, 'sensei-lms' ) }
onChange={ ( newLength ) =>
setAttributes( { newLength } )
}
suffix={ _n(
'minute',
'minutes',
length,
'sensei-lms'
) }
/>

<SelectControl
label={ __( 'Complexity', 'sensei-lms' ) }
options={ COMPLEXITIES.map(
( { label, value } ) => ( { label, value } )
) }
options={ COMPLEXITIES.map( ( { label, value } ) => ( {
label,
value,
} ) ) }
value={ complexity }
onChange={ complexity => setAttributes( { complexity } ) }
onChange={ ( newComplexity ) =>
setAttributes( { newComplexity } )
}
/>
</PanelBody>
</InspectorControls>

<div className={ classnames( 'lesson-metadata', className ) }>
{ !! length && (
<span className="lesson-length">
{ __( 'Length', 'sensei-lms' ) + ': ' + length + ' ' + _n( 'minute', 'minutes', length, 'sensei-lms' ) }
{ __( 'Length', 'sensei-lms' ) +
': ' +
length +
' ' +
_n( 'minute', 'minutes', length, 'sensei-lms' ) }
</span>
) }

{ complexity && (
<span className="lesson-complexity">
{
__( 'Complexity', 'sensei-lms' ) + ': ' +
COMPLEXITIES.find( lessonComplexity => complexity === lessonComplexity.value )?.label
}
{ __( 'Complexity', 'sensei-lms' ) +
': ' +
COMPLEXITIES.find(
( lessonComplexity ) =>
complexity === lessonComplexity.value
)?.label }
</span>
) }
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ export const useUpdateQuizHasQuestionsMeta = ( clientId ) => {
.filter( ( block ) => ! isQuestionEmpty( block.attributes ) )
);

const { editedValue: quizHasQuestionsMeta } = useSelect(
( select ) => {
const editor = select( 'core/editor' );
return {
editedValue: editor.getEditedPostAttribute( 'meta' )[
META_KEY
],
};
}
);
const { editedValue: quizHasQuestionsMeta } = useSelect( ( select ) => {
const editor = select( 'core/editor' );
return {
editedValue: editor.getEditedPostAttribute( 'meta' )[ META_KEY ],
};
} );

const { editPost } = useDispatch( 'core/editor' );
const setQuizHasQuestionsMeta = useCallback(
Expand Down
3 changes: 2 additions & 1 deletion includes/blocks/class-sensei-lesson-metadata-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,13 @@ public function render( array $attributes, string $content ) : string {
$content .=
'<span class="lesson-length">' .
__( 'Length', 'sensei-lms' ) . ': ' .
// translators: placeholder is lesson length in minutes.
sprintf( _n( '%d minute', '%d minutes', $length, 'sensei-lms' ), $length ) .
'</span>';
}

if ( $complexity ) {
$complexities = Sensei()->lesson->lesson_complexities();
$complexities = Sensei()->lesson->lesson_complexities();
$lesson_complexity = $complexities[ $complexity ];

if ( $lesson_complexity ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function init_post_meta() {
*
* @param bool $allowed True if allowed to view the meta field by default, false otherwise.
* @param string $meta_key Meta key.
* @param int $id Lesson ID.
* @param int $post_id Lesson ID.
* @return bool Whether the user can edit the post meta.
*/
public function auth_callback( $allowed, $meta_key, $post_id ) {
Expand Down

0 comments on commit e8c7b8e

Please sign in to comment.