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..4cb50821d5 --- /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 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 = projectSection(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 351a85fea2..4085c8fe18 100644 --- a/app/router.jsx +++ b/app/router.jsx @@ -294,6 +294,18 @@ export const routes = ( + + + + + + + + + + + + diff --git a/app/talk/board-preview.cjsx b/app/talk/board-preview.cjsx index afbbd296e2..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' @@ -19,7 +20,7 @@ module.exports = createReactClass boardId = @props.data.id if @props.project - + {@props.data.title} else diff --git a/app/talk/board.cjsx b/app/talk/board.cjsx index 116eea096e..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' @@ -232,7 +233,7 @@ module.exports = createReactClass

Moderator Zone:

{if @props.section isnt 'zooniverse' - View Reported Comments + View Reported Comments else View Reported Comments } @@ -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/comment-link.cjsx b/app/talk/comment-link.cjsx index 80f64571bb..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,8 +21,8 @@ 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}" + {comment, project} = @props + "/#{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 25e8be4fb2..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' @@ -108,7 +109,7 @@ module.exports = createReactClass commentSubjectTitle: (comment, subject) -> {owner, name} = @props.params if (comment.focus_type is 'Subject') and (owner and name) - + Subject {subject.id} else @@ -130,7 +131,7 @@ module.exports = createReactClass replyLine: (comment) -> baseLink = "/" if @props.project? - baseLink += "projects/#{@props.project.slug}/" + baseLink += "#{baseURL(@props.project)}/#{@props.project.slug}/"

{comment.user_display_name} @@ -168,7 +169,7 @@ 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}" + profile_link = "/#{baseURL(@props.project)}/#{@props.project.slug}#{profile_link}" author_login = if @props.author?.login then "@#{@props.author.login}" else ""

@@ -188,7 +189,7 @@ 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}" + profile_link = "/#{baseURL(@props.project)}/#{@props.project.slug}#{profile_link}"
{if @state.replies.length
@@ -266,7 +267,7 @@ module.exports = createReactClass
{switch @state.showing - when 'link' then + when 'link' then when 'report' then }
diff --git a/app/talk/discussion-preview.cjsx b/app/talk/discussion-preview.cjsx index a7a8231563..a360fa651b 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/getSubjectLocation').default # `import Thumbnail from '../components/thumbnail';` @@ -19,15 +20,14 @@ module.exports = createReactClass project: {} discussionLink: -> - {discussion} = @props + {discussion, project} = @props - if (@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 - "/projects/#{owner}/#{name}/talk/#{discussion.board_id}/#{discussion.id}" + "/#{baseURL(project)}/#{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 (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/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' }; diff --git a/app/talk/init.cjsx b/app/talk/init.cjsx index bab452857c..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' @@ -164,7 +165,7 @@ module.exports = createReactClass {if @props.section isnt 'zooniverse' - + View Reported Comments else @@ -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..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' @@ -54,9 +55,9 @@ module.exports = createReactClass locationObject = pathname: "/talk/#{@props.discussion.board_id}/#{@props.discussion.id}" query: query - if @props.params?.owner and @props.params?.name + if @props.project and @props.params?.owner and @props.params?.name {owner, name} = @props.params - locationObject.pathname = "/projects/#{owner}/#{name}" + locationObject.pathname + locationObject.pathname = "/#{baseURL(@props.project)}/#{owner}/#{name}" + locationObject.pathname {childtext} @@ -74,7 +75,7 @@ module.exports = createReactClass baseLink = "/" if @props.project? and @props.project.slug? - baseLink += "projects/#{@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/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/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 5bd79ea844..e42270adc0 100644 --- a/app/talk/recents.cjsx +++ b/app/talk/recents.cjsx @@ -6,8 +6,10 @@ 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 +baseURL = require('./lib/base-url').default talkConfig = require './config' module.exports = createReactClass @@ -52,7 +54,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 @@ -114,7 +116,7 @@ module.exports = createReactClass {if @props.params.owner and @props.params.name {owner, name} = @props.params - + {comment.discussion_title} on {comment.board_title} else