Skip to content

Connect Page Settings#649

Open
Akhill2020 wants to merge 4 commits intorevamp/AdminUI-MainBranchfrom
revamp/admin-ui
Open

Connect Page Settings#649
Akhill2020 wants to merge 4 commits intorevamp/AdminUI-MainBranchfrom
revamp/admin-ui

Conversation

@Akhill2020
Copy link
Copy Markdown
Contributor

@Akhill2020 Akhill2020 commented Mar 16, 2026

Summary by CodeRabbit

  • New Features

    • Added a new Connect page for streamlined Google API key setup with validation feedback and progress tracking.
    • Implemented API key visibility toggle and input validation with error/success states.
    • Added a welcome screen on first plugin activation.
    • Introduced UI overlay guidance when API key is not configured.
  • Documentation

    • Added design system showcase page for UI components and states.
  • Chores

    • Added Sass support and build scripts for stylesheet compilation.
    • Configured plugin activation redirect to Connect page.

Akhill2020 and others added 2 commits March 9, 2026 11:33
* Design system First draft

* Feedback changes

* feddback changes in css

* feedback changes

* required images

* make scss & local fonts

* input text css

* removed the dev api and enter random  key
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 16, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 173bb36f-6ee5-4c0f-a9eb-f40b7c471f5e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces a new admin Connect page for Google API key configuration with activation redirect, AJAX-based validation flow, design system assets, and supporting SCSS stylesheets. Includes build script updates for SCSS compilation and UI overlay masking for incomplete setup states.

Changes

Cohort / File(s) Summary
Build Configuration
.bin/esbuild.mjs, package.json, composer.json
Updated module import syntax from assert to with, added Sass devDependency, introduced SCSS build/dev scripts for admin UI CSS compilation.
Design System Assets
assets/design-system.html, assets/scss/design-system.scss
Created comprehensive design system showcase with typography, colors, buttons, inputs, progress circles, and component states; defined SCSS variables, utility classes, and base styles for UI components.
Connect Page UI
assets/scss/connect.scss, assets/js/admin.js
Added Connect page stylesheet with welcome screen, setup layout, responsive grid, and progress/state styling; implemented eye-toggle for API key input, AJAX validation flow, progress animation, and form submission handling.
Admin Page Integration
includes/admin/menus.php, includes/admin/assets.php, includes/admin/metaboxes/settings.php
Created Connect submenu item with welcome-screen logic, registered new CSS styles with design system dependency, localized AJAX data, and added API key validation UI overlay mask to settings metabox.
Admin Infrastructure
includes/admin/ajax.php, includes/functions/admin.php
Implemented Google API key validation AJAX endpoint with nonce/permission checks and HTTP request handling; created simcal_render_connect_page() function to render complete Connect page UI with progress tracking.
Plugin Initialization
includes/main.php, includes/installation.php
Added activation redirect option flag to skip welcome screen on first admin load, implemented maybe_redirect_to_connect() method to handle initial redirect to Connect page with capability and context checks.

Sequence Diagrams

sequenceDiagram
    participant Admin as Admin User
    participant Connect as Connect Page
    participant JS as JavaScript
    participant AJAX as AJAX Endpoint
    participant API as Google API

    Admin->>Connect: Visits Connect page
    Connect->>JS: Initializes validation UI
    Admin->>JS: Enters API key
    JS->>JS: Validates input
    Admin->>JS: Clicks validate button
    JS->>AJAX: POST validate_google_api_key (key, nonce)
    AJAX->>AJAX: Verify nonce & permission
    AJAX->>API: GET /calendar/v3/calendars/{id}
    API-->>AJAX: Response (200, 401, error)
    alt API Success
        AJAX-->>JS: {success: true}
        JS->>JS: Update UI success state
        JS->>JS: Animate progress circle
        JS->>JS: Mark step completed
    else API Key Not Supported
        AJAX-->>JS: {error: true, reason: api_keys_not_supported}
        JS->>JS: Show error message
    else API Error
        AJAX-->>JS: {error: true, message: error_text}
        JS->>JS: Display error feedback
    end
    JS->>Connect: Render final state
Loading
sequenceDiagram
    participant Plugin as Plugin Activation
    participant Install as Installation Hook
    participant Options as WP Options
    participant Admin as Admin Dashboard
    participant Redirect as Redirect Handler

    Plugin->>Install: Activate plugin
    Install->>Options: Set simple_calendar_redirect_to_connect = 1
    Admin->>Redirect: Load admin interface
    Redirect->>Redirect: Check user capability
    Redirect->>Options: Read redirect flag
    alt Flag set & not AJAX & not bulk
        Redirect->>Options: Delete redirect flag
        Redirect->>Admin: wp_safe_redirect to Connect page
    else
        Redirect->>Admin: Continue normal flow
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Design system First draft #648: Introduces identical design-system assets (design-system.html, design-system.scss) and corresponding build configuration changes in composer.json and package.json.

Suggested reviewers

  • rosinghal

Poem

🐰 A connect page hops into view,
With API keys and validation true,
Design tokens sparkle, progress circles gleam,
Welcome screens and AJAX dreams! ✨
Setup flows smoothly, masks appear—
Configuration magic, crystal clear! 🎨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 82.35% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title 'Connect Page Settings' accurately reflects the primary focus of this pull request, which introduces a comprehensive Connect page for API key setup and validation with related styling, validation logic, and UI components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch revamp/admin-ui

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (6)
assets/scss/design-system.scss (1)

602-624: Keyframe names use snake_case instead of kebab-case.

Stylelint flagged sc_btn_loading_spin and sc_btn_loading_scale as not following kebab-case convention. However, this appears intentional to maintain consistency with the sc_* naming pattern used throughout the design system. Consider adding a Stylelint exception for this file or these specific keyframes if the naming convention is deliberate.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/scss/design-system.scss` around lines 602 - 624, Stylelint is flagging
keyframe names sc_btn_loading_spin and sc_btn_loading_scale for using snake_case
instead of the project kebab-case convention; to fix, either rename these
`@keyframes` to kebab-case (e.g., sc-btn-loading-spin, sc-btn-loading-scale) and
update any references, or add a Stylelint exception for these selectors in the
design-system.scss (or for this file) so the sc_* pattern is allowed; locate the
`@keyframes` definitions (sc_btn_loading_spin and sc_btn_loading_scale) and apply
the chosen approach consistently across their usages.
assets/css/admin-post-settings.scss (1)

24-34: Verify Poppins font availability in admin context.

The .simcal-settings-mask__message class references font-family: Poppins, sans-serif, but this file doesn't import the Poppins font. The design system (design-system.scss) defines it as 'SC Poppins' via @font-face.

Consider using the design system's font variable or ensure Poppins is loaded on the calendar post type edit screen.

♻️ Suggested fix
 .simcal-settings-mask__message {
-	font-family: Poppins, sans-serif;
+	font-family: 'SC Poppins', Poppins, sans-serif;
 	font-weight: 600;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/css/admin-post-settings.scss` around lines 24 - 34, The
.simcal-settings-mask__message rule references Poppins but the SC Poppins
`@font-face` defined in design-system.scss isn't imported here; either switch the
font-family to use the design system's exported font (e.g., the SC Poppins
variable or the 'SC Poppins' name defined in design-system.scss) or import
design-system.scss into assets/css/admin-post-settings.scss and ensure that
design-system styles are enqueued for the calendar post type edit screen in the
admin. Update the .simcal-settings-mask__message declaration to use the
design-system font identifier and confirm the admin stylesheet loads the
design-system.scss so the font-face is available in the admin context.
assets/design-system.html (1)

507-586: Consider removing or enabling the commented-out JavaScript.

The commented-out JavaScript block contains interactive functionality for password toggle and loading button demos. If this showcase page is intended for active use, consider enabling the code. Otherwise, if it's not needed, removing it would reduce file size and avoid confusion.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/design-system.html` around lines 507 - 586, The commented-out script
block containing initSquareToggle and initLoadingButtons should either be
removed or re-enabled; locate the IIFE that defines initSquareToggle,
initLoadingButtons and the related selectors (sc_icon--square,
sc_input_password_toggle, data-sc-loading-btn) and either 1) uncomment the
entire immediately-invoked function so the password toggle and loading-button
demos work, or 2) delete the whole commented block to reduce file size and avoid
confusion—make sure to keep any necessary ARIA/title logic inside
initSquareToggle if you re-enable it.
assets/js/admin.js (1)

707-710: Consider reducing the auto-submit delay.

The 10-second delay before auto-submitting the form after successful validation may feel sluggish to users. A shorter delay (e.g., 1.5-2 seconds) would provide enough time for the success animation while improving perceived responsiveness.

♻️ Proposed change
 							$form.data('scValidated', true);
 							submitTimer = setTimeout(function () {
 								if ($btn.length) $btn.prop('disabled', false);
 								$form.trigger('submit');
-							}, 10000);
+							}, 1500);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/js/admin.js` around lines 707 - 710, The current auto-submit uses a
10000ms timeout which feels sluggish; change the timeout passed to setTimeout in
the submitTimer block (the code creating submitTimer that re-enables $btn and
triggers $form.submit()) to a shorter value such as 1500–2000ms so the success
animation can complete but the form submits faster; locate the setTimeout call
that references submitTimer, $btn, and $form and replace 10000 with the chosen
lower millisecond value.
assets/scss/connect.scss (1)

441-441: Use design system token instead of hardcoded hex color.

The color #1d73be is hardcoded here while other styles consistently use design system tokens like var(--sc-color-blue). This inconsistency could cause maintenance issues if the color palette changes.

♻️ Proposed fix
 .sc_connect_pro_list_icon {
   width: 20px;
   height: 20px;
   border-radius: 50%;
-  background: `#1d73be`;
+  background: var(--sc-color-blue);
   display: inline-flex;
   align-items: center;
   justify-content: center;
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@assets/scss/connect.scss` at line 441, Replace the hardcoded background color
"#1d73be" with the design system token (for example use var(--sc-color-blue)) in
the CSS rule where background: `#1d73be`; is set so the style uses the shared
token; ensure you remove the hex and use the token consistently and add a
fallback if needed (e.g., background: var(--sc-color-blue, `#1d73be`)).
includes/functions/admin.php (1)

386-393: Potential race condition in completion timestamp tracking.

If two requests occur simultaneously when $has_published_calendar becomes true, both could call update_option(). While not critical (the timestamp would just be slightly different), consider using add_option() with autoload or checking if the option already has a non-zero value before updating.

♻️ Proposed fix
 	// Track when setup first reached 100% so we can hide the progress card after a day.
 	$completed_timestamp = (int) get_option('simple_calendar_connect_setup_completed_at', 0);
-	if ($has_published_calendar && $completed_timestamp <= 0) {
+	if ($has_published_calendar && $completed_timestamp === 0) {
 		$completed_timestamp = time();
-		update_option('simple_calendar_connect_setup_completed_at', $completed_timestamp);
+		// Only set if not already set (avoid race condition)
+		add_option('simple_calendar_connect_setup_completed_at', $completed_timestamp, '', 'no');
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@includes/functions/admin.php` around lines 386 - 393, When setting the
completion time for simple_calendar_connect_setup_completed_at, avoid blindly
calling update_option() on concurrent requests: first read the current value
with get_option('simple_calendar_connect_setup_completed_at', 0) into
$completed_timestamp and only set it if it's <= 0; better yet try
add_option('simple_calendar_connect_setup_completed_at', $completed_timestamp,
'', 'no') (or equivalent add_option call) when $has_published_calendar is true
and only fall back to update_option() if add_option indicated the option did not
already exist—this ensures the first writer wins and prevents race updates from
stomping each other while preserving the existing logic around
$completed_timestamp and $hide_progress_after.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.bin/esbuild.mjs:
- Line 3: The import line "import pkg from '../package.json' with { type: 'json'
}" uses the newer "with" JSON-import syntax unsupported by Node.js >=18.15.0 and
<18.20.0; fix by either raising the declared minimum Node version in
package.json to ">=18.20.0" (or ">=18.20.5") or revert the import to the
compatible assert syntax ("import pkg from '../package.json' assert { type:
'json' }") so the pkg import works across the declared Node range.

In `@assets/js/admin.js`:
- Around line 696-732: The `api_keys_not_supported` branch treats the response
as success but omits showing the Add Calendar button; update the else-if branch
handling `res.data.reason === 'api_keys_not_supported'` to mirror the success
branch by calling animateProgressToApiKeyCompleted(), showing $msgWrap and
$msgSuccess, adding the sc_input--success class to $wrap, and also calling
$('#sc_connect_add_calendar_btn').show(); ensure the same $btn state changes,
$form.data('scValidated', true) and the submitTimer behavior are preserved so
the UI feedback matches the success path (see animateProgressToApiKeyCompleted,
$wrap, $msgWrap, $msgSuccess, $btn, $form, submitTimer).

In `@assets/scss/design-system.scss`:
- Around line 1376-1384: The .sc_ds_setup_card rule uses an undefined CSS
variable --sc-spacing-40 for gap; either add a new spacing token named
--sc-spacing-40 in the spacing variables block (next to
--sc-spacing-0..--sc-spacing-25) with the desired size, or change the gap to an
existing defined token (e.g., replace --sc-spacing-40 with an appropriate
existing variable such as --sc-spacing-25 or another defined spacing variable);
update any other references if you add the new token so spacing variables remain
consistent.

In `@includes/admin/menus.php`:
- Around line 142-145: The $video_url variable created via
apply_filters('simple_calendar_connect_welcome_video_url',
'https://www.youtube.com/embed/VIDEO_ID') is unused; either remove that
assignment entirely or replace the static placeholder image output with an
embedded video using $video_url (for example render an iframe whose src is
$video_url). Update the code around the placeholder image rendering in the same
template so the variable is actually used if you choose the embed approach, or
simply delete the $video_url line if no video is required.

In `@includes/functions/admin.php`:
- Line 394: Remove the unused local nonce variable by deleting the line that
assigns $validate_nonce =
wp_create_nonce('simcal_connect_validate_google_api_key') in
includes/functions/admin.php; ensure no other code in that file references
$validate_nonce and rely on the existing AJAX nonce provided by
wp_localize_script in includes/admin/assets.php (the localized key created
around the AJAX validation code).

In `@package.json`:
- Line 40: The npm script build:admin-ui-css currently passes multiple file
paths without source:destination pairs to the Sass CLI; update the script so
each compilation is a source:destination pair by changing the two entries to use
colons (e.g. design-system.scss:assets/generated/design-system.css and
connect.scss:assets/generated/connect.css) so Sass receives proper
source:destination arguments for both design-system and connect builds.

---

Nitpick comments:
In `@assets/css/admin-post-settings.scss`:
- Around line 24-34: The .simcal-settings-mask__message rule references Poppins
but the SC Poppins `@font-face` defined in design-system.scss isn't imported here;
either switch the font-family to use the design system's exported font (e.g.,
the SC Poppins variable or the 'SC Poppins' name defined in design-system.scss)
or import design-system.scss into assets/css/admin-post-settings.scss and ensure
that design-system styles are enqueued for the calendar post type edit screen in
the admin. Update the .simcal-settings-mask__message declaration to use the
design-system font identifier and confirm the admin stylesheet loads the
design-system.scss so the font-face is available in the admin context.

In `@assets/design-system.html`:
- Around line 507-586: The commented-out script block containing
initSquareToggle and initLoadingButtons should either be removed or re-enabled;
locate the IIFE that defines initSquareToggle, initLoadingButtons and the
related selectors (sc_icon--square, sc_input_password_toggle,
data-sc-loading-btn) and either 1) uncomment the entire immediately-invoked
function so the password toggle and loading-button demos work, or 2) delete the
whole commented block to reduce file size and avoid confusion—make sure to keep
any necessary ARIA/title logic inside initSquareToggle if you re-enable it.

In `@assets/js/admin.js`:
- Around line 707-710: The current auto-submit uses a 10000ms timeout which
feels sluggish; change the timeout passed to setTimeout in the submitTimer block
(the code creating submitTimer that re-enables $btn and triggers $form.submit())
to a shorter value such as 1500–2000ms so the success animation can complete but
the form submits faster; locate the setTimeout call that references submitTimer,
$btn, and $form and replace 10000 with the chosen lower millisecond value.

In `@assets/scss/connect.scss`:
- Line 441: Replace the hardcoded background color "#1d73be" with the design
system token (for example use var(--sc-color-blue)) in the CSS rule where
background: `#1d73be`; is set so the style uses the shared token; ensure you
remove the hex and use the token consistently and add a fallback if needed
(e.g., background: var(--sc-color-blue, `#1d73be`)).

In `@assets/scss/design-system.scss`:
- Around line 602-624: Stylelint is flagging keyframe names sc_btn_loading_spin
and sc_btn_loading_scale for using snake_case instead of the project kebab-case
convention; to fix, either rename these `@keyframes` to kebab-case (e.g.,
sc-btn-loading-spin, sc-btn-loading-scale) and update any references, or add a
Stylelint exception for these selectors in the design-system.scss (or for this
file) so the sc_* pattern is allowed; locate the `@keyframes` definitions
(sc_btn_loading_spin and sc_btn_loading_scale) and apply the chosen approach
consistently across their usages.

In `@includes/functions/admin.php`:
- Around line 386-393: When setting the completion time for
simple_calendar_connect_setup_completed_at, avoid blindly calling
update_option() on concurrent requests: first read the current value with
get_option('simple_calendar_connect_setup_completed_at', 0) into
$completed_timestamp and only set it if it's <= 0; better yet try
add_option('simple_calendar_connect_setup_completed_at', $completed_timestamp,
'', 'no') (or equivalent add_option call) when $has_published_calendar is true
and only fall back to update_option() if add_option indicated the option did not
already exist—this ensures the first writer wins and prevents race updates from
stomping each other while preserving the existing logic around
$completed_timestamp and $hide_progress_after.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 51b70c3f-7a81-408a-8c84-269f84d32c4f

📥 Commits

Reviewing files that changed from the base of the PR and between ff7a05b and 3cc7a7d.

⛔ Files ignored due to path filters (23)
  • assets/fonts/Inter-Variable-Italic.ttf is excluded by !**/*.ttf
  • assets/fonts/Inter-Variable.ttf is excluded by !**/*.ttf
  • assets/images/pages/connect/check.svg is excluded by !**/*.svg
  • assets/images/pages/connect/checked.svg is excluded by !**/*.svg
  • assets/images/pages/connect/clapperboard.svg is excluded by !**/*.svg
  • assets/images/pages/connect/close.svg is excluded by !**/*.svg
  • assets/images/pages/connect/copy-white.svg is excluded by !**/*.svg
  • assets/images/pages/connect/copy.svg is excluded by !**/*.svg
  • assets/images/pages/connect/crown.svg is excluded by !**/*.svg
  • assets/images/pages/connect/document.svg is excluded by !**/*.svg
  • assets/images/pages/connect/eye-hide-white.svg is excluded by !**/*.svg
  • assets/images/pages/connect/eye-hide.svg is excluded by !**/*.svg
  • assets/images/pages/connect/eye-white.svg is excluded by !**/*.svg
  • assets/images/pages/connect/eye.svg is excluded by !**/*.svg
  • assets/images/pages/connect/headphone.svg is excluded by !**/*.svg
  • assets/images/pages/connect/loading.svg is excluded by !**/*.svg
  • assets/images/pages/connect/logo.png is excluded by !**/*.png
  • assets/images/pages/connect/question-white-small.svg is excluded by !**/*.svg
  • assets/images/pages/connect/question-white.svg is excluded by !**/*.svg
  • assets/images/pages/connect/question.svg is excluded by !**/*.svg
  • assets/images/pages/connect/star.svg is excluded by !**/*.svg
  • assets/images/pages/connect/warning.svg is excluded by !**/*.svg
  • assets/images/pages/connect/welcome-video-placeholder.png is excluded by !**/*.png
📒 Files selected for processing (15)
  • .bin/esbuild.mjs
  • assets/css/admin-post-settings.scss
  • assets/design-system.html
  • assets/js/admin.js
  • assets/scss/connect.scss
  • assets/scss/design-system.scss
  • composer.json
  • includes/admin/ajax.php
  • includes/admin/assets.php
  • includes/admin/menus.php
  • includes/admin/metaboxes/settings.php
  • includes/functions/admin.php
  • includes/installation.php
  • includes/main.php
  • package.json

@Akhill2020 Akhill2020 changed the base branch from main to revamp/AdminUI-MainBranch March 16, 2026 05:22
@Akhill2020 Akhill2020 changed the title Revamp/admin UI Connect Page Settings Mar 16, 2026
@Akhill2020 Akhill2020 requested a review from rosinghal March 16, 2026 05:23
); ?>
</p>

<a href="https://simplecalendar.io/addons/google-calendar-pro/" target="_blank" class="sc_connect_pro_link">
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use utm param link

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in backlog will add for all the places in last.

aria-controls="sc_google_api_key"
title="<?php esc_attr_e('Show API key', 'google-calendar-events'); ?>"
>
<img src="<?php echo esc_url($assets_base . 'eye.svg'); ?>" alt="" class="sc_input_square_show" hidden />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hidden should be removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants