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

Implements a new conversation UI for an easy overview of all the comments on a case #173

Merged
merged 42 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c6166ac
Builds a UI for the most recent conversations around a case
cbothner Nov 17, 2017
222f2b6
Fills the recent comment threads list with real data
cbothner Nov 20, 2017
50919e9
Fills the selected comment thread interface with live data
cbothner Nov 20, 2017
c6e6ebf
Display blank selected comment pane while loading, rather than crashing
cbothner Nov 21, 2017
272b614
Switches the new comment form to an auto-resizing draft-js Editor
cbothner Nov 21, 2017
dbc2245
Makes the conversation view work on mobile
cbothner Nov 27, 2017
1593804
Uses the same SelectedCommentThread component for inline and converation
cbothner Nov 29, 2017
a1e3cf6
Uses priorities to keep only one FocusContainer active at a time
cbothner Nov 30, 2017
0963f17
Updates the CommentThreadsCard with the left side of Conversation
cbothner Nov 30, 2017
48aabed
Disables conversation view when the reader is not logged in
cbothner Dec 1, 2017
2abb6f5
“No comments” view in the RecentCommentThreads component
cbothner Dec 1, 2017
c0a94c8
Redirect to close the card when SelectedCommentThread is in situ w/o obj
cbothner Dec 1, 2017
96e280a
Makes the comment form work when there are no comments in the thread
cbothner Dec 1, 2017
0c12995
Moves babel-plugin-styled-components to prod dependencies
cbothner Dec 4, 2017
bef1b38
Makes the form for the first post in a comment thread longer
cbothner Dec 5, 2017
21a402e
Restores delete empty comment thread functionality
cbothner Dec 5, 2017
edf0f70
Allows for rich-text comments
cbothner Dec 6, 2017
687d8eb
Makes creating a new comment thread work—well, better—on mobile
cbothner Dec 6, 2017
55d293b
Fixes lists in CommentThreadItem exerpts
cbothner Dec 7, 2017
3637f9d
Fixes height of RecentCommentThreads ScrollView
cbothner Dec 7, 2017
346c982
Fixes the effects that adding/removing a thread has on cards/ui state
cbothner Dec 7, 2017
ea65c2e
Restores the delete comment button
cbothner Dec 7, 2017
762bbb6
Fixes the height of the ScrollView with FirstPostForm
cbothner Dec 8, 2017
afb0ec8
Disables conversation view when not applicable
cbothner Dec 8, 2017
fd3a8a0
Changes the color of the Less “Read More” link back to green
cbothner Dec 8, 2017
8767b7e
Adds aria-label back to delete comment button
cbothner Dec 8, 2017
0b17668
Adds a delete comment thread button next to the lead comment
cbothner Dec 8, 2017
97f912d
Fixes parsing of cards that only have old-style serialization
cbothner Dec 8, 2017
0fb23fb
Improves the look of the CommentThreadsCard and the NewCommentButton
cbothner Dec 8, 2017
097b8e2
Only shows the delete comment and delete thread buttons to the editor
cbothner Dec 8, 2017
c5b7bcd
Fixes moderating comment thread test
cbothner Dec 11, 2017
baeb9a8
Fixes leaving a comment spec
cbothner Dec 11, 2017
1327247
Fixes tests
cbothner Dec 11, 2017
fa69845
Adds a basic test of the conversation view
cbothner Dec 12, 2017
a2226fa
Links to conversation view from reply notification emails
cbothner Dec 12, 2017
76c546a
Links to the conversation view from the toast reply notifications
cbothner Dec 12, 2017
531276e
Removes the New Response button from the empty recent comments view
cbothner Dec 12, 2017
828265e
Adds a sourcemap in production
cbothner Dec 13, 2017
b01fcd9
Fixes race condition when SelectedCommentThread mounts w/o threads api
cbothner Dec 13, 2017
4ef1970
Cards and CommentThreadItems scroll into view when needed
cbothner Dec 13, 2017
f25f90a
Makes sure the response form isn’t too close to the bottom on iOS
cbothner Dec 13, 2017
c8f553e
Deletes unused code from old inline comments interface
cbothner Dec 13, 2017
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
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
],

"plugins": [
"babel-plugin-styled-components",
"syntax-dynamic-import",
"transform-object-rest-spread",
["transform-class-properties", { "spec": true }]
Expand Down
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.*/node_modules/jsonlint-lines-primitives

[include]
./node_modules/immutable
./node_modules/fbjs/flow/lib

[libs]
Expand Down
3 changes: 3 additions & 0 deletions app/assets/stylesheets/CaseOverview.sass
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@

.CaseOverviewRight
+flex($fg: 0, $fs: 1, $fb: 20em)
@media screen and (max-width: $mobileCutoff)
+flex($fg: 1, $fs: 1, $fb: 20em)

min-width: 15em
& > *
margin: 1em
Expand Down
32 changes: 0 additions & 32 deletions app/assets/stylesheets/CommentThread.sass
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,6 @@
background-color: #bfaeec

.CommentThreads
position: absolute
top: 0
right: -290px
width: 267px
font-family: $sansFont
font-weight: 500
font-size: 12pt

&__footer
border-top: 1px solid #351D7A
padding: 0.25em
display: flex

& > *
flex-grow: 1

& .CommentThreads__new-button.o-button
width: 100% !important
background-color: $darkPurple
margin: 0
padding: 0.5em
border-width: 0
font-size: 11pt
letter-spacing: 0.4px
font-weight: 500
color: white
&:hover,
&:focus
background-color: darken($darkPurple, 10%)
&:disabled
cursor: initial
background-color: transparent

&__banner
+banner
Expand Down
5 changes: 3 additions & 2 deletions app/assets/stylesheets/Narrative.sass
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ article
position: relative

p,
div[data-block]
& > .DraftEditor-root div[data-block],
& > div > .DraftEditor-root div[data-block]
margin: 1em 0

@media screen and (max-width: $mobileCutoff)
Expand All @@ -103,7 +104,7 @@ article
background-color: rgb(159, 187, 214)
text-shadow: none

a:not([data-edgenote])
.DraftEditor-root a:not(.c-edgenote-entity):not(.c-edgenote-entity--inactive):not(.pt-button)
color: $darkGreen

&:hover
Expand Down
9 changes: 4 additions & 5 deletions app/controllers/comment_threads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CommentThreadsController < ApplicationController
def index
@forum = current_reader.active_community.forums.find_by(case: @case)
@comment_threads = if @forum.nil?
[]
CommentThread.none
else
@forum.comment_threads
.visible_to_reader?(current_reader)
Expand All @@ -34,7 +34,7 @@ def create
def show
current_reader.update active_community_id: @comment_thread.forum
.community.id
redirect_to inline_comment_thread_url @comment_thread
redirect_to conversation_comment_thread_url @comment_thread
end

def destroy
Expand Down Expand Up @@ -64,9 +64,8 @@ def comment_thread_params
params.require(:comment_thread).permit(:start, :length, :block_index, :original_highlight_text)
end

def inline_comment_thread_url(comment_thread)
def conversation_comment_thread_url(comment_thread)
"#{case_url(I18n.locale, comment_thread.card.case.slug)}" \
"/#{comment_thread.card.element.case_element.position}" \
"/cards/#{comment_thread.card_id}/comments/#{comment_thread.id}"
"/conversation/#{comment_thread.id}"
end
end
4 changes: 4 additions & 0 deletions app/javascript/Case.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ const PreTest = asyncComponent(() =>
const PostTest = asyncComponent(() =>
import('quiz/PostTest').then(m => m.default)
)
const Conversation = asyncComponent(() =>
import('conversation').then(m => m.default)
)

function mapStateToProps ({ quiz, caseData }: State) {
return {
Expand Down Expand Up @@ -125,6 +128,7 @@ class Case extends React.Component<{
<Route exact path="/" component={CaseOverview} />
<Route path={needsPretest ? '/*' : 'miss'} component={PreTest} />
<Route path={hasQuiz ? '/quiz/' : 'miss'} component={PostTest} />
<Route path="/conversation" component={Conversation} />
<Route path="/:position/" component={CaseElement} />
</Switch>
</div>
Expand Down
30 changes: 20 additions & 10 deletions app/javascript/card/CardContents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import Statistics from 'utility/Statistics'
import CitationTooltip from './CitationTooltip'
import CommentThreadsTag from 'comments/CommentThreadsTag'
import { OnScreenTracker } from 'utility/Tracker'
import { FocusContainer } from 'utility/A11y'
import { ScrollIntoView } from 'utility/ScrollView'

import type { ContextRouter, Match } from 'react-router-dom'

Expand Down Expand Up @@ -111,6 +113,7 @@ class CardContents extends React.Component<Props, *> {
theseCommentThreadsOpen,
hoveredCommentThread,
selectedCommentThread,
acceptingSelection,
readOnly,
commentable,
title,
Expand Down Expand Up @@ -140,18 +143,25 @@ class CardContents extends React.Component<Props, *> {
transition: 'padding-top 0.1s, flex 0.3s',
}}
>
{theseCommentThreadsOpen ? <ScrollIntoView /> : null}

{editing && <EditorToolbar cardId={id} />}
{title}
<Editor
readOnly={readOnly}
customStyleMap={styleMap}
onChange={(eS: EditorState) => onChange(eS)}
{...{
blockRenderMap,
editorState,
handleKeyCommand,
}}
/>
<FocusContainer
active={!!(theseCommentThreadsOpen && acceptingSelection)}
priority={100}
>
<Editor
readOnly={readOnly}
customStyleMap={styleMap}
onChange={(eS: EditorState) => onChange(eS)}
{...{
blockRenderMap,
editorState,
handleKeyCommand,
}}
/>
</FocusContainer>

{commentable &&
solid && <CommentThreadsTag cardId={id} match={match} />}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function mapStateToProps (
const anyCommentThreadsOpen = matchPath(pathname, commentThreadsOpen())
const anyCommentsOpen = matchPath(pathname, commentsOpen())
const selectedCommentThread =
anyCommentsOpen && anyCommentsOpen.params.commentThreadId
anyCommentsOpen && anyCommentsOpen.params.threadId

return {
commentable:
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/catalog/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const Sidebar = ({
image={reader.imageUrl}
text={reader.name}
href="/profile/edit"
hashKey={reader.email}
hashKey={reader.hashKey}
/>
<Enrollments
loading={loading}
Expand All @@ -62,5 +62,8 @@ export const Container = styled.aside`
const IdentigradientElement = styled(Element)`
& > ${ElementImage} {
${identiconStyle};
&:after {
font-size: 16px;
}
}
`
18 changes: 10 additions & 8 deletions app/javascript/catalog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type State = {|
features: string[],
|}

class Catalog extends React.Component<{ intl: IntlShape }, State> {
export class Catalog extends React.Component<{ intl: IntlShape }, State> {
state = {
loading: { reader: true, cases: true },
reader: null,
Expand All @@ -48,13 +48,15 @@ class Catalog extends React.Component<{ intl: IntlShape }, State> {
`${intl.formatMessage({
id: 'catalog.unenrollConfirmation',
defaultMessage: 'Are you sure you want to unenroll in this case?',
})}${options.displayBetaWarning
? `\n\n${intl.formatMessage({
id: 'catalog.unenrollBetaWarning',
defaultMessage:
'Because this case is not published, you will need another invitation to reenroll.',
})}`
: ''}`
})}${
options.displayBetaWarning
? `\n\n${intl.formatMessage({
id: 'catalog.unenrollBetaWarning',
defaultMessage:
'Because this case is not published, you will need another invitation to reenroll.',
})}`
: ''
}`
)
) {
return
Expand Down
59 changes: 0 additions & 59 deletions app/javascript/comments/Comment.jsx

This file was deleted.

Loading