Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b33c0d5
Restore deriving contexts from the active pane item
smashwilson Jan 31, 2020
946a896
Pass context lock and setter method into React tree
smashwilson Jan 31, 2020
77626ab
Pass context props to Git and GitHub tab items
smashwilson Jan 31, 2020
a9f35b0
Drill context methods into Git tab
smashwilson Jan 31, 2020
bf8cbd1
Drill context props into GitHub tab components
smashwilson Jan 31, 2020
03e3b3f
Make the lock button borderless and backgroundless
smashwilson Feb 2, 2020
7411a35
Return context update promises
smashwilson Feb 2, 2020
9335d9e
Remove some unused parameters
smashwilson Feb 2, 2020
cd6b128
Modify lockedContext before re-rendering
smashwilson Feb 2, 2020
000a069
Pass missing props
smashwilson Feb 2, 2020
51aa5a7
Correct getWorkDir() typo
smashwilson Feb 2, 2020
0006b36
Pass correct props
smashwilson Feb 2, 2020
2ab6f7e
Context tile button/select enablement
smashwilson Feb 2, 2020
47e4e61
State key typo
smashwilson Feb 2, 2020
4626679
GitTabHeaderView tests
smashwilson Feb 2, 2020
610edb1
Right shallow renderer
smashwilson Feb 2, 2020
59a9daa
GitTabHeaderController test coverage
smashwilson Feb 2, 2020
0832dfb
GitTabView test coverage
smashwilson Feb 2, 2020
72e9eff
Fill in missing props
smashwilson Feb 2, 2020
5d6ea5a
GithubTabHeaderView tests
smashwilson Feb 2, 2020
7fe471e
GithubTabHeaderController tests
smashwilson Feb 2, 2020
78b1c9c
GithubTabHeaderContainer tests
smashwilson Feb 2, 2020
8b5aa61
GithubTabController tests
smashwilson Feb 2, 2020
cd28dd5
GithubTabView tests
smashwilson Feb 2, 2020
8e7c537
Pass missing props
smashwilson Feb 3, 2020
550fb8c
Keep the serialized state as `activeRepositoryPath`
smashwilson Feb 3, 2020
39df687
scheduleActiveContextUpdate() argument keywords
smashwilson Feb 3, 2020
4183766
Linty lint
smashwilson Feb 3, 2020
62f5f71
Use existing getActiveWorkdir() method
smashwilson Feb 3, 2020
54d8a6b
Prefer locked context over active item
smashwilson Feb 3, 2020
9dd2f25
Coverage tweaks
smashwilson Feb 3, 2020
09c4a6d
Tests for locked contexts
smashwilson Feb 3, 2020
9ae31dd
Inexpert but hopefully passable unlock icon
smashwilson Feb 3, 2020
2ea1377
Render manual SVG "octicons"
smashwilson Feb 5, 2020
4955c9b
Use the new unlock icon in the button
smashwilson Feb 5, 2020
36d001e
Fall back to '' instead of null for the selects' value
smashwilson Feb 5, 2020
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
61 changes: 61 additions & 0 deletions img/unlock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions lib/atom/octicon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,32 @@ import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';

/* eslint-disable max-len */
const SVG = {
unlock: {
viewBox: '0 0 24 16',
element: (
<path
fillRule="evenodd"
d="m 13.4,13 h -1 v -1 h 1 z m 6,-7 h 1 c 0.55,0 1,0.45 1,1 v 7 c 0,0.55 -0.45,1 -1,1 h -10 c -0.55,0 -1,-0.45 -1,-1 V 7 c 0,-0.55 0.45,-1 1,-1 h 1 V 4.085901 C 11.4,2.1862908 9.8780193,2.4095693 8.904902,2.4143325 8.0404588,2.4185637 6.3689542,2.1882296 6.3689542,4.085901 V 7.4918301 L 4.2521568,7.4509801 4.2930068,4.045051 C 4.3176792,1.987953 5.080245,-0.02206145 8.792353,-0.03403364 13.536238,-0.0493335 13.21,3.1688541 13.21,4.085901 V 6 h -0.01 4.41 m 2.79,1 h -9 v 7 h 9 z m -7,1 h -1 v 1 h 1 z m 0,2 h -1 v 1 h 1 z"
/>
),
},
};
/* eslint-enable max-len */

export default function Octicon({icon, ...others}) {
const classes = cx('icon', `icon-${icon}`, others.className);

const svgContent = SVG[icon];
if (svgContent) {
return (
<svg {...others} viewBox={svgContent.viewBox} xmlns="http://www.w3.org/2000/svg" className={classes}>
{svgContent.element}
</svg>
);
}

return <span {...others} className={classes} />;
}

Expand Down
16 changes: 11 additions & 5 deletions lib/containers/github-tab-header-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export default class GithubTabHeaderContainer extends React.Component {

// Workspace
currentWorkDir: PropTypes.string,
contextLocked: PropTypes.bool.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
setContextLock: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,

// Event Handlers
handleWorkDirSelect: PropTypes.func,
onDidChangeWorkDirs: PropTypes.func,
}

Expand Down Expand Up @@ -59,12 +61,12 @@ export default class GithubTabHeaderContainer extends React.Component {
environment={environment}
variables={{}}
query={query}
render={result => this.renderWithResult(result, token)}
render={result => this.renderWithResult(result)}
/>
);
}

renderWithResult({error, props, retry}, token) {
renderWithResult({error, props}) {
if (error || props === null) {
return this.renderNoResult();
}
Expand All @@ -78,10 +80,12 @@ export default class GithubTabHeaderContainer extends React.Component {

// Workspace
currentWorkDir={this.props.currentWorkDir}
contextLocked={this.props.contextLocked}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}

// Event Handlers
handleWorkDirSelect={this.props.handleWorkDirSelect}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
/>
);
Expand All @@ -94,10 +98,12 @@ export default class GithubTabHeaderContainer extends React.Component {

// Workspace
currentWorkDir={this.props.currentWorkDir}
contextLocked={this.props.contextLocked}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}

// Event Handlers
handleWorkDirSelect={this.props.handleWorkDirSelect}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
/>
);
Expand Down
4 changes: 4 additions & 0 deletions lib/controllers/git-tab-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export default class GitTabController extends React.Component {
openFiles: PropTypes.func.isRequired,
openInitializeDialog: PropTypes.func.isRequired,
controllerRef: RefHolderPropType,
contextLocked: PropTypes.bool.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
setContextLock: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
};
Expand Down Expand Up @@ -122,7 +124,9 @@ export default class GitTabController extends React.Component {
openFiles={this.props.openFiles}
discardWorkDirChangesForPaths={this.props.discardWorkDirChangesForPaths}
undoLastDiscard={this.props.undoLastDiscard}
contextLocked={this.props.contextLocked}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}

Expand Down
59 changes: 53 additions & 6 deletions lib/controllers/git-tab-header-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,28 @@ export default class GitTabHeaderController extends React.Component {
// Workspace
currentWorkDir: PropTypes.string,
getCurrentWorkDirs: PropTypes.func.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
contextLocked: PropTypes.bool.isRequired,
setContextLock: PropTypes.func.isRequired,

// Event Handlers
handleWorkDirSelect: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
onDidUpdateRepo: PropTypes.func.isRequired,
}

constructor(props) {
super(props);
this._isMounted = false;
this.state = {currentWorkDirs: [], committer: nullAuthor};
this.state = {
currentWorkDirs: [],
committer: nullAuthor,
changingLock: null,
changingWorkDir: null,
};
this.disposable = new CompositeDisposable();
}

static getDerivedStateFromProps(props, state) {
static getDerivedStateFromProps(props) {
return {
currentWorkDirs: props.getCurrentWorkDirs(),
};
Expand Down Expand Up @@ -59,17 +66,49 @@ export default class GitTabHeaderController extends React.Component {
committer={this.state.committer}

// Workspace
workdir={this.props.currentWorkDir}
workdir={this.getWorkDir()}
workdirs={this.state.currentWorkDirs}
contextLocked={this.getLocked()}
changingWorkDir={this.state.changingWorkDir !== null}
changingLock={this.state.changingLock !== null}

// Event Handlers
handleWorkDirSelect={this.props.handleWorkDirSelect}
handleWorkDirSelect={this.handleWorkDirSelect}
handleLockToggle={this.handleLockToggle}
/>
);
}

handleLockToggle = async () => {
if (this.state.changingLock !== null) {
return;
}

const nextLock = !this.props.contextLocked;
try {
this.setState({changingLock: nextLock});
await this.props.setContextLock(this.getWorkDir(), nextLock);
} finally {
await new Promise(resolve => this.setState({changingLock: null}, resolve));
}
}

handleWorkDirSelect = async e => {
if (this.state.changingWorkDir !== null) {
return;
}

const nextWorkDir = e.target.value;
try {
this.setState({changingWorkDir: nextWorkDir});
await this.props.changeWorkingDirectory(nextWorkDir);
} finally {
await new Promise(resolve => this.setState({changingWorkDir: null}, resolve));
}
}

resetWorkDirs = () => {
this.setState((state, props) => ({
this.setState(() => ({
currentWorkDirs: [],
}));
}
Expand All @@ -81,6 +120,14 @@ export default class GitTabHeaderController extends React.Component {
}
}

getWorkDir() {
return this.state.changingWorkDir !== null ? this.state.changingWorkDir : this.props.currentWorkDir;
}

getLocked() {
return this.state.changingLock !== null ? this.state.changingLock : this.props.contextLocked;
}

componentWillUnmount() {
this._isMounted = false;
this.disposable.dispose();
Expand Down
4 changes: 4 additions & 0 deletions lib/controllers/github-tab-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export default class GitHubTabController extends React.Component {
currentWorkDir: PropTypes.string,

changeWorkingDirectory: PropTypes.func.isRequired,
setContextLock: PropTypes.func.isRequired,
contextLocked: PropTypes.bool.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
Expand Down Expand Up @@ -54,6 +56,7 @@ export default class GitHubTabController extends React.Component {
rootHolder={this.props.rootHolder}

workingDirectory={this.props.workingDirectory || this.props.currentWorkDir}
contextLocked={this.props.contextLocked}
repository={this.props.repository}
branches={this.props.branches}
currentBranch={currentBranch}
Expand All @@ -67,6 +70,7 @@ export default class GitHubTabController extends React.Component {
handlePushBranch={this.handlePushBranch}
handleRemoteSelect={this.handleRemoteSelect}
changeWorkingDirectory={this.props.changeWorkingDirectory}
setContextLock={this.props.setContextLock}
getCurrentWorkDirs={this.props.getCurrentWorkDirs}
onDidChangeWorkDirs={this.props.onDidChangeWorkDirs}
openCreateDialog={this.props.openCreateDialog}
Expand Down
60 changes: 53 additions & 7 deletions lib/controllers/github-tab-header-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,26 @@ export default class GithubTabHeaderController extends React.Component {

// Workspace
currentWorkDir: PropTypes.string,
contextLocked: PropTypes.bool.isRequired,
changeWorkingDirectory: PropTypes.func.isRequired,
setContextLock: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,

// Event Handlers
handleWorkDirSelect: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
}

constructor(props) {
super(props);
this.state = {currentWorkDirs: []};

this.state = {
currentWorkDirs: [],
changingLock: null,
changingWorkDir: null,
};
}

static getDerivedStateFromProps(props, state) {
static getDerivedStateFromProps(props) {
return {
currentWorkDirs: props.getCurrentWorkDirs(),
};
Expand All @@ -46,21 +53,60 @@ export default class GithubTabHeaderController extends React.Component {
user={this.props.user}

// Workspace
workdir={this.props.currentWorkDir}
workdir={this.getWorkDir()}
workdirs={this.state.currentWorkDirs}
contextLocked={this.getContextLocked()}
changingWorkDir={this.state.changingWorkDir !== null}
changingLock={this.state.changingLock !== null}

// Event Handlers
handleWorkDirSelect={this.props.handleWorkDirSelect}
handleWorkDirChange={this.handleWorkDirChange}
handleLockToggle={this.handleLockToggle}
/>
);
}

resetWorkDirs = () => {
this.setState((state, props) => ({
this.setState(() => ({
currentWorkDirs: [],
}));
}

handleLockToggle = async () => {
if (this.state.changingLock !== null) {
return;
}

const nextLock = !this.props.contextLocked;
try {
this.setState({changingLock: nextLock});
await this.props.setContextLock(this.state.changingWorkDir || this.props.currentWorkDir, nextLock);
} finally {
await new Promise(resolve => this.setState({changingLock: null}, resolve));
}
}

handleWorkDirChange = async e => {
if (this.state.changingWorkDir !== null) {
return;
}

const nextWorkDir = e.target.value;
try {
this.setState({changingWorkDir: nextWorkDir});
await this.props.changeWorkingDirectory(nextWorkDir);
} finally {
await new Promise(resolve => this.setState({changingWorkDir: null}, resolve));
}
}

getWorkDir() {
return this.state.changingWorkDir !== null ? this.state.changingWorkDir : this.props.currentWorkDir;
}

getContextLocked() {
return this.state.changingLock !== null ? this.state.changingLock : this.props.contextLocked;
}

componentWillUnmount() {
this.disposable.dispose();
}
Expand Down
Loading