Skip to content

Commit

Permalink
AI Extension: update proofread with the AI Status Indicator component (
Browse files Browse the repository at this point in the history
…#32397)

* [not verified] expose AiStatusIndicator component

* [not verified] use AiStatusIndicator in proofread implementation

* [not verified] changelog

* Update changelog

---------

Co-authored-by: Renato Augusto Gama dos Santos <renato_0603@hotmail.com>
  • Loading branch information
retrofox and renatoagds authored Aug 10, 2023
1 parent f811ae7 commit 4acb09f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

AI Client: Export AiStatusIndicator
2 changes: 1 addition & 1 deletion projects/js-packages/ai-client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export * from './src/icons';
/*
* Components
*/
export { default as AIControl } from './src/components/ai-control';
export * from './src/components';

/*
* Contexts
Expand Down
2 changes: 2 additions & 0 deletions projects/js-packages/ai-client/src/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as AIControl } from './ai-control';
export { default as AiStatusIndicator } from './ai-status-indicator';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

AI Extension: update proofread with the AI Status Indicator component
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* External dependencies
*/
import { aiAssistantIcon, useAiSuggestions } from '@automattic/jetpack-ai-client';
import { AiStatusIndicator, useAiSuggestions } from '@automattic/jetpack-ai-client';
import { useAnalytics } from '@automattic/jetpack-shared-extension-utils';
import { serialize } from '@wordpress/blocks';
import { Modal, Button, Spinner } from '@wordpress/components';
import { Modal, Button } from '@wordpress/components';
import { useSelect } from '@wordpress/data';
import { useState } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Icon, close } from '@wordpress/icons';
import { close } from '@wordpress/icons';
import TurndownService from 'turndown';
/**
* Internal dependencies
Expand All @@ -28,11 +28,11 @@ const usePostContent = () => {
return blocks?.length ? turndownService.turndown( serialize( blocks ) ) : '';
};

const ModalHeader = ( { loading, onClose } ) => {
const ModalHeader = ( { requestingState, onClose } ) => {
return (
<div className="ai-assistant-post-feedback__modal-header">
<div className="ai-assistant-post-feedback__modal-title-wrapper">
{ loading ? <Spinner /> : <Icon icon={ aiAssistantIcon } /> }
<AiStatusIndicator state={ requestingState } />
<h1 className="ai-assistant-post-feedback__modal-title">
{ __( 'AI Assistant', 'jetpack' ) }
</h1>
Expand Down Expand Up @@ -120,10 +120,7 @@ export default function Proofread( {
{ isProofreadModalVisible && (
<Modal __experimentalHideHeader>
<div className="ai-assistant-post-feedback__modal-content">
<ModalHeader
loading={ requestingState === 'suggesting' || requestingState === 'requesting' }
onClose={ toggleProofreadModal }
/>
<ModalHeader requestingState={ requestingState } onClose={ toggleProofreadModal } />
<hr className="ai-assistant-post-feedback__modal-divider" />
<div className="ai-assistant-post-feedback__suggestion">{ suggestion }</div>
</div>
Expand Down

0 comments on commit 4acb09f

Please sign in to comment.