Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added linkifyOptions to ErrorPanel #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Component/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ConsoleMessage extends React.Component<MessageProps, any> {
log.data.every((message) => typeof message === 'string') &&
log.method === 'error'
) {
return <ErrorPanel error={log.data.join(' ')} />
return <ErrorPanel linkifyOptions={this.props.linkifyOptions} error={log.data.join(' ')} />
}

// Normal inspector
Expand Down
11 changes: 9 additions & 2 deletions src/Component/message-parsers/Error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react'
import Linkify from 'linkifyjs/react'
import type { Options } from 'linkifyjs'

function splitMessage(message: string): string {
const breakIndex = message.indexOf('\n')
Expand All @@ -10,7 +11,13 @@ function splitMessage(message: string): string {
return message.substr(0, breakIndex)
}

function ErrorPanel({ error }: { error: string }) {
function ErrorPanel({
error,
linkifyOptions,
}: {
error: string
linkifyOptions?: Options
}) {
/* This checks for error logTypes and shortens the message in the console by wrapping
it a <details /> tag and putting the first line in a <summary /> tag and the other lines
follow after that. This creates a nice collapsible error message */
Expand All @@ -30,7 +37,7 @@ function ErrorPanel({ error }: { error: string }) {
<summary style={{ outline: 'none', cursor: 'pointer' }}>
{firstLine}
</summary>
<Linkify>{otherErrorLines.join('\n\r')}</Linkify>
<Linkify options={linkifyOptions}>{otherErrorLines.join('\n\r')}</Linkify>
</details>
)
}
Expand Down