Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Check for version control, display notice #145

Merged
merged 39 commits into from
May 1, 2023

Conversation

mike-day
Copy link
Contributor

@mike-day mike-day commented Apr 20, 2023

This PR adds a dismissible notice in App if a .git folder is not found in the currently active theme directory:

Screenshot 2023-05-01 at 11 43 32 AM


Initial spike questions:

  1. Should the notice be dismissible? If so, should the dismissed state persist for a given theme? -> both items done
  2. Should the notice should also be shown in Editor? -> notice only shown in App
  3. Should .svn or .hg be included in the check? -> not for this version
  4. What helper guide should the helper link point to? -> deferred

Note about helper link deferral

While it would be a good idea to add a link to a basic guide for using git with a WordPress theme, finding a place to host that article will hold up the merging of this PR. A helper can link can be added in the future.


To-do

  • Make the dismissed notice state persist for a given theme
  • Translate VersionControlNotice strings
  • Add basic tests for get-version-control wp-module

How to test

  1. Checkout the branch
  2. Activate a theme with no .git folder in the directory
  3. The notice should display
  4. Dismiss the notice and refresh the page
  5. No notice should display (the dismissed state persisted)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With a light refactor to pass in versionControl and themeName as props, this component could be a good candidate for moving to common if we do something like #141.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea!

@mike-day mike-day requested a review from kienstra April 20, 2023 16:11
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

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

Hi @mike-day,
This approach is good, and it works:

Screenshot 2023-04-20 at 10 27 38 AM

I didn't comment on low-level details.

wp-modules/get-version-control/get-version-control.php Outdated Show resolved Hide resolved
@mike-day mike-day changed the title [SPIKE] Check for version control, display notice Check for version control, display notice Apr 27, 2023
@mike-day mike-day marked this pull request as ready for review April 27, 2023 17:44
@kienstra
Copy link
Contributor

Cool, looking at this now!

@mike-day mike-day requested a review from kienstra April 27, 2023 17:46
Copy link
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

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

Hi @mike-day,
Really nice work, the notice works well, and you figured out how to test a filesystem lookup! 🚀

Screenshot 2023-04-27 at 12 29 30 PM

Some suggestions below to make this even simpler.

wp-modules/app/js/src/components/Patterns/index.tsx Outdated Show resolved Hide resolved
wp-modules/app/js/src/hooks/useVersionControl.ts Outdated Show resolved Hide resolved
wp-modules/get-version-control/get-version-control.php Outdated Show resolved Hide resolved
wp-modules/api-data/api-data.php Outdated Show resolved Hide resolved
wp-modules/app/js/src/hooks/useVersionControl.ts Outdated Show resolved Hide resolved
wp-modules/app/app.php Outdated Show resolved Hide resolved
@kienstra
Copy link
Contributor

kienstra commented Apr 27, 2023

Also, maybe the message:

No version control detected for this theme. Learn how to set up git for your theme here: [Git Guide](https://wpengine.com/support/git/).

…could also mention what it means for the user, that their patterns will be deleted if they update the theme.

@mike-day
Copy link
Contributor Author

Also, maybe the message:

No version control detected for this theme. Learn how to set up git for your theme here: [Git Guide](https://wpengine.com/support/git/).

…could also mention what it means for the user, that their patterns will be deleted if they update the theme.

@kienstra UX helped tweak this message for the changes applied in 1463614!

* @param string $version_control The version control directory to check.
* @return boolean
*/
function check_version_control_notice_should_show( $theme_name, $version_control = '/.git' ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea for this, it's a very flat function.

@mike-day mike-day merged commit 6760041 into main May 1, 2023
@mike-day mike-day deleted the try/check-for-version-control branch May 1, 2023 18:54
@kienstra
Copy link
Contributor

kienstra commented May 1, 2023

This is your best PR yet. Very clean functions that are well tested. And data separate from presentation in the notice component.

@mike-day
Copy link
Contributor Author

mike-day commented May 1, 2023

Thanks for your kind words, and thanks for the help with this PR as always, @kienstra!

@kienstra
Copy link
Contributor

kienstra commented May 1, 2023

Of course! Great work on this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants