From d72f46ab8dc3599b27ecf6da444a7353f0723595 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Thu, 20 Jun 2019 14:17:42 +0100 Subject: [PATCH 1/6] Add an organisation Talk page Add a Talk section called org-{organisation.id}. Passes the organisation down to Talk components as the project prop. --- .../organization/organization-container.jsx | 4 ++- app/pages/organization/talk/index.jsx | 33 +++++++++++++++++++ app/router.jsx | 12 +++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 app/pages/organization/talk/index.jsx diff --git a/app/pages/organization/organization-container.jsx b/app/pages/organization/organization-container.jsx index b74b9147d6..b02f92ad52 100644 --- a/app/pages/organization/organization-container.jsx +++ b/app/pages/organization/organization-container.jsx @@ -227,6 +227,7 @@ class OrganizationContainer extends React.Component { } render() { + const { user } = this.context; const { children, params } = this.props; const { collaboratorView, @@ -256,7 +257,8 @@ class OrganizationContainer extends React.Component { organizationProjects, projectAvatars, quoteObject, - toggleCollaboratorView: this.toggleCollaboratorView + toggleCollaboratorView: this.toggleCollaboratorView, + user }); } else if (fetchingOrganization) { return ( diff --git a/app/pages/organization/talk/index.jsx b/app/pages/organization/talk/index.jsx new file mode 100644 index 0000000000..5ab41a67c7 --- /dev/null +++ b/app/pages/organization/talk/index.jsx @@ -0,0 +1,33 @@ +import React from 'react'; +import { Helmet } from 'react-helmet'; +import { Link } from 'react-router'; +import counterpart from 'counterpart'; +import TalkBreadcrumbs from '../../../talk/breadcrumbs'; +import TalkSearchInput from '../../../talk/search-input'; +import TalkFootnote from '../../../talk/footnote'; + +export default function OrgTalkPage(props) { + const { organization, user } = props; + const section = `org-${organization.id}`; + const project = organization + const pageTitle = `${organization.display_name} » ${counterpart('orgTalk.title')}`; + return ( +
+ +
+

+ + {organization.display_name} Talk + +

+ + + + + {React.cloneElement(props.children, { section, project: organization, user })} + + +
+
+ ); +} diff --git a/app/router.jsx b/app/router.jsx index 7869469b9f..1fbfa9a609 100644 --- a/app/router.jsx +++ b/app/router.jsx @@ -291,6 +291,18 @@ export const routes = ( + + + + + + + + + + + + From 0ee5d93fc5fe80f239958e0b2c21d9837d25e3c1 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 23 Mar 2020 12:16:55 +0000 Subject: [PATCH 2/6] Add baseURL to links Derive a base URL for links from the type of project resource. --- app/talk/board-preview.cjsx | 5 +++-- app/talk/board.cjsx | 3 ++- app/talk/breadcrumbs.cjsx | 3 ++- app/talk/discussion-preview.cjsx | 10 +++++----- app/talk/init.cjsx | 3 ++- app/talk/latest-comment-link.cjsx | 8 +++++--- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/talk/board-preview.cjsx b/app/talk/board-preview.cjsx index afbbd296e2..1616a921de 100644 --- a/app/talk/board-preview.cjsx +++ b/app/talk/board-preview.cjsx @@ -17,9 +17,10 @@ module.exports = createReactClass boardLink: -> {owner, name} = @props.params boardId = @props.data.id + baseURL = @props.project?._type._name - if @props.project - + if baseURL + {@props.data.title} else diff --git a/app/talk/board.cjsx b/app/talk/board.cjsx index 116eea096e..0f32734ba5 100644 --- a/app/talk/board.cjsx +++ b/app/talk/board.cjsx @@ -211,6 +211,7 @@ module.exports = createReactClass render: -> + baseURL = @props.project?._type._name {board} = @state discussionsMeta = @state.discussions[0]?.getMeta() @@ -299,7 +300,7 @@ module.exports = createReactClass {if @props.section is 'zooniverse' Recent Comments else - + Recent Comments } diff --git a/app/talk/breadcrumbs.cjsx b/app/talk/breadcrumbs.cjsx index a96aa6433e..c2593894ae 100644 --- a/app/talk/breadcrumbs.cjsx +++ b/app/talk/breadcrumbs.cjsx @@ -34,7 +34,8 @@ module.exports = createReactClass rootTalkPath: -> if @props.project [owner, name] = @props.project.slug.split('/') - "/projects/#{owner}/#{name}/talk" + baseURL = @props.project._type._name + "/#{baseURL}/#{owner}/#{name}/talk" else "/talk" diff --git a/app/talk/discussion-preview.cjsx b/app/talk/discussion-preview.cjsx index 017faccb8a..89618685e7 100644 --- a/app/talk/discussion-preview.cjsx +++ b/app/talk/discussion-preview.cjsx @@ -20,14 +20,14 @@ module.exports = createReactClass discussionLink: -> {discussion} = @props + baseURL = @props.project?._type._name - if (@props.params?.owner and @props.params?.name) # get from url if possible + if (baseURL && @props.params?.owner and @props.params?.name) # get from url if possible {owner, name} = @props.params - "/projects/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" + "/#{baseURL}/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" - else if @props.project.slug # otherwise fetch from project - [owner, name] = @props.project.slug.split('/') - "/projects/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" + else if (baseURL && @props.project.slug) # otherwise fetch from project + "/#{baseURL}/#{@props.project.slug}/talk/#{discussion.board_id}/#{discussion.id}" else # link to zooniverse main talk "/talk/#{discussion.board_id}/#{discussion.id}" diff --git a/app/talk/init.cjsx b/app/talk/init.cjsx index bab452857c..a1a71afccb 100644 --- a/app/talk/init.cjsx +++ b/app/talk/init.cjsx @@ -139,6 +139,7 @@ module.exports = createReactClass @setBoards() render: -> + baseURL = @props.project?._type._name
{if @props.user?
@@ -200,7 +201,7 @@ module.exports = createReactClass {if @props.section is 'zooniverse' Recent Comments else - Recent Comments + Recent Comments } diff --git a/app/talk/latest-comment-link.cjsx b/app/talk/latest-comment-link.cjsx index fa155ddb4b..3c67dd2c6d 100644 --- a/app/talk/latest-comment-link.cjsx +++ b/app/talk/latest-comment-link.cjsx @@ -49,14 +49,15 @@ module.exports = createReactClass @setState({latestCommentText}) if latestCommentText discussionLink: (childtext = '', query = {}, className = '') -> + baseURL = @props.project?._type._name if className is "latest-comment-time" logClick = @context.geordi?.makeHandler? 'discussion-time' locationObject = pathname: "/talk/#{@props.discussion.board_id}/#{@props.discussion.id}" query: query - if @props.params?.owner and @props.params?.name + if baseURL and @props.params?.owner and @props.params?.name {owner, name} = @props.params - locationObject.pathname = "/projects/#{owner}/#{name}" + locationObject.pathname + locationObject.pathname = "/#{baseURL}/#{owner}/#{name}" + locationObject.pathname {childtext} @@ -74,7 +75,8 @@ module.exports = createReactClass baseLink = "/" if @props.project? and @props.project.slug? - baseLink += "projects/#{@props.project.slug}/" + baseURL = @props.project?._type._name + baseLink += "#{baseURL}/#{@props.project.slug}/"
From 4d8643663dcbedc1c5abf4f53cec419ae894b578 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 23 Mar 2020 12:56:09 +0000 Subject: [PATCH 3/6] Generalise projectSection Update the projectSection helper to include organisations. Update main Talk page and recent comments to use projectSection. --- app/pages/organization/talk/index.jsx | 4 ++-- app/talk/lib/project-section.coffee | 6 +++++- app/talk/recents.cjsx | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/pages/organization/talk/index.jsx b/app/pages/organization/talk/index.jsx index 5ab41a67c7..4cb50821d5 100644 --- a/app/pages/organization/talk/index.jsx +++ b/app/pages/organization/talk/index.jsx @@ -2,14 +2,14 @@ import React from 'react'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router'; import counterpart from 'counterpart'; +import projectSection from '../../../talk/lib/project-section' import TalkBreadcrumbs from '../../../talk/breadcrumbs'; import TalkSearchInput from '../../../talk/search-input'; import TalkFootnote from '../../../talk/footnote'; export default function OrgTalkPage(props) { const { organization, user } = props; - const section = `org-${organization.id}`; - const project = organization + const section = projectSection(organization); const pageTitle = `${organization.display_name} » ${counterpart('orgTalk.title')}`; return (
diff --git a/app/talk/lib/project-section.coffee b/app/talk/lib/project-section.coffee index 1fa254a298..37bef71b0f 100644 --- a/app/talk/lib/project-section.coffee +++ b/app/talk/lib/project-section.coffee @@ -1,3 +1,7 @@ # takes in a project id and returns a correctly formatted talk section for that project -module.exports = (project) -> "project-#{project.id}" +module.exports = (project) -> + type = project._type._name + switch type + when 'organizations' then "org-#{project.id}" + when 'projects' then "project-#{project.id}" diff --git a/app/talk/recents.cjsx b/app/talk/recents.cjsx index 5bd79ea844..0b89af2228 100644 --- a/app/talk/recents.cjsx +++ b/app/talk/recents.cjsx @@ -6,6 +6,7 @@ Comment = require './comment' apiClient = require 'panoptes-client/lib/api-client' talkClient = require 'panoptes-client/lib/talk-client' Paginator = require './lib/paginator' +projectSection = require './lib/project-section' updateQueryParams = require './lib/update-query-params' Loading = require('../components/loading-indicator').default talkConfig = require './config' @@ -52,7 +53,7 @@ module.exports = createReactClass if @props.params.board params.board_id = @props.params.board if @props.params.board else if @props.project - params.section = "project-#{ @props.project.id }" + params.section = projectSection(@props.project) else params.section = 'zooniverse' params From 15c9eeeae3b38205c85d9ca09ebdef8961be9b17 Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 23 Mar 2020 13:23:29 +0000 Subject: [PATCH 4/6] Generalise comment links Add base URLs to comment links, based on the type of project resource. --- app/talk/comment-link.cjsx | 5 +++-- app/talk/comment.cjsx | 14 +++++++++----- app/talk/recents.cjsx | 3 ++- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/talk/comment-link.cjsx b/app/talk/comment-link.cjsx index 80f64571bb..d55c0b76ef 100644 --- a/app/talk/comment-link.cjsx +++ b/app/talk/comment-link.cjsx @@ -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 diff --git a/app/talk/comment.cjsx b/app/talk/comment.cjsx index 25e8be4fb2..dd6acdf05c 100644 --- a/app/talk/comment.cjsx +++ b/app/talk/comment.cjsx @@ -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) - + Subject {subject.id} else @@ -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}/"

{comment.user_display_name} @@ -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 ""

@@ -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}"
{if @state.replies.length
@@ -266,7 +270,7 @@ module.exports = createReactClass
{switch @state.showing - when 'link' then + when 'link' then when 'report' then }
diff --git a/app/talk/recents.cjsx b/app/talk/recents.cjsx index 0b89af2228..c4e2063bc6 100644 --- a/app/talk/recents.cjsx +++ b/app/talk/recents.cjsx @@ -114,8 +114,9 @@ module.exports = createReactClass commentTitle: (comment) -> {if @props.params.owner and @props.params.name + baseURL = @props.project?._type._name {owner, name} = @props.params - + {comment.discussion_title} on {comment.board_title} else From 39c4e32a297c5b5d85079956804449afc191856f Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 23 Mar 2020 13:35:20 +0000 Subject: [PATCH 5/6] Fix tests --- app/talk/discussion-preview.cjsx | 8 ++++---- app/talk/discussion-preview.spec.js | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/talk/discussion-preview.cjsx b/app/talk/discussion-preview.cjsx index 89618685e7..0f8a8a13e1 100644 --- a/app/talk/discussion-preview.cjsx +++ b/app/talk/discussion-preview.cjsx @@ -19,15 +19,15 @@ module.exports = createReactClass project: {} discussionLink: -> - {discussion} = @props - baseURL = @props.project?._type._name + {discussion, project} = @props + baseURL = project?._type?._name if (baseURL && @props.params?.owner and @props.params?.name) # get from url if possible {owner, name} = @props.params "/#{baseURL}/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" - else if (baseURL && @props.project.slug) # otherwise fetch from project - "/#{baseURL}/#{@props.project.slug}/talk/#{discussion.board_id}/#{discussion.id}" + else if (baseURL && project.slug) # otherwise fetch from project + "/#{baseURL}/#{project.slug}/talk/#{discussion.board_id}/#{discussion.id}" else # link to zooniverse main talk "/talk/#{discussion.board_id}/#{discussion.id}" diff --git a/app/talk/discussion-preview.spec.js b/app/talk/discussion-preview.spec.js index bab0b318ba..927bca0b87 100644 --- a/app/talk/discussion-preview.spec.js +++ b/app/talk/discussion-preview.spec.js @@ -5,6 +5,9 @@ import { shallow } from 'enzyme'; import DiscussionPreview from './discussion-preview'; const validProject = { + _type: { + _name: 'projects' + }, id: 34, slug: 'test/project' }; From 674f584b3be5513ffe71ee4bfb8912639350146c Mon Sep 17 00:00:00 2001 From: Jim O'Donnell Date: Mon, 23 Mar 2020 14:40:32 +0000 Subject: [PATCH 6/6] Move baseURL into a helper function --- app/talk/board-preview.cjsx | 6 +++--- app/talk/board.cjsx | 6 +++--- app/talk/comment-link.cjsx | 4 ++-- app/talk/comment.cjsx | 13 +++++-------- app/talk/discussion-preview.cjsx | 10 +++++----- app/talk/init.cjsx | 6 +++--- app/talk/latest-comment-link.cjsx | 9 ++++----- app/talk/lib/base-url.js | 1 + app/talk/popular-tags.jsx | 3 ++- app/talk/recents.cjsx | 4 ++-- 10 files changed, 30 insertions(+), 32 deletions(-) create mode 100644 app/talk/lib/base-url.js diff --git a/app/talk/board-preview.cjsx b/app/talk/board-preview.cjsx index 1616a921de..e9f2b578f4 100644 --- a/app/talk/board-preview.cjsx +++ b/app/talk/board-preview.cjsx @@ -4,6 +4,7 @@ createReactClass = require 'create-react-class' {Link} = require 'react-router' resourceCount = require './lib/resource-count' LatestCommentLink = require './latest-comment-link' +baseURL = require('./lib/base-url').default module.exports = createReactClass displayName: 'TalkBoardDisplay' @@ -17,10 +18,9 @@ module.exports = createReactClass boardLink: -> {owner, name} = @props.params boardId = @props.data.id - baseURL = @props.project?._type._name - if baseURL - + if @props.project + {@props.data.title} else diff --git a/app/talk/board.cjsx b/app/talk/board.cjsx index 0f32734ba5..85a85baf8c 100644 --- a/app/talk/board.cjsx +++ b/app/talk/board.cjsx @@ -20,6 +20,7 @@ merge = require 'lodash/merge' talkConfig = require './config' SignInPrompt = require '../partials/sign-in-prompt' alert = require('../lib/alert').default +baseURL = require('./lib/base-url').default `import ActiveUsers from './active-users';` ProjectLinker = require './lib/project-linker' @@ -211,7 +212,6 @@ module.exports = createReactClass render: -> - baseURL = @props.project?._type._name {board} = @state discussionsMeta = @state.discussions[0]?.getMeta() @@ -233,7 +233,7 @@ module.exports = createReactClass

Moderator Zone:

{if @props.section isnt 'zooniverse' - View Reported Comments + View Reported Comments else View Reported Comments } @@ -300,7 +300,7 @@ module.exports = createReactClass {if @props.section is 'zooniverse' Recent Comments else - + Recent Comments } diff --git a/app/talk/comment-link.cjsx b/app/talk/comment-link.cjsx index d55c0b76ef..0a428ece97 100644 --- a/app/talk/comment-link.cjsx +++ b/app/talk/comment-link.cjsx @@ -1,6 +1,7 @@ React = require 'react' PropTypes = require 'prop-types' createReactClass = require 'create-react-class' +baseURL = require('./lib/base-url').default talkConfig = require './config' {Link} = require 'react-router' @@ -20,9 +21,8 @@ module.exports = createReactClass @props.comment.section isnt 'zooniverse' projectCommentUrl: -> - baseURL = @props.project?._type._name {comment, project} = @props - "/#{baseURL}/#{project.slug}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}" + "/#{baseURL(project)}/#{project.slug}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}" mainTalkCommentUrl: -> {comment} = @props diff --git a/app/talk/comment.cjsx b/app/talk/comment.cjsx index dd6acdf05c..7b80b2f83b 100644 --- a/app/talk/comment.cjsx +++ b/app/talk/comment.cjsx @@ -18,6 +18,7 @@ SubjectViewer = require '../components/subject-viewer' SingleSubmitButton = require '../components/single-submit-button' DisplayRoles = require './lib/display-roles' CommentContextIcon = require './lib/comment-context-icon' +baseURL = require('./lib/base-url').default `import WrappedMarkdown from '../components/wrapped-markdown';` DEFAULT_AVATAR = '/assets/simple-avatar.png' @@ -107,9 +108,8 @@ 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) - + Subject {subject.id} else @@ -131,8 +131,7 @@ module.exports = createReactClass replyLine: (comment) -> baseLink = "/" if @props.project? - baseURL = @props.project?._type._name - baseLink += "#{baseURL}/#{@props.project.slug}/" + baseLink += "#{baseURL(@props.project)}/#{@props.project.slug}/"

{comment.user_display_name} @@ -170,8 +169,7 @@ module.exports = createReactClass isDeleted = if @props.data.is_deleted then 'deleted' else '' profile_link = "/users/#{@props.author?.login}" if @props.project? - baseURL = @props.project._type._name - profile_link = "/#{baseURL}/#{@props.project.slug}#{profile_link}" + profile_link = "/#{baseURL(@props.project)}/#{@props.project.slug}#{profile_link}" author_login = if @props.author?.login then "@#{@props.author.login}" else ""

@@ -191,8 +189,7 @@ module.exports = createReactClass {if @props.data.reply_id profile_link = "/users/#{@props.data.reply_user_login}" if @props.project? - baseURL = @props.project?._type._name - profile_link = "/#{baseURL}/#{@props.project.slug}#{profile_link}" + profile_link = "/#{baseURL(@props.project)}/#{@props.project.slug}#{profile_link}"
{if @state.replies.length
diff --git a/app/talk/discussion-preview.cjsx b/app/talk/discussion-preview.cjsx index 0f8a8a13e1..1ef5cd8791 100644 --- a/app/talk/discussion-preview.cjsx +++ b/app/talk/discussion-preview.cjsx @@ -4,6 +4,7 @@ createReactClass = require 'create-react-class' {Link} = require 'react-router' resourceCount = require './lib/resource-count' LatestCommentLink = require './latest-comment-link' +baseURL = require('./lib/base-url').default getSubjectLocation = require '../lib/get-subject-location' # `import Thumbnail from '../components/thumbnail';` @@ -20,14 +21,13 @@ module.exports = createReactClass discussionLink: -> {discussion, project} = @props - baseURL = project?._type?._name - if (baseURL && @props.params?.owner and @props.params?.name) # get from url if possible + if (project && @props.params?.owner and @props.params?.name) # get from url if possible {owner, name} = @props.params - "/#{baseURL}/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" + "/#{baseURL(project)}/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" - else if (baseURL && project.slug) # otherwise fetch from project - "/#{baseURL}/#{project.slug}/talk/#{discussion.board_id}/#{discussion.id}" + else if (project && project.slug) # otherwise fetch from project + "/#{baseURL(project)}/#{project.slug}/talk/#{discussion.board_id}/#{discussion.id}" else # link to zooniverse main talk "/talk/#{discussion.board_id}/#{discussion.id}" diff --git a/app/talk/init.cjsx b/app/talk/init.cjsx index a1a71afccb..711cbb9d17 100644 --- a/app/talk/init.cjsx +++ b/app/talk/init.cjsx @@ -14,6 +14,7 @@ Loading = require('../components/loading-indicator').default SingleSubmitButton = require '../components/single-submit-button' ZooniverseTeam = require './lib/zoo-team.cjsx' alert = require('../lib/alert').default +baseURL = require('./lib/base-url').default AddZooTeamForm = require './add-zoo-team-form' DragReorderable = require 'drag-reorderable' Paginator = require './lib/paginator' @@ -139,7 +140,6 @@ module.exports = createReactClass @setBoards() render: -> - baseURL = @props.project?._type._name
{if @props.user?
@@ -165,7 +165,7 @@ module.exports = createReactClass {if @props.section isnt 'zooniverse' - + View Reported Comments else @@ -201,7 +201,7 @@ module.exports = createReactClass {if @props.section is 'zooniverse' Recent Comments else - Recent Comments + Recent Comments } diff --git a/app/talk/latest-comment-link.cjsx b/app/talk/latest-comment-link.cjsx index 3c67dd2c6d..bd4c281612 100644 --- a/app/talk/latest-comment-link.cjsx +++ b/app/talk/latest-comment-link.cjsx @@ -3,6 +3,7 @@ PropTypes = require 'prop-types' createReactClass = require 'create-react-class' talkClient = require 'panoptes-client/lib/talk-client' {timeAgo} = require './lib/time' +baseURL = require('./lib/base-url').default DisplayRoles = require './lib/display-roles' Avatar = require '../partials/avatar' {Link} = require 'react-router' @@ -49,15 +50,14 @@ module.exports = createReactClass @setState({latestCommentText}) if latestCommentText discussionLink: (childtext = '', query = {}, className = '') -> - baseURL = @props.project?._type._name if className is "latest-comment-time" logClick = @context.geordi?.makeHandler? 'discussion-time' locationObject = pathname: "/talk/#{@props.discussion.board_id}/#{@props.discussion.id}" query: query - if baseURL and @props.params?.owner and @props.params?.name + if @props.project and @props.params?.owner and @props.params?.name {owner, name} = @props.params - locationObject.pathname = "/#{baseURL}/#{owner}/#{name}" + locationObject.pathname + locationObject.pathname = "/#{baseURL(@props.project)}/#{owner}/#{name}" + locationObject.pathname {childtext} @@ -75,8 +75,7 @@ module.exports = createReactClass baseLink = "/" if @props.project? and @props.project.slug? - baseURL = @props.project?._type._name - baseLink += "#{baseURL}/#{@props.project.slug}/" + baseLink += "#{baseURL(@props.project)}/#{@props.project.slug}/"
diff --git a/app/talk/lib/base-url.js b/app/talk/lib/base-url.js new file mode 100644 index 0000000000..085d2f4ffe --- /dev/null +++ b/app/talk/lib/base-url.js @@ -0,0 +1 @@ +export default resource => resource && resource._type._name \ No newline at end of file diff --git a/app/talk/popular-tags.jsx b/app/talk/popular-tags.jsx index 1ee21f5ff4..118937c367 100644 --- a/app/talk/popular-tags.jsx +++ b/app/talk/popular-tags.jsx @@ -6,9 +6,10 @@ import { Link } from 'react-router'; const ProjectTag = (props) => { const tag = props.tag.name; + const baseURL = props.project._type._name; return (
- + {tag} {' '} diff --git a/app/talk/recents.cjsx b/app/talk/recents.cjsx index c4e2063bc6..e42270adc0 100644 --- a/app/talk/recents.cjsx +++ b/app/talk/recents.cjsx @@ -9,6 +9,7 @@ Paginator = require './lib/paginator' projectSection = require './lib/project-section' updateQueryParams = require './lib/update-query-params' Loading = require('../components/loading-indicator').default +baseURL = require('./lib/base-url').default talkConfig = require './config' module.exports = createReactClass @@ -114,9 +115,8 @@ module.exports = createReactClass commentTitle: (comment) -> {if @props.params.owner and @props.params.name - baseURL = @props.project?._type._name {owner, name} = @props.params - + {comment.discussion_title} on {comment.board_title} else