Repository navigation
Refactor main package entry point - #332
Conversation
* git-package-controller.js -> github-package-controller.js * move static props into `static prop =` inside class
Previously, rendering an Etch component with React required creating a new class by passing the Etch component class to `EtchReactAdapter` and rendering what was returned with React. Instead, EtchReactAdapter allows you to specify which component to wrap and what props to pass it declaratively via JSX, and will manage the component lifecycle itself.
This fixes CSP errors with old versions of sinon.spy
d4f922d to
c77d690
Compare
39ad9a4 to
b85ea2f
Compare
|
This is ready to be merged. Here's a quick summary of what we've changed:
While the raw number of lines of code has gone up in this PR, there are a few things to consider:
|
| this.setState({gitPanelActive: true}, () => { | ||
| // TODO: why doesn't a setTimeout of 0 or even 100 work here? | ||
| // Suspect it has to do with the command palette closing... | ||
| setTimeout(() => this.focusGitPanel(), 200) |
There was a problem hiding this comment.
The high timeout is necessary even when the command palette isn't being used (e.g. when using a keyboard shortcut). I have no idea why. 🔥
This PR makes some fairly significant changes to the main entry point of the package (
GithubPackage). It also attempts to make the code cleaner by switching up the management of top-level controllers. In detail:GithubPackagewas full of logic related specifically to the Git portion of the package. Adding GitHub-specific functionality was awkward as it gave the class multiple responsibilities and made it feel quite bloated. Most of this logic is moved toGithubPackageController, which will probably be renamed to something more specific to Git.All the logic for managing the top-level controllers (
GitPanelController,FilePatchController, andStatusBarTileController) was lost in a maze of callbacks, event-driven code, and conditionals designed to figure out if we should create, update, or destroy the given controllers. I've moved this logic into a React-driven declarative component that uses new meta-components likePanel,StatusBar, andPaneItemto wrap Atom's imperative API in a declarative interface. Now, simply removing the<Panel><GitPanelController /></Panel>from the return value ofrenderis enough to remove the panel.All the new meta-components are documented. As these are new, there may be issues in certain edge cases.