Skip to content

Commit

Permalink
add showRemove attribute to AIControl (#34677)
Browse files Browse the repository at this point in the history
  • Loading branch information
CGastrell committed Dec 15, 2023
1 parent 8f11230 commit 300de59
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

AI Client: add showRemove attribute for ai-control
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type AiControlProps = {
onStop?: () => void;
onAccept?: () => void;
onDiscard?: () => void;
showRemove?: boolean;
};

// eslint-disable-next-line @typescript-eslint/no-empty-function
Expand Down Expand Up @@ -70,6 +71,7 @@ export function AIControl(
onStop = noop,
onAccept = noop,
onDiscard = null,
showRemove = false,
}: AiControlProps,
ref: React.MutableRefObject< null > // eslint-disable-line @typescript-eslint/ban-types
): React.ReactElement {
Expand Down Expand Up @@ -188,7 +190,7 @@ export function AIControl(
</Button>
) }

{ ! editRequest && ! value?.length && onDiscard && (
{ showRemove && ! editRequest && ! value?.length && onDiscard && (
<Button
className="jetpack-components-ai-control__controls-prompt_button"
onClick={ discardHandler }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: other

AI Assistant: provide showRemove attribute for AIControl component
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ export default function AIAssistantEdit( { attributes, setAttributes, clientId,
showAccept={ requestingState !== 'init' && contentIsLoaded && ! isWaitingState }
acceptLabel={ acceptLabel }
showGuideLine={ contentIsLoaded }
showRemove={ attributes?.content?.length > 0 }
/>

{ ! loadingImages && resultImages.length > 0 && (
Expand Down

0 comments on commit 300de59

Please sign in to comment.