forked from atom/github
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub-tab-item.js
81 lines (63 loc) · 1.77 KB
/
github-tab-item.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React from 'react';
import PropTypes from 'prop-types';
import {GithubLoginModelPropType} from '../prop-types';
import RefHolder from '../models/ref-holder';
import GitHubTabContainer from '../containers/github-tab-container';
export default class GitHubTabItem extends React.Component {
static propTypes = {
workspace: PropTypes.object.isRequired,
repository: PropTypes.object,
loginModel: GithubLoginModelPropType.isRequired,
documentActiveElement: PropTypes.func,
changeWorkingDirectory: PropTypes.func.isRequired,
onDidChangeWorkDirs: PropTypes.func.isRequired,
getCurrentWorkDirs: PropTypes.func.isRequired,
openCreateDialog: PropTypes.func.isRequired,
openPublishDialog: PropTypes.func.isRequired,
openCloneDialog: PropTypes.func.isRequired,
openGitTab: PropTypes.func.isRequired,
}
static defaultProps = {
documentActiveElement: /* istanbul ignore next */ () => document.activeElement,
}
static uriPattern = 'atom-github://dock-item/github';
static buildURI() {
return this.uriPattern;
}
constructor(props) {
super(props);
this.rootHolder = new RefHolder();
}
getTitle() {
return 'GitHub';
}
getIconName() {
return 'octoface';
}
getDefaultLocation() {
return 'right';
}
getPreferredWidth() {
return 400;
}
getWorkingDirectory() {
return this.props.repository.getWorkingDirectoryPath();
}
serialize() {
return {
deserializer: 'GithubDockItem',
uri: this.getURI(),
};
}
render() {
return (
<GitHubTabContainer {...this.props} rootHolder={this.rootHolder} />
);
}
hasFocus() {
return this.rootHolder.map(root => root.contains(this.props.documentActiveElement())).getOr(false);
}
restoreFocus() {
// No-op
}
}