Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Reviews dock item #1995

Merged
merged 742 commits into from Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
742 commits
Select commit Hold shift + click to select a range
af51ec4
Open the ReviewsItem and jump to the thread on gutter decoration click
smashwilson Mar 27, 2019
c4ecfa7
Fade in a border color on highlighted comment threads
smashwilson Mar 27, 2019
c747540
Remove line number and button background decorations
smashwilson Mar 27, 2019
bbf510d
Reset thread highlight after 1.5s
smashwilson Mar 27, 2019
6a5078c
Support decorating inherited decorables on prop-provided editors
smashwilson Mar 27, 2019
ebf97e6
Use the <Decoration> fix to avoid creating unnecessary markers
smashwilson Mar 27, 2019
0fc62e9
add test scaffolding for `CommentDecorationsContainer`
Mar 25, 2019
18ad661
"start a review" should link to files tab on dotcom
Mar 26, 2019
8749628
why did i commit an empty test
Mar 26, 2019
f386239
[wip] CommentDecorationsContainer tests
Mar 27, 2019
11d0774
Render <BareReviewsController> instead of <ReviewsController>
smashwilson Mar 27, 2019
a5f8ff0
EditorCommentDecorationsController tests :white_check_mark: + :100:
smashwilson Mar 27, 2019
30745c8
add link for reporting abuse
Mar 27, 2019
f579bee
unit test for `CommentDecorationsContainer` happy path
Mar 27, 2019
1b0debd
:fire: unused import
smashwilson Mar 28, 2019
2831257
:fire: diagnostic console.log
smashwilson Mar 28, 2019
ff95ffd
Consistent <detail> toggle methods
smashwilson Mar 28, 2019
f1d8233
Use native path separators in ReviewsView
smashwilson Mar 28, 2019
56f08d6
Use native paths in CommentDecorationsController
smashwilson Mar 28, 2019
98fd876
Update IssueDetailView test
smashwilson Mar 28, 2019
9e156ec
Accumulator tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
91ccc49
ReviewThreadsAccumulator tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
f9e1686
ReviewsContainer tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
92b244f
ReviewCommentsAccumulator tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
d3b7153
ReviewSummariesAccumulator tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
9107f16
PullRequestDetailView tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
c865c66
PR Checkout integration test :white_check_mark:
smashwilson Mar 28, 2019
29c2b3d
get rid of the PullRequestReviewCommentThreadView component
vanessayuenn Mar 28, 2019
4c67d31
use gutter instead for comments
vanessayuenn Mar 28, 2019
97299ca
unused import
vanessayuenn Mar 28, 2019
8807503
Instead of creating gutter within <Decoration>, we could just do a gu…
vanessayuenn Mar 28, 2019
5923660
Fix up the in editor gutter decorations
vanessayuenn Mar 28, 2019
708caa8
unused import
vanessayuenn Mar 28, 2019
619f95a
AggregatedReviewsContainer tests :white_check_mark: + :100:
smashwilson Mar 28, 2019
8bf4785
Get that one CommentDecorationsContainer test passing
smashwilson Mar 28, 2019
f12b2d1
Get the remaining written ReviewsView tests passing
smashwilson Mar 28, 2019
1de70d0
Exclude superstring from the snapshot test
smashwilson Mar 28, 2019
3a87b38
only do a console.error for now so i dont block people
vanessayuenn Mar 28, 2019
9b6d6eb
When trying to decorate a gutter, don't do it right away; instead wai…
vanessayuenn Mar 28, 2019
77d9870
remember to dispose the sub!
vanessayuenn Mar 28, 2019
787f086
use report abuse icon instead of text
Mar 28, 2019
2111e3a
grammar
vanessayuenn Mar 28, 2019
3e2c0cf
refactor out the comment gutter decoration to a shared component
vanessayuenn Mar 28, 2019
15b4019
use the new `CommentGutterDecorationController`
vanessayuenn Mar 28, 2019
e7c5b22
unused imports
vanessayuenn Mar 28, 2019
ff6b639
drill the props
vanessayuenn Mar 28, 2019
0a9b523
vertically align the icon
vanessayuenn Mar 29, 2019
52b301d
only you can prevent prop type errors
Mar 29, 2019
473a37c
add alllll the metrics
Mar 29, 2019
354ed3e
fix typo
Mar 29, 2019
eee9b04
metrics for adding/removing emoji reactions
Mar 29, 2019
86bc5af
Include review comment state in ReviewCommentsAccumulator
smashwilson Mar 29, 2019
930aa8d
Render and style a "pending" badge on pending comments
smashwilson Mar 29, 2019
81a0196
Depend directly on lodash.isequal
smashwilson Mar 29, 2019
1947e4a
Use deep equality to compare variables when finding a Relay expectation
smashwilson Mar 29, 2019
06760f7
definition.operation can be 'query' or 'mutation'
smashwilson Mar 29, 2019
2716128
make the comment gutter have selected line highlighting also
vanessayuenn Mar 29, 2019
9cadbca
Build a GraphQL response with errors reported
smashwilson Mar 29, 2019
1788283
Mutation fields on the builder for the operation root
smashwilson Mar 29, 2019
cb91d71
Omit unused variables entirely (as opposed to passing `undefined`)
smashwilson Mar 29, 2019
8d43ec6
Me being picky about PropTypes ordering
smashwilson Mar 29, 2019
524255d
Add builder fields for ReviewsController tests
smashwilson Mar 29, 2019
86c12fe
Oh that needs to throw instead of return a payload
smashwilson Mar 29, 2019
9f514d6
Drill atom.notifications to the ReviewsController
smashwilson Mar 29, 2019
338434c
Report comment mutation errors as Atom notifications
smashwilson Mar 29, 2019
5874391
respect the line highlighting color combo for gutter comment icons
vanessayuenn Mar 29, 2019
7f74d8a
don't need an empty prop anymore
vanessayuenn Mar 29, 2019
3c97eb7
Return a Promise from unresolveReviewThread
smashwilson Mar 29, 2019
4eeae65
Builder fields for resolve and unresolve mutations
smashwilson Mar 29, 2019
3cd5776
Test (un)resolve actions and error handling
smashwilson Mar 29, 2019
3dd65a6
Lift mutation error reporting to RootController
smashwilson Mar 29, 2019
b4bce5b
Drill reportMutationErrors into IssueishDetailItem
smashwilson Mar 29, 2019
0246b3d
need some extra fields from repository
vanessayuenn Mar 29, 2019
54618b4
lint
vanessayuenn Mar 29, 2019
9261a7b
add reviews button to the current checked out PR header
vanessayuenn Mar 29, 2019
d58b6d9
don't show reviews button when there is no checked out PR
vanessayuenn Mar 29, 2019
32626cb
:art:
vanessayuenn Mar 29, 2019
ea3fdef
Builders for Reactable fields and (add|remove)Reaction mutations
smashwilson Apr 1, 2019
a22c1f5
Consistently end builder class names with "Builder"
smashwilson Apr 1, 2019
7601d33
Test EmojiReactionsController mutations and error reporting
smashwilson Apr 1, 2019
02b0dbc
Center loading spinner on stub Review items
smashwilson Apr 1, 2019
ee03863
test for the correct error message
vanessayuenn Apr 1, 2019
97232fe
fix gutter decoration test
vanessayuenn Apr 1, 2019
c57f885
add test to ensure attempt to decorate a non-existent gutter does not…
vanessayuenn Apr 1, 2019
5ca0288
:fire: .only
vanessayuenn Apr 1, 2019
b02c445
add tests for INSUFFICIENT and UNAUTHENTICATED tokens
Apr 1, 2019
be7edf0
add tests for query rendering in `CommentDecorationsContainer`
Apr 1, 2019
adc0fa5
:art: test descriptions and order
Apr 1, 2019
c44fffc
testy test test for CommentGutterDecorationController
vanessayuenn Apr 1, 2019
94475ab
be more specific about where the event is firing from
vanessayuenn Apr 1, 2019
694f0fb
weee more tests
vanessayuenn Apr 1, 2019
fd937f5
lint
vanessayuenn Apr 1, 2019
f6beaec
actually be even more specific in the metric reporting about which gu…
vanessayuenn Apr 1, 2019
e9c0271
properly bind `logStartReviewClick`
Apr 1, 2019
2587b41
test for event reporting in `ReviewsView`
Apr 1, 2019
2ca915d
fix same mistake in `ReviewsFooterView`
Apr 1, 2019
f9d080b
:fire: unused import
kuychaco Mar 28, 2019
5156ca7
Add preserveOriginal option when building patches for PrPatchContainer
kuychaco Apr 1, 2019
8110ef7
Lift AggregatedReviewsContainer to ReviewsContainer
kuychaco Apr 1, 2019
76c8bea
Add Repository#getDiffsForFilePath method to get working directory ch…
kuychaco Apr 1, 2019
bd7f937
Set default value of `preserveOriginal` to false
kuychaco Apr 1, 2019
b133842
Add MultiFilePatch#getPatchForPath method
kuychaco Apr 1, 2019
087b191
Create CommentPositioningContainer and use it in ReviewsContainer
kuychaco Apr 1, 2019
61e2eb2
Translate lines for jump-to-file
kuychaco Apr 1, 2019
1dedad9
:fire: unused import and prop
kuychaco Apr 1, 2019
4446493
More cleanup
kuychaco Apr 1, 2019
c4ad139
Remove `isRequired` since prop starts out as null
kuychaco Apr 1, 2019
549b469
Move translation logic to ReviewsView to display correct line number
kuychaco Apr 2, 2019
c3c14fa
typo omg 🙈
vanessayuenn Apr 2, 2019
9c7b55c
WIP Start moving AggregatedReviewsContainer to CommentDecorationsCont…
kuychaco Apr 2, 2019
a213d86
Revert "WIP Start moving AggregatedReviewsContainer to CommentDecorat…
kuychaco Apr 2, 2019
81ac713
`reviews-item` test :100:
vanessayuenn Apr 2, 2019
f061877
Revert "Revert "WIP Start moving AggregatedReviewsContainer to Commen…
smashwilson Apr 2, 2019
6b4e857
Optionally convert comment paths to absolute paths
smashwilson Apr 2, 2019
3caa463
Lift review thread aggregation to CommentDecorationsContainer
smashwilson Apr 2, 2019
9947619
:gear: relay-compiler :gear:
smashwilson Apr 2, 2019
adb2577
:memo: Touch up a comment apparently
smashwilson Apr 2, 2019
e2d8415
add required props to `ReviewsView` tests
Apr 2, 2019
01b245d
add test for mounting commands
Apr 2, 2019
068e2e3
make openFile async for consistency
vanessayuenn Apr 2, 2019
93ef566
test action methods of review controller
vanessayuenn Apr 2, 2019
df48a81
tests for the state management of the summary & comment accordions
vanessayuenn Apr 2, 2019
b11cebf
`reviews-controllers` test coverage :100::tada:
vanessayuenn Apr 2, 2019
0aa4a7f
jk missed one test
vanessayuenn Apr 2, 2019
8518a57
:shirt:
Apr 2, 2019
d79717a
checkout button test
Apr 2, 2019
ccfa39c
Mark builder fields as nullable
smashwilson Apr 2, 2019
b0eb39d
CommentDecorationsContainer :white_check_mark: + :100:
smashwilson Apr 2, 2019
cd3146e
EditorCommentDecorationsController tests :white_check_mark: + :100:
smashwilson Apr 2, 2019
2b3195c
CommentPositioningContainer tests :white_check_mark: + :100:
smashwilson Apr 2, 2019
fc329ec
Use global sinon sandbox
smashwilson Apr 2, 2019
3572989
Create sinon spies in beforeEach() blocks
smashwilson Apr 2, 2019
c0c1336
ReviewsContainer tests :white_check_mark: again, but not :100:
smashwilson Apr 2, 2019
9b15eb5
Provide a default reviewsButton prop to Accordion
smashwilson Apr 2, 2019
54ec555
(tests for) making (re)fetch happen
Apr 2, 2019
3bfe40a
remove `AggregatedReviewsContainer` from `ReviewsView` tests
Apr 2, 2019
acc1f01
use sinon in beforeEach blocks
Apr 2, 2019
65b1570
fucked up that merge somehow
Apr 2, 2019
877ed88
:fire: unused import
Apr 2, 2019
102e38a
fallback when comment translations are not provided
Apr 2, 2019
3c47015
Test for comment decorations instead of comment thread views
smashwilson Apr 2, 2019
e50400f
:shirt: mostly unused imports
smashwilson Apr 2, 2019
4df3af9
resolve / unresolve thread tests
Apr 3, 2019
d500945
:skull: dead code
Apr 3, 2019
b254fa5
test for reply buttons
Apr 3, 2019
6eb19fa
add tests for CommentDecorationsController
vanessayuenn Apr 2, 2019
4a516ec
thank u, istanbul ignore next
vanessayuenn Apr 3, 2019
a6e95dc
add checks for empty renders
vanessayuenn Apr 3, 2019
7a2a87f
last one yay :tada:
vanessayuenn Apr 3, 2019
3e812d6
🙅‍ .only
vanessayuenn Apr 3, 2019
44092ab
wrong thread oopsie woopsie
Apr 3, 2019
d5ee88c
No mutations here, istanbul, shhh, shhhhh
smashwilson Apr 3, 2019
cb78c6c
test addSingleComment args
Apr 3, 2019
21dd94c
ReviewsFooterView tests
vanessayuenn Apr 3, 2019
a7313e8
Cover or ignore those last few straggling lines in MFPView
smashwilson Apr 3, 2019
408e080
CurrentPullRequestContainer tests :100:
smashwilson Apr 3, 2019
6070c5f
add test for new open reviews button in checked out PR issueish list …
vanessayuenn Apr 3, 2019
eec5876
why is it even called istanbul and not izmir though
vanessayuenn Apr 3, 2019
f31a46c
Adjust position in EditorCommentDecorationsController based on file t…
kuychaco Apr 3, 2019
70ad909
Don't update EditorCommentDecorationsController
kuychaco Apr 3, 2019
615c3ab
Revert "fallback when comment translations are not provided"
kuychaco Apr 3, 2019
343ea7d
Use file translation in ReviewsView
kuychaco Apr 3, 2019
e17b22b
WIP update fileTranslation map upon saving
kuychaco Apr 3, 2019
18779be
Use published whats-my-line npm package
kuychaco Apr 3, 2019
5544ea7
"retry" is null while loading
smashwilson Apr 3, 2019
2a33311
add opens reviews test for IssueishListController
vanessayuenn Apr 3, 2019
9e1dbb9
Manage TextEditor event subscriptions in CommentDecorationsContainer
smashwilson Apr 3, 2019
6e22622
Extract CommentPositioning "info" objects into a class
smashwilson Apr 3, 2019
247eca7
Bring translationDigestFrom() up to date
smashwilson Apr 3, 2019
b310091
Back out the invalidateCachedDiffForFile() repository method
smashwilson Apr 3, 2019
92f1ce3
include selected tab in URI serialization test
vanessayuenn Apr 3, 2019
7b91069
should make sure the state is set before switching tab
vanessayuenn Apr 3, 2019
97c530e
[WIP] add tab navigation tests
vanessayuenn Apr 3, 2019
f41b958
finish up issueish tab navigation tests
vanessayuenn Apr 3, 2019
29f3f2c
clean up after yourself
vanessayuenn Apr 3, 2019
e71dfaf
dammit .only
vanessayuenn Apr 3, 2019
b7fb1be
Generate correct cache keys for getDiffsForFilePath()
smashwilson Apr 3, 2019
1cfecf4
pass `workingDirectory` prop to `IssueishListController`
Apr 3, 2019
9347c0e
buybye console logging
Apr 3, 2019
b4a72d4
Manage Marker positions within EditorCommentDecorationsController
smashwilson Apr 3, 2019
8001085
Use a model observer to collect diffsused for comment positioning
smashwilson Apr 3, 2019
1eee51f
Remove the manual positioning update trigger function
smashwilson Apr 3, 2019
51046dc
Remove updateTranslations callers
smashwilson Apr 3, 2019
0cae1dd
:art: use consistent button style & copy for "Start a review"
vanessayuenn Apr 3, 2019
99e7a7b
fix `ReviewsView` tests
Apr 3, 2019
545382f
:shirt:
Apr 3, 2019
1befa6b
Select <a> element in empty state
smashwilson Apr 4, 2019
9f20f76
Respect initThreadID and scrollToThreadID on mount
smashwilson Apr 4, 2019
2d74556
Re-jump to a thread
smashwilson Apr 4, 2019
6e5ea4a
"delete PR review" mutation
smashwilson Apr 4, 2019
c206c19
GraphQL builder fields for delete review mutation
smashwilson Apr 4, 2019
3d6ec89
Include path and position in optimistically updated review comment
smashwilson Apr 4, 2019
0c66f54
Delete a temporary pending review if comment submission fails
smashwilson Apr 4, 2019
f19ffb2
Account for Windows path separators
smashwilson Apr 4, 2019
f771cbf
No longer need to install the SSH key
smashwilson Apr 4, 2019
150b8b5
only get new file positions for checked out pull requests
Apr 4, 2019
591160f
use comment position instead of the translated line number when deali…
vanessayuenn Apr 4, 2019
d4dd504
don't try to update filePatches that don't exist
Apr 4, 2019
71f01f2
Return the Disposable created by props.relay.refetch
smashwilson Apr 4, 2019
56e0280
Cancel a refetch in progress when the ReviewsItem is closed
smashwilson Apr 4, 2019
8eb5140
fake news!
vanessayuenn Apr 4, 2019
09ae950
Return "null" and log invalid getBufferRowForDiffPosition calls
smashwilson Apr 4, 2019
d24d587
getPreviewPatchBuffer() returns an empty buffer for invalid arguments
smashwilson Apr 4, 2019
35f3daf
Skip review threads with unmappable paths or positions
smashwilson Apr 4, 2019
037045b
Ignore requests to scroll to unrecognized files and positions
smashwilson Apr 4, 2019
cc3451c
:knife: unused PullRequestReviewCommentThreadView
smashwilson Apr 4, 2019
2689465
Support the undocumented "exclusive" marker property
smashwilson Apr 4, 2019
6b10320
Mark the entire buffer row of a row that contains a comment
smashwilson Apr 4, 2019
24d6e37
Mark the entire row for the CommentGutterDecoration
smashwilson Apr 4, 2019
3c29644
Submit the current reply comment with (cmd|ctrl)-enter
smashwilson Apr 4, 2019
4f9498c
:fire: unused import
smashwilson Apr 4, 2019
bea74db
Drill the command registry to CommentDecorationsController
smashwilson Apr 4, 2019
d38a4bf
Open the Reviews tab with a command
smashwilson Apr 4, 2019
3ab2ee7
Keybindings and menus, oh my
smashwilson Apr 4, 2019
c035602
Remove .is-focused styling from atom-text-editor
smashwilson Apr 4, 2019
87ddaac
Include an (empty) reaction group in the optimistic comment response
smashwilson Apr 4, 2019
58d5f93
use the button color instead for comment highlight border
vanessayuenn Apr 4, 2019
3eb7049
add a nice glowy border to emphasize the highlight
vanessayuenn Apr 4, 2019
2fd4db4
i think this `transition-duration` property gets overridden anyway
vanessayuenn Apr 4, 2019
0322a78
we don't actually use the check mark to indicate resolved comments an…
vanessayuenn Apr 5, 2019
1fb2af2
clean up unused css classes
vanessayuenn Apr 5, 2019
f670b75
prefers `em` over `px` whenever possible 🤔
vanessayuenn Apr 5, 2019
7d15d71
Remove unused GraphQL fields
smashwilson Apr 5, 2019
60407c8
Remove unused fetchParams entry
smashwilson Apr 5, 2019
f9c9a39
Remove unused method
smashwilson Apr 5, 2019
1953be7
Use a method to derive typename instead of getDerivedStateFromProps()
smashwilson Apr 5, 2019
b77aa70
Accept an object for IssueishDetailItem.buildURI()
smashwilson Apr 5, 2019
9e46359
Rename setState() variable
smashwilson Apr 5, 2019
8c80810
Use a didFailComment callback to restore the body of a failed comment
smashwilson Apr 5, 2019
62faa80
:fire: unused import
smashwilson Apr 5, 2019
8e6e37c
Describe the commentTranslations structure with a comment
smashwilson Apr 5, 2019
7d7a289
Refactor getTranslatedPosition() out of renderReviewCommentThread()
smashwilson Apr 5, 2019
c289ff0
Remove TODO
smashwilson Apr 5, 2019
bea411b
ReviewsItem.buildURI() accepts an options object
smashwilson Apr 5, 2019
141bbfc
make copying works for all `GithubDotcomMarkdown` components
vanessayuenn Apr 5, 2019
fe291a9
Supply a default value for selectedTab when building a URL
smashwilson Apr 5, 2019
d8a947d
Prevent PullRequestPatchContainer from calling setState after unmount
smashwilson Apr 5, 2019
a146aff
Pass props recovered from the StubItem to support deserialized state
smashwilson Apr 5, 2019
984144b
Move IssueishDetailItem selected tab state into the item
smashwilson Apr 5, 2019
c1842ff
Deserialize the selected tab
smashwilson Apr 5, 2019
88b2b96
Pass selectedTab from state properly
smashwilson Apr 5, 2019
f5f7b57
No need for that onTabSelected() call
smashwilson Apr 5, 2019
27b4f2e
Place the cursor on the comment line in the MFP View :ok_hand:
smashwilson Apr 5, 2019
9a4d0bf
Unbreak tests
smashwilson Apr 5, 2019
7a3a14b
Intentionally skip deleted and hidden files when placing diff comments
smashwilson Apr 5, 2019
b292c04
Actually pass {bypassReadOnly: true} when setting text
kuychaco Apr 5, 2019
1570afe
:fire: unused data-diff attribute
kuychaco Apr 6, 2019
229acd5
Render the "add emoji" button when no reaction groups are present
smashwilson Apr 8, 2019
c7adcb4
Set reactionGroups to [] on optimistically rendered PR review comments
smashwilson Apr 8, 2019
dcd0ad6
:scissors: stale comment
smashwilson Apr 8, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2,719 changes: 2,267 additions & 452 deletions graphql/schema.graphql

Large diffs are not rendered by default.

75 changes: 75 additions & 0 deletions img/mona.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions keymaps/git.cson
Expand Up @@ -9,6 +9,7 @@
'alt-g p': 'github:push'
'alt-g shift-p': 'github:force-push'
'alt-g =': 'github:clone'
'alt-g r': 'github:open-reviews-tab'

'atom-text-editor':
'alt-m 1': 'github:resolve-as-ours'
Expand Down Expand Up @@ -132,3 +133,20 @@
'end': 'github:co-author:end'
'delete': 'github:co-author:delete'
'shift-backspace': 'github:co-author-exclude'

'.platform-darwin .github-Reviews':
'cmd-=': 'github:more-context'
'cmd--': 'github:less-context'
'.platform-win32 .github-Reviews':
'ctrl-=': 'github:more-context'
'ctrl--': 'github:less-context'
'.platform-linux .github-Reviews':
'ctrl-=': 'github:more-context'
'ctrl--': 'github:less-context'

'.platform-darwin .github-Review-reply atom-text-editor':
'cmd-enter': 'github:submit-comment'
'.platform-win32 .github-Review-reply atom-text-editor':
'ctrl-enter': 'github:submit-comment'
'.platform-linux .github-Review-reply atom-text-editor':
'ctrl-enter': 'github:submit-comment'
4 changes: 1 addition & 3 deletions lib/atom/atom-text-editor.js
Expand Up @@ -18,7 +18,7 @@ const editorUpdateProps = {
};

const editorCreationProps = {
buffer: PropTypes.object, // FIXME make proptype more specific
buffer: PropTypes.object,
...editorUpdateProps,
};

Expand All @@ -30,8 +30,6 @@ export default class AtomTextEditor extends React.Component {
static propTypes = {
...editorCreationProps,

workspace: PropTypes.object.isRequired,

didChangeCursorPosition: PropTypes.func,
didAddSelection: PropTypes.func,
didChangeSelectionRange: PropTypes.func,
Expand Down
60 changes: 41 additions & 19 deletions lib/atom/decoration.js
Expand Up @@ -44,9 +44,11 @@ class BareDecoration extends React.Component {
this.decorationHolder = new RefHolder();
this.editorSub = new Disposable();
this.decorableSub = new Disposable();
this.gutterSub = new Disposable();

this.domNode = null;
this.item = null;

if (['gutter', 'overlay', 'block'].includes(this.props.type)) {
this.domNode = document.createElement('div');
this.domNode.className = cx('react-atom-decoration', this.props.className);
Expand Down Expand Up @@ -115,6 +117,23 @@ class BareDecoration extends React.Component {
return;
}

// delay decoration creation when it's a gutter type;
// instead wait for the Gutter to be added to the editor first
if (this.props.type === 'gutter') {
if (!this.props.gutterName) {
throw new Error('You are trying to decorate a gutter but did not supply gutterName prop.');
}
this.props.editorHolder.map(editor => {
this.gutterSub = editor.observeGutters(gutter => {
if (gutter.name === this.props.gutterName) {
this.createDecoration();
}
});
return null;
});
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would it make sense to use forEach instead of map here to avoid having to return null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to implement .forEach() on RefHolder first (editorHolder isn't an Array). eslint goes purely by the method name, not the receiver type, so it doesn't know the difference. Just a RefHolder API thing that i've never gotten around to smoothing over.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok cool makes sense!

}

this.createDecoration();
}

Expand All @@ -126,7 +145,6 @@ class BareDecoration extends React.Component {
const opts = this.getDecorationOpts(this.props);
const editor = this.props.editorHolder.get();
const decorable = this.props.decorableHolder.get();

this.decorationHolder.setter(
editor[this.props.decorateMethod](decorable, opts),
);
Expand All @@ -136,6 +154,7 @@ class BareDecoration extends React.Component {
this.decorationHolder.map(decoration => decoration.destroy());
this.editorSub.dispose();
this.decorableSub.dispose();
this.gutterSub.dispose();
}

getDecorationOpts(props) {
Expand All @@ -150,6 +169,7 @@ export default class Decoration extends React.Component {
static propTypes = {
editor: PropTypes.object,
decorable: PropTypes.object,
decorateMethod: PropTypes.oneOf(['decorateMarker', 'decorateMarkerLayer']),
}

constructor(props) {
Expand Down Expand Up @@ -184,28 +204,30 @@ export default class Decoration extends React.Component {
}

render() {
if (!this.state.editorHolder.isEmpty() && !this.state.decorableHolder.isEmpty()) {
return (
<BareDecoration
{...this.props}
editorHolder={this.state.editorHolder}
decorableHolder={this.state.decorableHolder}
/>
);
}

return (
<TextEditorContext.Consumer>
{editorHolder => (
<DecorableContext.Consumer>
{({holder, decorateMethod}) => (
<BareDecoration
editorHolder={editorHolder}
decorableHolder={holder}
decorateMethod={decorateMethod}
{...this.props}
/>
)}
{decorable => {
let holder = null;
let decorateMethod = null;
if (!this.state.decorableHolder.isEmpty()) {
holder = this.state.decorableHolder;
decorateMethod = this.props.decorateMethod;
} else {
holder = decorable.holder;
decorateMethod = decorable.decorateMethod;
}

return (
<BareDecoration
editorHolder={editorHolder || this.state.editorHolder}
decorableHolder={holder}
decorateMethod={decorateMethod}
{...this.props}
/>
);
}}
</DecorableContext.Consumer>
)}
</TextEditorContext.Consumer>
Expand Down
1 change: 1 addition & 0 deletions lib/atom/marker.js
Expand Up @@ -13,6 +13,7 @@ const MarkablePropType = PropTypes.shape({
});

const markerProps = {
exclusive: PropTypes.bool,
reversed: PropTypes.bool,
invalidate: PropTypes.oneOf(['never', 'surround', 'overlap', 'inside', 'touch']),
};
Expand Down
20 changes: 11 additions & 9 deletions lib/atom/pane-item.js
Expand Up @@ -173,6 +173,7 @@ class OpenItem {
this.domNode.tabIndex = '-1';
this.domNode.onfocus = this.onFocus.bind(this);
this.stubItem = stub;
this.stubProps = stub ? stub.props : {};
this.match = match;
this.itemHolder = new RefHolder();
}
Expand Down Expand Up @@ -202,15 +203,15 @@ class OpenItem {
}

getStubProps() {
if (!this.itemHolder.isEmpty()) {
const item = this.itemHolder.get();
return {
title: item.getTitle ? item.getTitle() : null,
iconName: item.getIconName ? item.getIconName() : null,
};
} else {
return {};
}
const itemProps = this.itemHolder.map(item => ({
title: item.getTitle ? item.getTitle() : null,
iconName: item.getIconName ? item.getIconName() : null,
}));

return {
...this.stubProps,
...itemProps,
};
}

onFocus() {
Expand All @@ -220,6 +221,7 @@ class OpenItem {
renderPortal(renderProp) {
return ReactDOM.createPortal(
renderProp({
deserialized: this.stubProps,
itemHolder: this.itemHolder,
params: this.match.getParams(),
uri: this.match.getURI(),
Expand Down
5 changes: 5 additions & 0 deletions lib/atom/tooltip.js
Expand Up @@ -36,6 +36,7 @@ export default class Tooltip extends React.Component {
keyBindingTarget: PropTypes.element,
children: PropTypes.element,
itemHolder: RefHolderPropType,
tooltipHolder: RefHolderPropType,
}

static defaultProps = {
Expand Down Expand Up @@ -126,6 +127,10 @@ export default class Tooltip extends React.Component {
this.refSub = this.props.target.observe(t => {
this.tipSub.dispose();
this.tipSub = this.props.manager.add(t, options);
const h = this.props.tooltipHolder;
if (h) {
h.setter(this.tipSub);
}
});
}
}