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

Add a direct link to trace URLs #102

Open
wants to merge 1 commit into
base: main
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
9 changes: 4 additions & 5 deletions app/assets/components/TraceInfo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ export class Field extends Component
render: ->
{ title, value, href } = this.props

if value?
value = value.toString()

$ 'div',
$ 'h4', title
do =>
if value
$ 'a', title: value, href: href, value
if value? && href
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't quite correct yet, as some of the other fields omit the href prop as well. What I want to really check is whether value is itself a VDOM node, but I didn't know how...

$ 'a', title: value.toString(), href: href, value.toString()
else if value?
$ 'p', value
else
$ 'a', className: 'empty', '<none>'
24 changes: 22 additions & 2 deletions app/assets/components/TraceMeta.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import {
createElement as $
} from './core'

import FaExternalLink from 'preact-icons/fa/external-link'

import URIJS from 'urijs'

import { Field } from './TraceInfo'
Expand Down Expand Up @@ -45,8 +47,7 @@ class WebMeta extends Component
href: routes.traces_url(ws: meta['status']) if meta['status']?
$ Field,
title: 'Path'
value: meta['path']
href: routes.traces_url(application: application['uuid'], wp: meta['path']) if meta['path']?
value: this.pathField()
$ Field,
title: 'Query'
value: meta['query']
Expand All @@ -55,6 +56,25 @@ class WebMeta extends Component
value: meta['action']
href: routes.traces_url(application: application['uuid'], wc: meta['controller'], wa: meta['action']) if meta['action']?

pathField: ->
{ routes } = this.context
{ application, meta } = this.props.trace

return unless meta['path']?

traceUrl = routes.traces_url(application: application['uuid'], wp: meta['path'])

# If it makes sense, let's add a direct link to the request's URL
if meta['method'] == 'GET' && meta['host']?
visitUrl = 'http://' + meta['host'] + meta['path']

[
$('a', href: traceUrl, meta['path']),
$('a', href: visitUrl, class: 'external', $(FaExternalLink))
]
else
$ 'a', href: traceUrl, meta['path']


class JobMeta extends Component
render: ->
Expand Down
19 changes: 10 additions & 9 deletions app/assets/components/TraceView.sass
Original file line number Diff line number Diff line change
Expand Up @@ -165,30 +165,31 @@
&:nth-child(5n), &:first-child
border-left-width: 1px

> h4, > a
> h4, > a, > p
line-height: 1.4rem
font-size: 0.7rem
margin: 0
padding: 2px 0.4rem

> h4
text-align: right
margin: 0
min-width: 80px
padding: 2px 0.4rem

color: #555
background: #f6f6f6

> a
> a, > p
background: #fff
width: 100%
margin: 0
padding: 2px 0.4rem
text-overflow: ellipsis
overflow: hidden
white-space: nowrap

&.empty
color: #999
> a.empty
color: #999

a.external
padding-left: 5px
padding-right: 5px

@media (max-width: 1024px)
flex-direction: column
Expand Down