This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 410
Expand file tree
/
Copy pathgithub-tab-header-view.js
More file actions
67 lines (59 loc) · 2.03 KB
/
github-tab-header-view.js
File metadata and controls
67 lines (59 loc) · 2.03 KB
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
import React from 'react';
import PropTypes from 'prop-types';
import path from 'path';
import {AuthorPropType} from '../prop-types';
import Octicon from '../atom/octicon';
export default class GithubTabHeaderView extends React.Component {
static propTypes = {
user: AuthorPropType.isRequired,
// Workspace
workdir: PropTypes.string,
workdirs: PropTypes.shape({[Symbol.iterator]: PropTypes.func.isRequired}).isRequired,
contextLocked: PropTypes.bool.isRequired,
changingWorkDir: PropTypes.bool.isRequired,
changingLock: PropTypes.bool.isRequired,
handleWorkDirChange: PropTypes.func.isRequired,
handleLockToggle: PropTypes.func.isRequired,
}
render() {
const lockIcon = this.props.contextLocked ? 'lock' : 'unlock';
const lockToggleTitle = this.props.contextLocked ?
'Change repository with the dropdown' :
'Follow the active pane item';
return (
<header className="github-Project">
{this.renderUser()}
<select className="github-Project-path input-select"
value={this.props.workdir || ''}
disabled={this.props.changingWorkDir}
onChange={this.props.handleWorkDirChange}>
{this.renderWorkDirs()}
</select>
<button className="github-Project-lock btn btn-small"
onClick={this.props.handleLockToggle}
disabled={this.props.changingLock}
title={lockToggleTitle}>
<Octicon icon={lockIcon} />
</button>
</header>
);
}
renderWorkDirs() {
const workdirs = [];
for (const workdir of this.props.workdirs) {
workdirs.push(<option key={workdir} value={path.normalize(workdir)}>{path.basename(workdir)}</option>);
}
return workdirs;
}
renderUser() {
const login = this.props.user.getLogin();
const avatarUrl = this.props.user.getAvatarUrl();
return (
<img className="github-Project-avatar"
src={avatarUrl || 'atom://github/img/avatar.svg'}
title={`@${login}`}
alt={`@${login}'s avatar`}
/>
);
}
}