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 an organisation Talk page #5415

Open
wants to merge 7 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
4 changes: 3 additions & 1 deletion app/pages/organization/organization-container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class OrganizationContainer extends React.Component {
}

render() {
const { user } = this.context;
const { children, params } = this.props;
const {
collaboratorView,
Expand Down Expand Up @@ -256,7 +257,8 @@ class OrganizationContainer extends React.Component {
organizationProjects,
projectAvatars,
quoteObject,
toggleCollaboratorView: this.toggleCollaboratorView
toggleCollaboratorView: this.toggleCollaboratorView,
user
});
} else if (fetchingOrganization) {
return (
Expand Down
33 changes: 33 additions & 0 deletions app/pages/organization/talk/index.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="project-text-content talk project">
<Helmet title={pageTitle} />
<div className="content-container">
<h1 className="talk-main-link">
<Link to={`/organizations/${props.organization.slug}/talk`}>
{organization.display_name} Talk
</Link>
</h1>
<TalkBreadcrumbs project={organization} {...props} />

<TalkSearchInput project={organization} {...props} />

{React.cloneElement(props.children, { section, project: organization, user })}

<TalkFootnote />
</div>
</div>
);
}
12 changes: 12 additions & 0 deletions app/router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ export const routes = (
<IndexRoute component={(require('./pages/organization/organization-page').default)} />
<Route path="home" component={ONE_UP_REDIRECT} />
<Route path="stats" component={(require('./pages/organization/stats').default)} />
<Route path="talk" component={require('./pages/organization/talk').default}>
<IndexRoute component={require('./talk/init')} />
<Route path="recents" component={require('./talk/recents')} />
<Route path="not-found" component={NotFoundPage} />
<Route path="search" component={require('./talk/search')} />
<Route path="moderations" component={require('./talk/moderations')} />
<Route path="subjects/:id" component={SubjectPageController} />
<Route path="recents/:board" component={require('./talk/recents')} />
<Route path="tags/:tag" component={require('./talk/tags')} />
<Route path=":board" component={require('./talk/board')} />
<Route path=":board/:discussion" component={require('./talk/discussion')} />
</Route>
</Route>

<Route path="notifications" component={NotificationsPage} />
Expand Down
3 changes: 2 additions & 1 deletion app/talk/board-preview.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -19,7 +20,7 @@ module.exports = createReactClass
boardId = @props.data.id

if @props.project
<Link to="/projects/#{owner}/#{name}/talk/#{boardId}">
<Link to="/#{baseURL(@props.project)}/#{owner}/#{name}/talk/#{boardId}">
{@props.data.title}
</Link>
else
Expand Down
5 changes: 3 additions & 2 deletions app/talk/board.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -232,7 +233,7 @@ module.exports = createReactClass
<h2>Moderator Zone:</h2>

{if @props.section isnt 'zooniverse'
<Link to="/projects/#{@props.params?.owner}/#{@props.params?.name}/talk/moderations">View Reported Comments</Link>
<Link to="/baseURL(@props.project)/#{@props.params?.owner}/#{@props.params?.name}/talk/moderations">View Reported Comments</Link>
else
<Link to="/talk/moderations">View Reported Comments</Link>
}
Expand Down Expand Up @@ -299,7 +300,7 @@ module.exports = createReactClass
{if @props.section is 'zooniverse'
<Link className="sidebar-link" to="/talk/recents/#{@props.params.board}">Recent Comments</Link>
else
<Link className="sidebar-link" to="/projects/#{@props.params.owner}/#{@props.params.name}/talk/recents/#{@props.params.board}">
<Link className="sidebar-link" to="/#{baseURL(@props.project)}/#{@props.params.owner}/#{@props.params.name}/talk/recents/#{@props.params.board}">
Recent Comments
</Link>}
</h3>
Expand Down
3 changes: 2 additions & 1 deletion app/talk/breadcrumbs.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
5 changes: 3 additions & 2 deletions app/talk/comment-link.cjsx
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions app/talk/comment.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -108,7 +109,7 @@ module.exports = createReactClass
commentSubjectTitle: (comment, subject) ->
{owner, name} = @props.params
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(@props.project)}/#{owner}/#{name}/talk/subjects/#{comment.focus_id}" onClick={@logItemClick.bind this, "view-subject-direct"}>
Subject {subject.id}
</Link>
else
Expand All @@ -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}/"
<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 +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 ""
<div className="talk-comment #{activeClass} #{isDeleted}">
<div className="talk-comment-author">
Expand All @@ -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}"
<div className="talk-comment-reply">
{if @state.replies.length
<div>
Expand Down Expand Up @@ -266,7 +267,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
12 changes: 6 additions & 6 deletions app/talk/discussion-preview.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';`
Expand All @@ -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}"
Expand Down
3 changes: 3 additions & 0 deletions app/talk/discussion-preview.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { shallow } from 'enzyme';
import DiscussionPreview from './discussion-preview';

const validProject = {
_type: {
_name: 'projects'
},
id: 34,
slug: 'test/project'
};
Expand Down
5 changes: 3 additions & 2 deletions app/talk/init.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -164,7 +165,7 @@ module.exports = createReactClass
</button>
</ZooniverseTeam>
{if @props.section isnt 'zooniverse'
<Link to="/projects/#{@props.params?.owner}/#{@props.params?.name}/talk/moderations">
<Link to="/#{baseURL(@props.project)}/#{@props.params?.owner}/#{@props.params?.name}/talk/moderations">
View Reported Comments
</Link>
else
Expand Down Expand Up @@ -200,7 +201,7 @@ module.exports = createReactClass
{if @props.section is 'zooniverse'
<Link className="sidebar-link" onClick={@logTalkClick.bind this, 'recent-comments-sidebar'} to="/talk/recents">Recent Comments</Link>
else
<Link className="sidebar-link" onClick={@logTalkClick.bind this, 'recent-comments-sidebar'} to="/projects/#{@props.params.owner}/#{@props.params.name}/talk/recents">Recent Comments</Link>
<Link className="sidebar-link" onClick={@logTalkClick.bind this, 'recent-comments-sidebar'} to="/#{baseURL(@props.project)}/#{@props.params.owner}/#{@props.params.name}/talk/recents">Recent Comments</Link>
}
</h3>
</section>
Expand Down
7 changes: 4 additions & 3 deletions app/talk/latest-comment-link.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

<Link className={className} onClick={logClick?.bind(this, childtext)} to={@context.router.createHref(locationObject)}>
{childtext}
Expand All @@ -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}/"

<div className="talk-latest-comment-link">
<div className="talk-discussion-link">
Expand Down
1 change: 1 addition & 0 deletions app/talk/lib/base-url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default resource => resource && resource._type._name
6 changes: 5 additions & 1 deletion app/talk/lib/project-section.coffee
Original file line number Diff line number Diff line change
@@ -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}"
3 changes: 2 additions & 1 deletion app/talk/popular-tags.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { Link } from 'react-router';

const ProjectTag = (props) => {
const tag = props.tag.name;
const baseURL = props.project._type._name;
return (
<div className="truncated">
<Link to={`/projects/${props.project.slug}/talk/tags/${tag}`} onClick={props.onClick} >
<Link to={`/${baseURL}/${props.project.slug}/talk/tags/${tag}`} onClick={props.onClick} >
{tag}
</Link>
{' '}
Expand Down
6 changes: 4 additions & 2 deletions app/talk/recents.cjsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -114,7 +116,7 @@ module.exports = createReactClass
<span>
{if @props.params.owner and @props.params.name
{owner, name} = @props.params
<Link to="/projects/#{owner}/#{name}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}">
<Link to="/#{baseURL(@props.project)}/#{owner}/#{name}/talk/#{comment.board_id}/#{comment.discussion_id}?comment=#{comment.id}">
{comment.discussion_title} on {comment.board_title}
</Link>
else
Expand Down