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

Conversation

@smashwilson
Copy link
Contributor

@smashwilson 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

@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.

Copy link
Contributor Author

@smashwilson smashwilson left a comment

Choose a reason for hiding this comment

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

Self-review for context.


```
this.props.commandRegistry.add(this.refRoot, {
this.props.commands.add(this.refRoot, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.)

children: PropTypes.element.isRequired,
options: PropTypes.object,
onDidClosePanel: PropTypes.func,
visible: PropTypes.bool,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

🔥 Unused props from waaaay back in the day.

* ```
*
*/
export default class AutoFocus {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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-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()} />
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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


const atomGitRepo = await this.project.repositoryForDirectory(directory);
if (atomGitRepo) {
await atomGitRepo.refreshStatus();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 July 19, 2019 19:25
@smashwilson smashwilson merged commit fd6172a into master Jul 22, 2019
@smashwilson smashwilson deleted the aw/refactor-dialogs branch July 22, 2019 13:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants