close
The Wayback Machine - https://web.archive.org/web/20200527185055/https://github.com/atom/github/pull/2209
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

Refactor dialog handling #2209

Merged
merged 42 commits into from Jul 22, 2019
Merged

Refactor dialog handling #2209

merged 42 commits into from Jul 22, 2019

Conversation

@smashwilson
Copy link
Member

smashwilson commented Jul 17, 2019

Please be sure to read the contributor's guide to the GitHub package before submitting any pull requests.

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • Suggestion: You can use checklists to keep track of progress for the sections on metrics, tests, documentation, and user research.

Description of the Change

To prepare for the implementation of #2111, I'm refactoring and tidying up some of the code related to dialog handling.

Our dialogs are currently managed by RootController. All of their state is captured in common-prefix RootController state, including the "is this dialog visible right now or not" logic. RootController is already a bit overwhelming, so before I add more dialogs, I'm extracting the dialog-handling code to its own DialogsController.

Screenshot/Gif

N/A

Alternate Designs

N/A

Benefits

Hopefully RootController will be slightly more readable.

Possible Drawbacks

N/A

Applicable Issues

N/A

Metrics

N/A

Tests

Visual inspection of:

  • The "init" dialog.
  • The "clone" dialog.
  • The credentials dialog.
  • The "open issueish" dialog.
  • The "open commit" dialog.

Documentation

N/A

Release Notes

N/A

User Experience Research (Optional)

N/A


View rendered docs/focus-management.md

smashwilson added 4 commits Jul 17, 2019
@codecov
Copy link

codecov bot commented Jul 17, 2019

Codecov Report

Merging #2209 into master will increase coverage by 0.03%.
The diff coverage is 92.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2209      +/-   ##
==========================================
+ Coverage   92.71%   92.75%   +0.03%     
==========================================
  Files         216      219       +3     
  Lines       12347    12354       +7     
  Branches     1815     1798      -17     
==========================================
+ Hits        11448    11459      +11     
+ Misses        899      895       -4
Impacted Files Coverage Δ
lib/views/recent-commits-view.js 98.24% <ø> (ø) ⬆️
lib/views/branch-menu-view.js 94.73% <ø> (-3%) ⬇️
lib/controllers/commit-controller.js 92.85% <ø> (ø) ⬆️
lib/controllers/git-tab-controller.js 80.67% <ø> (ø) ⬆️
lib/views/staging-view.js 72.63% <ø> (ø) ⬆️
lib/controllers/repository-conflict-controller.js 100% <ø> (ø) ⬆️
lib/views/co-author-form.js 92.85% <ø> (ø) ⬆️
lib/controllers/editor-conflict-controller.js 100% <ø> (ø) ⬆️
lib/controllers/status-bar-tile-controller.js 92.45% <ø> (ø) ⬆️
lib/controllers/recent-commits-controller.js 100% <ø> (ø) ⬆️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5db1eed...3a668f8. Read the comment docs.

smashwilson added 20 commits Jul 17, 2019
@smashwilson smashwilson added this to In progress in Release : v0.31.0 Jul 18, 2019
smashwilson added 15 commits Jul 19, 2019
Copy link
Member Author

smashwilson left a comment

Self-review for context.

@@ -29,7 +29,7 @@ We move focus around by registering Atom commands.
For example, in `GitTabView`:

```
this.props.commandRegistry.add(this.refRoot, {
this.props.commands.add(this.refRoot, {

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

This is a renaming I slipped in just because it was annoying me 👀

editor.getElement().classList.add(this.props.className);
}
if (this.props.preselect) {
editor.selectAll();

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

I went back and forth between supporting "all text preselected" and "cursor positioned at the end of the provided buffer." I think I landed on "all text preselected" because it's slightly more flexible (one keypress to decline a suggested starting value!) and because it's slightly easier to code (I don't have to pull anything from the buffer here.)

@@ -22,14 +22,12 @@ export default class Panel extends React.Component {
children: PropTypes.element.isRequired,
options: PropTypes.object,
onDidClosePanel: PropTypes.func,
visible: PropTypes.bool,

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

🔥 Unused props from waaaay back in the day.

* ```
*
*/
export default class AutoFocus {

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

I'm wondering if I could generalize this somehow to deal with #1403. It'd likely need to wait on a hooks refactor, though, and be passed as a context... 🤔

return null;
}

class DialogRequest {

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

This class is in here so that I can restrict the scope of "things that need to know the List Of All Possible Dialogs" to only this file. Hopefully that'll make it less error-prone to add new ones in the future.

initDialogPath: null,
initDialogResolve: null,
credentialDialogQuery: null,
dialogRequest: dialogRequests.null,

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

One of the big reasons I wanted to do this was to make this state less of a "blob of everything."

<Command command="github:toggle-git-tab" callback={this.gitTabTracker.toggle} />
<Command command="github:toggle-git-tab-focus" callback={this.gitTabTracker.toggleFocus} />
<Command command="github:toggle-github-tab" callback={this.githubTabTracker.toggle} />
<Command command="github:toggle-github-tab-focus" callback={this.githubTabTracker.toggleFocus} />
<Command command="github:clone" callback={this.openCloneDialog} />
<Command command="github:open-commit" callback={this.showOpenCommitDialog} />
<Command command="github:initialize" callback={() => this.openInitializeDialog()} />

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

Oh hey github:initialize is new. I am the worst at "refactoring"


const atomGitRepo = await this.project.repositoryForDirectory(directory);
if (atomGitRepo) {
await atomGitRepo.refreshStatus();

This comment has been minimized.

Copy link
@smashwilson

smashwilson Jul 19, 2019

Author Member

So this doesn't actually prompt Atom's tree-view to recompute workdir's directory icon to reflect that it's now a git repository. I did a little poking in tree-view source to see if that was possible and wasn't able to come up with anything.

@smashwilson smashwilson marked this pull request as ready for review Jul 19, 2019
@smashwilson smashwilson requested review from kuychaco and vanessayuenn Jul 19, 2019
…actor-dialogs
@smashwilson smashwilson merged commit fd6172a into master Jul 22, 2019
9 checks passed
9 checks passed
Consider pull request for release board Consider pull request for release board
Details
atom.github Build #20190722.1 succeeded
Details
atom.github (Lint) Lint succeeded
Details
atom.github (Linux) Linux succeeded
Details
atom.github (MacOS) MacOS succeeded
Details
atom.github (Snapshot) Snapshot succeeded
Details
atom.github (Windows) Windows succeeded
Details
codecov/patch 92.33% of diff hit (within 2% threshold of 92.71%)
Details
codecov/project 92.75% (+0.03%) compared to c9b56e4
Details
Release : v0.31.0 automation moved this from In progress to Merged Jul 22, 2019
@smashwilson smashwilson deleted the aw/refactor-dialogs branch Jul 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked issues

Successfully merging this pull request may close these issues.

None yet

1 participant
You can’t perform that action at this time.