Skip to content

Commit

Permalink
Generalise comment links
Browse files Browse the repository at this point in the history
Add base URLs to comment links, based on the type of project resource.
  • Loading branch information
eatyourgreens committed Mar 23, 2020
1 parent b6e3336 commit 856969d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
5 changes: 3 additions & 2 deletions app/talk/comment-link.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ module.exports = createReactClass
@props.comment.section isnt 'zooniverse'

projectCommentUrl: ->
{comment} = @props
"/projects/#{comment.project_slug}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"
baseURL = @props.project?._type._name
{comment, project} = @props
"/#{baseURL}/#{project.slug}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}"

mainTalkCommentUrl: ->
{comment} = @props
Expand Down
14 changes: 9 additions & 5 deletions app/talk/comment.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ module.exports = createReactClass

commentSubjectTitle: (comment, subject) ->
{owner, name} = @props.params
baseURL = @props.project?._type._name
if (comment.focus_type is 'Subject') and (owner and name)
<Link to="/projects/#{owner}/#{name}/talk/subjects/#{comment.focus_id}" onClick={@logItemClick.bind this, "view-subject-direct"}>
<Link to="/#{baseURL}/#{owner}/#{name}/talk/subjects/#{comment.focus_id}" onClick={@logItemClick.bind this, "view-subject-direct"}>
Subject {subject.id}
</Link>
else
Expand All @@ -130,7 +131,8 @@ module.exports = createReactClass
replyLine: (comment) ->
baseLink = "/"
if @props.project?
baseLink += "projects/#{@props.project.slug}/"
baseURL = @props.project?._type._name
baseLink += "#{baseURL}/#{@props.project.slug}/"
<div key={comment.id} className="comment-reply-line" ref="comment-reply-#{comment.id}">
<p>
<Link to="#{baseLink}users/#{comment.user_login}">{comment.user_display_name}</Link>
Expand Down Expand Up @@ -168,7 +170,8 @@ module.exports = createReactClass
isDeleted = if @props.data.is_deleted then 'deleted' else ''
profile_link = "/users/#{@props.author?.login}"
if @props.project?
profile_link = "/projects/#{@props.project.slug}#{profile_link}"
baseURL = @props.project._type._name
profile_link = "/#{baseURL}/#{@props.project.slug}#{profile_link}"
author_login = if @props.author?.login then "@#{@props.author.login}" else ""
<div className="talk-comment #{activeClass} #{isDeleted}">
<div className="talk-comment-author">
Expand All @@ -188,7 +191,8 @@ module.exports = createReactClass
{if @props.data.reply_id
profile_link = "/users/#{@props.data.reply_user_login}"
if @props.project?
profile_link = "/projects/#{@props.project.slug}#{profile_link}"
baseURL = @props.project?._type._name
profile_link = "/#{baseURL}/#{@props.project.slug}#{profile_link}"
<div className="talk-comment-reply">
{if @state.replies.length
<div>
Expand Down Expand Up @@ -266,7 +270,7 @@ module.exports = createReactClass

<div className="talk-comment-children">
{switch @state.showing
when 'link' then <CommentLink comment={@props.data}/>
when 'link' then <CommentLink comment={@props.data} project={@props.project}/>
when 'report' then <CommentReportForm comment={@props.data} />}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/talk/recents.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ module.exports = createReactClass
commentTitle: (comment) ->
<span>
{if @props.params.owner and @props.params.name
baseURL = @props.project?._type._name
{owner, name} = @props.params
<Link to="/projects/#{owner}/#{name}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}">
<Link to="/#{baseURL}/#{owner}/#{name}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}">
{comment.discussion_title} on {comment.board_title}
</Link>
else
Expand Down

0 comments on commit 856969d

Please sign in to comment.