diff --git a/CHANGELOG.md b/CHANGELOG.md index 369b394..3cf5125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ each change under the current top section as you work. ## [1.3.1] ### Added -- An **Account** block (`[us_account]`) showing who is signed in — their name, their email, the students they book for if that is anyone besides themselves — and a **Sign out** link. Signing out returns to the login page chosen in the block, or to the page the visitor was already on when none is set, so putting it in a site header does not also move people somewhere. To a signed-out visitor it shows a **Sign in** link when a login page is chosen, and nothing at all when one is not: a panel about who is signed in has nothing to tell a stranger, and a notice they cannot act on is just clutter in a header. +- An **Account** block (`[us_account]`) showing who is signed in — their name and their email — and a **Sign out** link. Signing out returns to the login page chosen in the block, or to the page the visitor was already on when none is set, so putting it in a site header does not also move people somewhere. To a signed-out visitor it shows a **Sign in** link when a login page is chosen, and nothing at all when one is not: a panel about who is signed in has nothing to tell a stranger, and a notice they cannot act on is just clutter in a header. ### Changed - A student's **name and birth year are now required**, marked in the form the same way a required registration question is and enforced on the server whichever way they were submitted. On signup the requirement applies only once the parent/guardian box is ticked, so registering for yourself is unaffected. A student block you have started filling in is now reported back to you rather than silently dropped when the name is missing — only a completely untouched spare block is still ignored. diff --git a/assets/css/frontend.css b/assets/css/frontend.css index 02a5ee3..75ab2db 100644 --- a/assets/css/frontend.css +++ b/assets/css/frontend.css @@ -538,8 +538,7 @@ font-weight: 600; } -.us-account-email, -.us-account-students { +.us-account-email { display: block; font-size: 0.9em; opacity: 0.75; diff --git a/assets/js/blocks.js b/assets/js/blocks.js index dcaf81b..8971ce0 100644 --- a/assets/js/blocks.js +++ b/assets/js/blocks.js @@ -310,7 +310,7 @@ { name: 'us-scheduler/account', title: __('Account', 'unsupervised-schedular'), - description: __('Shows who is signed in, who they book for, and a sign out link. Renders nothing for signed-out visitors unless a login page is chosen.', 'unsupervised-schedular'), + description: __('Shows the name and email of whoever is signed in, with a sign out link. Renders nothing for signed-out visitors unless a login page is chosen.', 'unsupervised-schedular'), icon: 'admin-users', keywords: ['account', 'sign out', 'log out', 'signed in', 'profile'], shortcode: 'us_account', diff --git a/docs/features/editor-blocks.md b/docs/features/editor-blocks.md index c30a16d..51d826f 100644 --- a/docs/features/editor-blocks.md +++ b/docs/features/editor-blocks.md @@ -142,7 +142,6 @@ header is noise that cannot be acted on, so: - **Login page chosen** → a single **Sign in** link. Signed in, it shows the display name (`Auth\UserName::format()`, so a username -is never exposed), the account email, a **Sign out** link, and — only on an -account that books for someone other than itself — the students it books for. -Signing out returns to the chosen login page, or to the current page when there +is never exposed), the account email, and a **Sign out** link — deliberately +nothing else. Signing out returns to the chosen login page, or to the current page when there is none, so a header sign-out does not also navigate the visitor somewhere. diff --git a/src/Auth/AccountPage.php b/src/Auth/AccountPage.php index 1ace546..3e89637 100644 --- a/src/Auth/AccountPage.php +++ b/src/Auth/AccountPage.php @@ -3,7 +3,6 @@ declare(strict_types=1); namespace Unsupervised\Schedular\Auth; -use Unsupervised\Schedular\Guardian\GuardianService; use Unsupervised\Schedular\Val; /** @@ -15,8 +14,6 @@ use Unsupervised\Schedular\Val; */ class AccountPage { - public function __construct( private GuardianService $guardians ) {} - /** * Renders the account shortcode/block output. * @@ -55,16 +52,6 @@ class AccountPage { $name = UserName::format( $user, get_current_user_id() ); $email = $user->user_email; - // Whose lessons this account books, when that is more than just their own. - // A parent's first question on seeing "signed in as Grace" is whether this - // is the account their children's lessons are on. - $students = []; - foreach ( $this->guardians->bookableStudents( get_current_user_id() ) as $student ) { - if ( ! $student['is_self'] ) { - $students[] = $student['name']; - } - } - // Back to where they were, so signing out of a header link does not also // navigate them somewhere. The login page is the better landing spot when // one is configured, since the current page may be members-only. diff --git a/src/BlockPreview.php b/src/BlockPreview.php index 9f5fd1d..c1c3f65 100644 --- a/src/BlockPreview.php +++ b/src/BlockPreview.php @@ -220,18 +220,10 @@ class BlockPreview { '
', self::note( __( 'Editor preview — each visitor sees their own account here.', 'unsupervised-schedular' ) ), esc_html__( 'Grace Hopper', 'unsupervised-schedular' ), esc_html__( 'grace@example.com', 'unsupervised-schedular' ), - esc_html( - sprintf( - /* translators: %s: comma-separated list of the students this account books for. */ - __( 'Booking for %s', 'unsupervised-schedular' ), - __( 'Ada, Alan', 'unsupervised-schedular' ) - ) - ), esc_html__( 'Sign out', 'unsupervised-schedular' ) ); } diff --git a/src/Plugin.php b/src/Plugin.php index fa65c95..394f92e 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -100,7 +100,7 @@ class Plugin { $registrationPage = new RegistrationPage( $invites, $policies, $policyVersions, $acceptances, $settings, $registrationMailer, $questions, $answers, $groupAccess, $guardians ); $groupClassPage = new GroupClassPage( $guardians ); $familyPage = new FamilyPage( $guardians, $questions, $answers ); - $accountPage = new AccountPage( $guardians ); + $accountPage = new AccountPage(); ( new ScheduledBillingRunner( $paymentService, $bookings, $enrollments, $offerings, new PaymentDueMailer(), $guardians ) )->register(); diff --git a/templates/frontend/account-page.php b/templates/frontend/account-page.php index 3dcd446..b94a444 100644 --- a/templates/frontend/account-page.php +++ b/templates/frontend/account-page.php @@ -8,7 +8,6 @@ if (! defined('ABSPATH')) { /** * @var string $name Display name of the signed-in visitor. * @var string $email Their account email. - * @var list- -
- - diff --git a/tests/Unit/Auth/AccountPageTest.php b/tests/Unit/Auth/AccountPageTest.php index b1a672c..a6b8708 100644 --- a/tests/Unit/Auth/AccountPageTest.php +++ b/tests/Unit/Auth/AccountPageTest.php @@ -6,20 +6,17 @@ namespace Unsupervised\Schedular\Tests\Unit\Auth; use Brain\Monkey\Functions; use Mockery; use Unsupervised\Schedular\Auth\AccountPage; -use Unsupervised\Schedular\Guardian\GuardianService; use Unsupervised\Schedular\Tests\Unit\TestCase; class AccountPageTest extends TestCase { - private GuardianService&Mockery\MockInterface $guardians; private AccountPage $page; protected function setUp(): void { parent::setUp(); - $this->guardians = Mockery::mock(GuardianService::class); - $this->page = new AccountPage($this->guardians); + $this->page = new AccountPage(); Functions\when('is_user_logged_in')->justReturn(true); Functions\when('get_current_user_id')->justReturn(5); @@ -47,16 +44,8 @@ class AccountPageTest extends TestCase return $user; } - /** @param list