FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
github/lib/controllers/github-tab-header-controller.js at master · atom/github · GitHub
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
atom
/
github
Public archive
Notifications
You must be signed in to change notification settings
Fork
408
Star
1.2k
Code
Issues
439
Pull requests
65
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
github
/
lib
/
controllers
/
github-tab-header-controller.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
113 lines (94 loc) · 2.91 KB
Breadcrumbs
github
/
lib
/
controllers
/
github-tab-header-controller.js
Copy path
File metadata and controls
113 lines (94 loc) · 2.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import
React
from
'react'
;
import
PropTypes
from
'prop-types'
;
import
{
AuthorPropType
}
from
'../prop-types'
;
import
GithubTabHeaderView
from
'../views/github-tab-header-view'
;
export
default
class
GithubTabHeaderController
extends
React
.
Component
{
static
propTypes
=
{
user
:
AuthorPropType
.
isRequired
,
// Workspace
currentWorkDir
:
PropTypes
.
string
,
contextLocked
:
PropTypes
.
bool
.
isRequired
,
changeWorkingDirectory
:
PropTypes
.
func
.
isRequired
,
setContextLock
:
PropTypes
.
func
.
isRequired
,
getCurrentWorkDirs
:
PropTypes
.
func
.
isRequired
,
// Event Handlers
onDidChangeWorkDirs
:
PropTypes
.
func
.
isRequired
,
}
constructor
(
props
)
{
super
(
props
)
;
this
.
state
=
{
currentWorkDirs
:
[
]
,
changingLock
:
null
,
changingWorkDir
:
null
,
}
;
}
static
getDerivedStateFromProps
(
props
)
{
return
{
currentWorkDirs
:
props
.
getCurrentWorkDirs
(
)
,
}
;
}
componentDidMount
(
)
{
this
.
disposable
=
this
.
props
.
onDidChangeWorkDirs
(
this
.
resetWorkDirs
)
;
}
componentDidUpdate
(
prevProps
)
{
if
(
prevProps
.
onDidChangeWorkDirs
!==
this
.
props
.
onDidChangeWorkDirs
)
{
if
(
this
.
disposable
)
{
this
.
disposable
.
dispose
(
)
;
}
this
.
disposable
=
this
.
props
.
onDidChangeWorkDirs
(
this
.
resetWorkDirs
)
;
}
}
render
(
)
{
return
(
<
GithubTabHeaderView
user
=
{
this
.
props
.
user
}
// Workspace
workdir
=
{
this
.
getWorkDir
(
)
}
workdirs
=
{
this
.
state
.
currentWorkDirs
}
contextLocked
=
{
this
.
getContextLocked
(
)
}
changingWorkDir
=
{
this
.
state
.
changingWorkDir
!==
null
}
changingLock
=
{
this
.
state
.
changingLock
!==
null
}
handleWorkDirChange
=
{
this
.
handleWorkDirChange
}
handleLockToggle
=
{
this
.
handleLockToggle
}
/>
)
;
}
resetWorkDirs
=
(
)
=>
{
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
(
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL