Skip to content

Commit

Permalink
Update button logic and variants
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Dec 6, 2024
1 parent 0e8cca8 commit 673720b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ function Layout( {

return (
<SlotFillProvider>
<ErrorBoundary>
<ErrorBoundary canCopyContent>
<CommandMenu />
<WelcomeGuide postType={ currentPostType } />
<div
Expand Down
15 changes: 9 additions & 6 deletions packages/editor/src/components/error-boundary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ function getContent() {
} catch ( error ) {}
}

function CopyButton( { text, children } ) {
function CopyButton( { text, children, variant = 'secondary' } ) {
const ref = useCopyToClipboard( text );
return (
<Button __next40pxDefaultSize variant="secondary" ref={ ref }>
<Button __next40pxDefaultSize variant={ variant } ref={ ref }>
{ children }
</Button>
);
Expand All @@ -57,6 +57,7 @@ class ErrorBoundary extends Component {

render() {
const { error } = this.state;
const { canCopyContent = false } = this.props;
if ( ! error ) {
return this.props.children;
}
Expand All @@ -74,10 +75,12 @@ class ErrorBoundary extends Component {
{ __( 'The editor has encountered an unexpected error.' ) }
</Text>
<HStack expanded={ false }>
<CopyButton text={ getContent }>
{ __( 'Copy post text' ) }
</CopyButton>
<CopyButton text={ error?.stack }>
{ canCopyContent && (
<CopyButton text={ getContent }>
{ __( 'Copy contents' ) }
</CopyButton>
) }
<CopyButton variant="primary" text={ error?.stack }>
{ __( 'Copy error' ) }
</CopyButton>
</HStack>
Expand Down

0 comments on commit 673720b

Please sign in to comment.