Skip to content

Commit

Permalink
feat!: refactor Admin UX/UI (#144)
Browse files Browse the repository at this point in the history
* dev: refactor application frame

* dev: simplify screens + cleanup

* dev: refactor field controls

* dev: modularize styles

* dev: add error boundary

* core: relocate `layout` to `components`

* chore: cleanup npm deps

* feat!: refactor settings handling

* chore: cleanup

* chore: remove barrel files

* tests: backfill main/autoloader tests

* chore: fix `default_login_options_schema()` return type

* chore: cleanup RestController and add tests

* chore: update deps

* chore: cleanup SettingsRegistry and add tests

* chore: cleanup and backfill Settings tests

* chore: phpstan

* tests: cleanup SettingsTest

* chore: cleanup Upgrade and add tests

* tests: phpcbf

* chore: post rebase cleanup

* tests: test provider settings

* chore: update changelog

* chore: update NPM deps

* fix: use `react` instead of wordpress-element

* chore: bump minimum PHP version

* ci: fix permissions

* ci: fix env creation and tests
  • Loading branch information
justlevine authored Oct 20, 2024
1 parent bdef8b8 commit 7cddbef
Show file tree
Hide file tree
Showing 100 changed files with 19,444 additions and 38,339 deletions.
4 changes: 4 additions & 0 deletions .docker/init-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,9 @@ chmod +x ./bin/install-test-env.sh

bash -c "./bin/install-test-env.sh"

echo "Setting permissions"
chmod -R 777 "$WORDPRESS_ROOT_DIR/wp-content/plugins/$PLUGIN_SLUG"

# Go back to the root directory
cd "$WORDPRESS_ROOT_DIR"

16 changes: 2 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module.exports = {
extends: [
'plugin:@wordpress/eslint-plugin/recommended',
'plugin:you-dont-need-lodash-underscore/compatible',
],
extends: [ 'plugin:@wordpress/eslint-plugin/recommended' ],
globals: {
fetchMock: true,
IntersectionObserver: 'readonly',
Expand Down Expand Up @@ -65,19 +62,10 @@ module.exports = {
],
},
overrides: [
{
files: [ '**/bin/**.js' ],
rules: {
'you-dont-need-lodash-underscore/omit': 'off',
},
},
{
files: [ '*.ts', '*.tsx' ],
parser: '@typescript-eslint/parser',
extends: [
'plugin:you-dont-need-lodash-underscore/compatible',
'plugin:@typescript-eslint/recommended',
],
extends: [ 'plugin:@typescript-eslint/recommended' ],
rules: {
'prefer-rest-params': 'off',
'@typescript-eslint/no-explicit-any': 'error',
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/integration-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,12 @@ jobs:
strategy:
matrix:
php: ["8.2", "8.1", "8.0"]
wordpress: ["6.6", "6.5", "6.4", "6.3", "6.2", "6.1", "6.0" ]
wordpress: ["6.6", "6.5", "6.4", "6.3", "6.2"]
include:
- php: "8.2"
wordpress: "6.6"
coverage: 1
# Test old versions against PHP 8.0
- php: "7.4"
wordpress: "6.1"
- php: "7.4"
wordpress: "6.0"
exclude:
# Old WP versions that dont support newer PHP versions
- php: "8.2"
wordpress: "6.0"
# New WP versions that dont support older PHP versions
- php: "8.0"
wordpress: "6.6"
Expand Down
2 changes: 1 addition & 1 deletion .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Tests for WordPress version compatibility.
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties
-->
<config name="minimum_wp_version" value="6.0"/>
<config name="minimum_wp_version" value="6.2"/>

<!-- Rules: WPGraphQL Coding Standards -->
<!-- https://github.com/AxeWP/WPGraphQL-Coding-Standards/WPGraphQL/ruleset.xml -->
Expand Down
12 changes: 10 additions & 2 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
"declaration-block-no-duplicate-properties": null,
"declaration-property-unit-allowed-list": null,
"font-weight-notation": null,
"max-line-length": null,
"no-descending-specificity": null,
"no-duplicate-selectors": null,
"rule-empty-line-before": null,
"selector-class-pattern": null,
"value-keyword-case": null
"value-keyword-case": null,
"selector-pseudo-class-no-unknown": [
true,
{
"ignorePseudoClasses": [
"global",
"export"
]
}
]
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

- feat!: Refactor Settings handling and storage.
- feat: Refactor admin package.
- feat: Add Upgrader class for handling plugin upgrades.
- chore!: Bump minimum WordPress version to 6.2.
- chore!: Remove `vendor`, `vendor-prefixed`, and `build` directories from the repository.
- chore: Update Composer dependencies.
- chore: Update NPM dependencies.
- chore: Update Strauss to v0.19.4.
- ci!: Update ci scripts and commands, docker configuration, and env variables.
- tests!: Update codeception tests to use `wp-browser` > v3.5.x.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This plugin is inspired by and aims to replace <a href="https://github.com/wp-gr
## System Requirements

* PHP 7.4-8.2+
* WordPress 6.0+
* WordPress 6.2+
* WPGraphQL 1.14.0+

## Quick Install
Expand Down
6 changes: 4 additions & 2 deletions activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace WPGraphQL\Login;

use WPGraphQL\Login\Admin\Upgrade\UpgradeRegistry;

/**
* Runs when the plugin is activated.
*
Expand All @@ -20,7 +22,7 @@ function activation_callback(): callable {
// Runs when the plugin is activated.
do_action( 'graphql_login_activate' );

// store the current version of the plugin.
update_option( 'wp_graphql_login_version', WPGRAPHQL_LOGIN_VERSION );
// Run any upgrade routines.
UpgradeRegistry::do_upgrades();
};
}
13 changes: 4 additions & 9 deletions bin/install-test-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ set -e
ORIGINAL_PATH=$(pwd)
BASEDIR=$(dirname "$0")

# Include common environment variables and functions
source "${BASEDIR}/_lib.sh"

# Common variables.
WP_DEBUG=${WP_DEBUG:-true}
SCRIPT_DEBUG=${SCRIPT_DEBUG:-true}
WP_VERSION=${WP_VERSION:-"latest"}

# Include common environment variables and functions
source "${BASEDIR}/_lib.sh"

##
# Install the database.
##
Expand Down Expand Up @@ -89,7 +89,7 @@ configure_wordpress() {

SITE_TITLE=${WORDPRESS_SITE_TITLE:-"Headless Login Tests"}

wp core install --title="$SITE_TITLE" --admin_user="$WORDPRESS_ADMIN_USER" --admin_password="$WORDPRESS_ADMIN_PASSWORD" --admin_email="$WORDPRESS_ADMIN_EMAIL" --skip-email --url="$WORDRESS_URL" --allow-root
wp core install --title="$SITE_TITLE" --admin_user="$WORDPRESS_ADMIN_USER" --admin_password="$WORDPRESS_ADMIN_PASSWORD" --admin_email="$WORDPRESS_ADMIN_EMAIL" --skip-email --url="$WORDPRESS_URL" --allow-root

echo -e "$(status_message "Running WordPress version: $(wp core version --allow-root) at $(wp option get home --allow-root)")"
}
Expand Down Expand Up @@ -141,11 +141,6 @@ setup_plugin() {

# Build the plugin
npm run build

# Fix file permissions
# Set permissions to www-data
echo "Setting permissions"
chmod -R 777 .
}

post_setup() {
Expand Down
29 changes: 10 additions & 19 deletions deactivation.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace WPGraphQL\Login;

use WPGraphQL\Login\Admin\SettingsRegistry;
use WPGraphQL\Login\Admin\Upgrade\AbstractUpgrade;

/**
* Runs when WPGraphQL is de-activated.
*
Expand Down Expand Up @@ -42,30 +45,18 @@ function delete_data(): void {
return;
}

// Delete plugin version.
delete_option( 'wp_graphql_login_version' );

// Initialize the settings API.
$settings = \WPGraphQL\Login\Admin\Settings::get_all_settings();
$options = array_merge(
[ AbstractUpgrade::VERSION_OPTION_KEY ],
array_keys( SettingsRegistry::get_all() ),
);

if ( empty( $settings ) ) {
if ( empty( $options ) ) {
return;
}

// Get all the setting keys across various groups.
$settings = array_reduce(
$settings,
static function ( $carry, $item ) {
return array_merge( $carry, array_keys( $item ) );
},
[]
);

// Loop over the registered settings fields and delete the options.
if ( ! empty( $settings ) && is_array( $settings ) ) {
foreach ( array_keys( $settings ) as $option_name ) {
delete_option( $option_name );
}
foreach ( $options as $option ) {
delete_option( $option );
}

// Fire an action when data is deleted.
Expand Down
17 changes: 11 additions & 6 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
declare let __webpack_public_path__: string;

declare module '*.svg' {
import * as React from 'react';
import * as React from 'react';

export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>;
export const ReactComponent: React.FunctionComponent<
React.SVGProps< SVGSVGElement > & { title?: string }
>;

const src: string;
export default src;
const src: string;
export default src;
}

declare module '*.scss' {
const content: Record< string, string >;
export default content;
}
Loading

0 comments on commit 7cddbef

Please sign in to comment.