Skip to content

Commit

Permalink
Merge pull request #157 from itthinx/tested-3.2.1-6.6
Browse files Browse the repository at this point in the history
Tested 3.2.1 6.6
  • Loading branch information
itthinx authored Jul 20, 2024
2 parents 365dec4 + 759f01d commit fe38afd
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 197 deletions.
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
== Groups by itthinx - changelog.txt

= 3.2.1 =
* WordPress 6.6 compatible.
* Updates script dependencies for blocks.
* Fixes blocks not available (regression bug in 3.2.0).
* Unified store used by blocks, avoids duplicate definition and console warning.

= 3.2.0 =
* WordPress 6.6 compatible.
* Revised Welcome screen.
Expand Down
4 changes: 2 additions & 2 deletions groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Plugin Name: Groups
* Plugin URI: https://www.itthinx.com/plugins/groups
* Description: Groups provides group-based user membership management, group-based capabilities and content access control.
* Version: 3.2.0
* Version: 3.2.1
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: itthinx
Expand All @@ -34,7 +34,7 @@
if ( !defined( 'ABSPATH' ) ) {
exit;
}
define( 'GROUPS_CORE_VERSION', '3.2.0' );
define( 'GROUPS_CORE_VERSION', '3.2.1' );
define( 'GROUPS_FILE', __FILE__ );
if ( !defined( 'GROUPS_CORE_DIR' ) ) {
define( 'GROUPS_CORE_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
Expand Down
2 changes: 1 addition & 1 deletion lib/blocks/build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '73cee55169865cf1f2feac51d5c471f5');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => '638078029bd27e96b93f');
4 changes: 2 additions & 2 deletions lib/blocks/build/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/blocks/build/index.js

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions lib/blocks/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
{
"name": "groups-blocks",
"version": "2.14.0",
"version": "3.2.1",
"description": "Groups Blocks",
"main": "build/index.js",
"author": "itthinx",
"license": "GPL-3.0",
"devDependencies": {
"@wordpress/scripts": "^12.6.1"
"@wordpress/scripts": "^25.1.0"
},
"dependencies": {
"@wordpress/data": "^8.1.0",
"classnames": "^2.3.1",
"react-select": "^5.0.0"
},
"peerDependencies": {
"react" : "^18.0.0"
},
"scripts": {
"start": "wp-scripts start",
"build": "wp-scripts build",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@wordpress/data": "^6.0.0",
"classnames": "^2.3.1",
"react-select": "^4.3.1"
}
}
108 changes: 8 additions & 100 deletions lib/blocks/src/blocks/groups-member/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,100 +27,11 @@ import { __, _x, _n, sprintf } from '@wordpress/i18n';
import { InspectorControls, InnerBlocks } from '@wordpress/block-editor';
import { PanelBody, PanelRow, Spinner } from '@wordpress/components';
import apiFetch from '@wordpress/api-fetch';
import { store } from '../store';

// Import CSS.
import './editor.scss';

/**
* Default state - no groups selected.
*/
const DEFAULT_STATE = {
groups: {},
};

/**
* Actions object.
* Actions are payloads of information that send data from the application to the store.
* Plain JavaScript objects.
*/
const actions = {
// Action creator for the action called when settng a group by choosing from the options list.
setGroups( groups )
{
return {
type: 'SET_GROUPS',
groups,
};
},

receiveGroups( path )
{
return {
type: 'RECEIVE_GROUPS',
path,
};
},
};

/**
* Store
*/
const store = registerStore(
'groups/groups-blocks',
{
// The reducer is a pure function that takes the previous state and an action, and returns the next state.
reducer( state = DEFAULT_STATE, action )
{
switch ( action.type )
{
case 'SET_GROUPS':
return {
// To keep the reducer pure, state should not be mutated.
// Use object state operator to copy enumerabale properties into a new object instead of Object.assign().
...state,
groups: action.groups,
};
}
// Return the previous state - for when there's an unknown action.
return state;
},

actions,
// A selector accepts state and optional arguments and returns some value from state.
selectors:
{
receiveGroups( state )
{
const
{
groups
} = state;
return groups;
},
},
// Defines the execution flow behavior associated with a specific action type.
controls:
{
RECEIVE_GROUPS( action )
{
return apiFetch(
{
path: action.path
} );
},
},
// Side-effects for a selector. Used with data from an extrnal source.
resolvers:
{
* receiveGroups( state )
{
const groups = yield actions.receiveGroups( '/groups/groups-blocks/groups/' );
return actions.setGroups( groups );
},
},
}
);

/**
* Icon for the Groups Member block.
*/
Expand Down Expand Up @@ -163,10 +74,8 @@ registerBlockType(
icon: memberIcon, // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
category: 'groups', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
keywords: [ __( 'groups', 'groups' ), __( 'access', 'groups' ), __( 'members', 'groups' ) ],
attributes:
{
groups_select:
{
attributes: {
groups_select: {
type: 'string',
default: null
},
Expand Down Expand Up @@ -194,8 +103,7 @@ registerBlockType(
(
props => {

const
{
const {
attributes: { groups_select },
groups,
className,
Expand All @@ -214,9 +122,9 @@ registerBlockType(
}

// Show if the data is not loaded yet.
if ( !groups.length ) {
if ( ! groups.length ) {
return (
<p className={ className}>
<p className={className}>
<Spinner/>
{ __( 'Loading...', 'groups' ) }
</p>
Expand Down Expand Up @@ -244,8 +152,8 @@ registerBlockType(
</PanelRow>
</PanelBody>
</InspectorControls>,
<div className = { isSelected ? ( classnames( className ) + '__selected' ) : props.className }>
<div className = { classnames( className ) + '__inner-block' }>
<div className={ isSelected ? ( classnames( className ) + '__selected' ) : props.className }>
<div className={ classnames( className ) + '__inner-block' }>
<InnerBlocks/>
</div>
</div>
Expand Down
93 changes: 10 additions & 83 deletions lib/blocks/src/blocks/groups-non-member/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @package groups
* @since groups 2.8.0
*/

import Select from 'react-select';
import classnames from 'classnames';
import { registerStore, withSelect } from '@wordpress/data';
Expand All @@ -27,84 +27,11 @@ import { __, _x, _n, sprintf } from '@wordpress/i18n';
import { InspectorControls, InnerBlocks } from '@wordpress/block-editor';
import { PanelBody, PanelRow, Spinner } from '@wordpress/components';
import apiFetch from '@wordpress/api-fetch';
import { store } from '../store';

// Import CSS.
import './editor.scss';

/**
* Default state - no groups selected.
*/
const DEFAULT_STATE = {
groups: {},
};

/**
* Actions object.
* Actions are payloads of information that send data from the application to the store.
* Plain JavaScript objects.
*/
const actions = {
// Action creator for the action called when settng a group by choosing from the options list.
setGroups( groups ) {
return {
type: 'SET_GROUPS',
groups,
};
},

receiveGroups( path ) {
return {
type: 'RECEIVE_GROUPS',
path,
};
},
};

/**
* Store
*/
const store = registerStore(
'groups/groups-blocks',
{
// The reducer is a pure function that takes the previous state and an action, and returns the next state.
reducer( state = DEFAULT_STATE, action ) {
switch ( action.type ) {
case 'SET_GROUPS':
return {
// To keep the reducer pure, state should not be mutated.
// Use object state operator to copy enumerabale properties into a new object instead of Object.assign().
...state,
groups: action.groups,
};
}
// Return the previous state - for when there's an unknown action.
return state;
},

actions,
// A selector accepts state and optional arguments and returns some value from state.
selectors: {
receiveGroups( state ) {
const { groups } = state;
return groups;
},
},
// Defines the execution flow behavior associated with a specific action type.
controls: {
RECEIVE_GROUPS( action ) {
return apiFetch( { path: action.path } );
},
},
// Side-effects for a selector. Used with data from an extrnal source.
resolvers: {
* receiveGroups( state ) {
const groups = yield actions.receiveGroups( '/groups/groups-blocks/groups/' );
return actions.setGroups( groups );
},
},
}
);

/**
* Icon for the Groups Non-member Block.
*/
Expand Down Expand Up @@ -146,10 +73,10 @@ registerBlockType(
description: __( 'Hide content from group members', 'groups' ),
icon: nonMemberIcon, // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
category: 'groups', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
keywords: [__( 'groups', 'groups' ), __( 'access', 'groups' ), __( 'members', 'groups' ) ],
keywords: [ __( 'groups', 'groups' ), __( 'access', 'groups' ), __( 'members', 'groups' ) ],
attributes: {
groups_select: {
type: 'string',
type: 'string',
default: null
},
},
Expand Down Expand Up @@ -197,10 +124,10 @@ registerBlockType(
// Show if the data is not loaded yet.
if ( ! groups.length ) {
return (
<p className={className}>
<Spinner />
{ __( 'Loading...', 'groups' ) }
</p>
<p className={className}>
<Spinner/>
{ __( 'Loading...', 'groups' ) }
</p>
);
}

Expand All @@ -209,7 +136,7 @@ registerBlockType(
<PanelBody title={ __( 'Select Groups', 'groups' ) } className="block-inspector">
<PanelRow>
<label htmlFor="block-groups" className="groups-inspector__label">
{ __( 'Content will be shown to users that are not members of these groups:', 'groups' ) }
{ __( 'Content will be shown to users that are not members of these groups:', 'groups' ) }
</label>
</PanelRow>
<PanelRow>
Expand All @@ -220,7 +147,7 @@ registerBlockType(
onChange = { handleGroupsChange }
options = { groups }
isClearable
isMulti = 'true'
isMulti = 'true'
/>
</PanelRow>
</PanelBody>
Expand Down
Loading

0 comments on commit fe38afd

Please sign in to comment.