This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Check for version control, display notice #145
Merged
Merged
Changes from 8 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
8021294
Create `get-version-control` wp-module
mike-day 70ac8a1
Hydrate `app` using `check_for_git_in_theme`
mike-day cbd407c
Update global type with `themename`, `versionControl`
mike-day e352cc8
Create VersionControlNotice component
mike-day c92dcae
Remove margin-right for notice__content
mike-day 8ca4bc5
Use `VersionControlNotice` in `Patterns`
mike-day e8e2c71
Update AppTest
mike-day a8dbda1
Remove unused check for git in theme root
mike-day 1527f1c
Setup a test-theme fixture
mike-day f3b450c
Create unit tests for get-verison-control (not passing)
mike-day 3e22e49
Simplify the phpunit tests, delete unneeded fixture theme files
mike-day 8031eec
Use a param for main vc checker function so testing is easier
mike-day d3f6d6b
Make the notice dismissible; adjust notice style to go full-width
mike-day f52085a
Remove invalid max-width property
mike-day ba16aca
Use `info` status for notice; adjust styles after talking through UX
mike-day 7379ab4
Try a `warning` status for the notice
mike-day dbe4758
Tweak the verbiage in notice; linting for component
mike-day 2c7f9c0
Add the update-dismissed-themes endpoint
mike-day c4b39f7
Hydrate app with new endpoint, query for dismissedThemes
mike-day 7db5b54
Update types
mike-day 36641de
Add a new `useVersionControl` hook
mike-day ae0d0aa
Call the new hook, then add to context provider
mike-day c8e0b03
Simplify VersionControlNotice; use the updated context in `Patterns`
mike-day 1697e26
Update ApiDataTest
mike-day 3a394e2
Update AppTest
mike-day d785692
Move getting of usermeta to get-version-control, return empty array i…
mike-day e96e8a1
Add empty array test for get_dismissed_themes
mike-day a9b9ef6
Translate the notification message
mike-day 4e8188e
Merge branch 'main' of https://github.com/studiopress/pattern-manager…
mike-day 126e83f
Pass themeName in PatternProps
mike-day 06172f2
Pass versionControl bool, handler as props in Patterns instead of usi…
mike-day b50b045
Add get_current_user_id() to setUp, tearDown in unit test
mike-day af0ada1
Pass `Notice` as an optional prop to `Patterns`
mike-day 37afb1a
Simplify the logic and just hydrate with a boolean to show or hide no…
mike-day 54f8656
Bugfix from sending empty `themeName`; remove the POST body
mike-day 1463614
Tweak the notice message, add space
mike-day fff8336
Add more test assertions for GetVersionControlTest
mike-day 19437ed
Delete testing usermeta, user on tearDown
mike-day 6c3907c
Remove the link to `Git Guide` in the notice message
mike-day File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
wp-modules/app/js/src/components/VersionControlNotice/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// WP dependencies | ||
import { Notice } from '@wordpress/components'; | ||
|
||
// Globals | ||
import { patternManager } from '../../globals'; | ||
|
||
/** Display a non-dismissible notice if no version control is detected in the theme. */ | ||
export default function VersionControlNotice() { | ||
return ( | ||
! patternManager.versionControl && ( | ||
<Notice | ||
className="patternmanager-version-control-notice" | ||
isDismissible={ false } | ||
status="error" | ||
> | ||
No version control detected for this theme. Please{ ' ' } | ||
<a href="https://github.com/git-guides">initialize git</a> in | ||
the <span>{ patternManager.themeName }</span> theme folder. | ||
</Notice> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
/** | ||
* Module Name: Get Version Control | ||
* Description: Checks the current theme directory for version control. | ||
* Namespace: GetVersionControl | ||
* | ||
* @package pattern-manager | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PatternManager\GetVersionControl; | ||
|
||
/** | ||
* Checks for a .git folder in the current theme. | ||
* | ||
* @return boolean | ||
*/ | ||
function check_for_git_in_theme() { | ||
$theme_git_dir = get_template_directory() . '/.git'; | ||
return file_exists( $theme_git_dir ); | ||
mike-day marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
andthemeName
as props, this component could be a good candidate for moving tocommon
if we do something like #141.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea!