-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add git sidebar placeholder in the editor
- Loading branch information
1 parent
df1230a
commit a579fa7
Showing
9 changed files
with
195 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
require_once( dirname(__DIR__) . '/lib/git-wrapper.php' ); | ||
|
||
class Git_Themes_API { | ||
private $git; | ||
|
||
public function __construct() { | ||
$this -> git = Git_Wrapper::get_git(CREATE_BLOCK_THEME_GIT_DIR); | ||
} | ||
|
||
public function get_git_config() { | ||
return array( | ||
'version' => $this -> git -> get_version(), | ||
'git_configured' => false, | ||
'remote_url' => '' | ||
); | ||
} | ||
} |
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,48 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
// eslint-disable-next-line | ||
__experimentalSpacer as Spacer, | ||
// eslint-disable-next-line | ||
__experimentalText as Text, | ||
TextControl, | ||
} from '@wordpress/components'; | ||
import { useState } from "@wordpress/element"; | ||
|
||
export const GitIntegrationForm = function() { | ||
const [ repository, setRepository ] = useState( { | ||
url: '', | ||
author_name: '', | ||
author_email: '', | ||
} ); | ||
|
||
return <> | ||
<Text> | ||
{ __( | ||
'Enter a repository Url to connect with current theme.', | ||
'create-block-theme' | ||
) } | ||
</Text> | ||
<Spacer /> | ||
<TextControl | ||
label={ __( 'Repository URL', 'create-block-theme' ) } | ||
value={ repository.url } | ||
onChange={ ( value ) => | ||
setRepository( { ...repository, url: value } ) | ||
} | ||
/> | ||
<TextControl | ||
label={ __( 'Author Name', 'create-block-theme' ) } | ||
value={ repository.author_name } | ||
onChange={ ( value ) => | ||
setRepository( { ...repository, author_name: value } ) | ||
} | ||
/> | ||
<TextControl | ||
label={ __( 'Author Email', 'create-block-theme' ) } | ||
value={ repository.author_email } | ||
onChange={ ( value ) => | ||
setRepository( { ...repository, author_email: value } ) | ||
} | ||
/> | ||
</> | ||
} |
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,14 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
// eslint-disable-next-line | ||
__experimentalText as Text, | ||
} from '@wordpress/components'; | ||
|
||
export const GitNotInstalledError = function () { | ||
return <Text> | ||
{ __( | ||
'Git is not installed on the server.', | ||
'create-block-theme' | ||
) } | ||
</Text>; | ||
} |
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,50 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
// eslint-disable-next-line | ||
__experimentalVStack as VStack, | ||
// eslint-disable-next-line | ||
__experimentalText as Text, | ||
// eslint-disable-next-line | ||
__experimentalHeading as Heading, | ||
// eslint-disable-next-line | ||
__experimentalNavigatorToParentButton as NavigatorToParentButton, | ||
PanelBody, | ||
} from '@wordpress/components'; | ||
import { useState, useEffect } from '@wordpress/element'; | ||
import apiFetch from '@wordpress/api-fetch'; | ||
import { | ||
chevronLeft, | ||
} from '@wordpress/icons'; | ||
import { GitIntegrationForm } from './git-config'; | ||
import { GitNotInstalledError } from './git-errors'; | ||
|
||
export const GitIntegrationPanel = function() { | ||
const [gitConfig, setGitConfig] = useState({}); | ||
|
||
useEffect(() => { | ||
apiFetch( { | ||
path: '/create-block-theme/v1/get-git-config', | ||
method: 'GET', | ||
} ).then( ( response ) => { | ||
setGitConfig(response); | ||
}).catch(() => { | ||
setGitConfig({}); | ||
}); | ||
}); | ||
|
||
return <PanelBody> | ||
<Heading> | ||
<NavigatorToParentButton icon={ chevronLeft }> | ||
{ __( 'Git Integration', 'create-block-theme' ) } | ||
</NavigatorToParentButton> | ||
</Heading> | ||
<VStack> | ||
{ | ||
!gitConfig.version ? <GitNotInstalledError /> : ( | ||
!gitConfig.git_configured ? <GitIntegrationForm /> : | ||
<div>Git connected.</div> | ||
) | ||
} | ||
</VStack> | ||
</PanelBody>; | ||
} |
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,14 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { SVG, Path } from '@wordpress/primitives'; | ||
|
||
export const GitIcon = ( | ||
// source: https://github.com/primer/octicons/blob/main/icons/git-compare-24.svg | ||
// license: MIT | ||
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
<Path d="M16.5 19.25a3.25 3.25 0 1 1 6.5 0 3.25 3.25 0 0 1-6.5 0Zm3.25-1.75a1.75 1.75 0 1 0 .001 3.501 1.75 1.75 0 0 0-.001-3.501Z" /> | ||
<Path d="M13.905 1.72a.75.75 0 0 1 0 1.06L12.685 4h4.065a3.75 3.75 0 0 1 3.75 3.75v8.75a.75.75 0 0 1-1.5 0V7.75a2.25 2.25 0 0 0-2.25-2.25h-4.064l1.22 1.22a.75.75 0 0 1-1.061 1.06l-2.5-2.5a.75.75 0 0 1 0-1.06l2.5-2.5a.75.75 0 0 1 1.06 0ZM7.5 4.75a3.25 3.25 0 1 1-6.5 0 3.25 3.25 0 0 1 6.5 0ZM4.25 6.5a1.75 1.75 0 1 0-.001-3.501A1.75 1.75 0 0 0 4.25 6.5Z" /> | ||
<Path d="M10.095 22.28a.75.75 0 0 1 0-1.06l1.22-1.22H7.25a3.75 3.75 0 0 1-3.75-3.75V7.5a.75.75 0 0 1 1.5 0v8.75a2.25 2.25 0 0 0 2.25 2.25h4.064l-1.22-1.22a.748.748 0 0 1 .332-1.265.75.75 0 0 1 .729.205l2.5 2.5a.75.75 0 0 1 0 1.06l-2.5 2.5a.75.75 0 0 1-1.06 0Z" /> | ||
</SVG> | ||
); |
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