Skip to content

Commit 6763212

Browse files
author
Yang Zhen
committed
Update workstation to 0.1.3
Add full ui to workstation
1 parent b56f876 commit 6763212

31 files changed

+769
-111
lines changed

app/commons/Tab/state.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ function TabScope () {
2424
tabGroups: mapToJS(this.tabGroups),
2525
activeTabGroupId: this.activeTabGroupId
2626
}
27-
}
27+
},
28+
keepOne: false, // 是否保留一个 tab
2829
})
2930

3031
const mapEntity = mapEntityFactory(state)
@@ -72,6 +73,9 @@ function TabScope () {
7273
}
7374

7475
@action destroy () {
76+
if (state.tabs.size === 1 && state.keepOne) {
77+
return
78+
}
7579
this.tabGroup.removeTab(this)
7680
state.tabs.delete(this.id)
7781
}

app/components/Git/GitBranchWidget.jsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import i18n from 'utils/createI18n'
1111

1212
// add withRef to deliver ref to the wrapperedcomponent
1313
@connect(state => state.GitState.branches,
14-
dispatch => bindActionCreators(GitActions, dispatch), null, { withRef: true })
14+
dispatch => bindActionCreators(GitActions, dispatch), null, { withRef: false })
1515
export default class GitBranchWidget extends Component {
1616
constructor (props) {
1717
super(props)
@@ -60,22 +60,22 @@ export default class GitBranchWidget extends Component {
6060

6161
makeBrancheMenuItems (localBranches, remoteBranches) {
6262
if (!localBranches && !remoteBranches) {
63-
return [{ name: i18n`git.branchWidget.fetchingBranches`, isDisabled: true }]
63+
return [{ name: i18n.get('git.branchWidget.fetchingBranches'), isDisabled: true }]
6464
}
6565

6666
const localBranchItems = localBranches.map(branch => ({
6767
name: branch,
6868
icon: 'fa',
6969
items: [{
70-
name: i18n`git.branchWidget.checkout`,
70+
name: i18n.get('git.branchWidget.checkout'),
7171
command: () => { this.props.checkoutBranch(branch) }
7272
}, {
73-
name: i18n`git.branchWidget.checkoutAsNew`,
73+
name: i18n.get('git.branchWidget.checkoutAsNew'),
7474
command: () => dispatchCommand('git:checkout_new_branch', {
7575
fromBranch: branch
7676
})
7777
}, {
78-
name: i18n`git.branchWidget.delete`,
78+
name: i18n.get('git.branchWidget.delete'),
7979
command: () => { this.props.gitDeleteBranch(branch) }
8080
}]
8181
}))
@@ -86,28 +86,28 @@ export default class GitBranchWidget extends Component {
8686
name: remoteBranch,
8787
icon: 'fa',
8888
items: [{
89-
name: i18n`git.branchWidget.checkout`,
89+
name: i18n.get('git.branchWidget.checkout'),
9090
// @todo: should prompt to input local branch name
9191
command: () => dispatchCommand('git:checkout_new_branch', {
9292
fromBranch: remoteBranch,
9393
toBranch: localBranch
9494
})
9595
}, {
96-
name: i18n`git.branchWidget.delete`,
96+
name: i18n.get('git.branchWidget.delete'),
9797
command: () => { this.props.gitDeleteBranch(remoteBranch) }
9898
}]
9999
}
100100
})
101101
return [
102-
{ name: i18n`git.branchWidget.newBranch`, command: () => dispatchCommand('git:new_branch'),
102+
{ name: i18n.get('git.branchWidget.newBranch'), command: () => dispatchCommand('git:new_branch'),
103103
iconElement: (<span style={{ marginRight: '0.3em' }}>+</span>) },
104-
{ name: i18n`git.branchWidget.synchronize`, command: () => this.props.getFetch(),
104+
{ name: i18n.get('git.branchWidget.synchronize'), command: () => this.props.getFetch(),
105105
icon: 'fa' },
106106
{ isDivider: true },
107-
{ name: i18n`git.branchWidget.localBranches`, isDisabled: true },
107+
{ name: i18n.get('git.branchWidget.localBranches'), isDisabled: true },
108108
...localBranchItems,
109109
{ isDivider: true },
110-
{ name: i18n`git.branchWidget.remoteBranches`, isDisabled: true },
110+
{ name: i18n.get('git.branchWidget.remoteBranches'), isDisabled: true },
111111
...remoteBranchItems
112112
]
113113
}

app/components/MenuBar/menuBarItems.jsx

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,160 +12,160 @@ const menuBarItems = observable([
1212
items: [
1313
{
1414
key: 'settings',
15-
name: i18n.get('menuBarItems.meta.main'),
15+
name: i18n`menuBarItems.meta.main`,
1616
icon: 'octicon octicon-gear',
1717
command: 'global:show_settings',
1818
canopen: true
1919
}
2020
]
2121
}, {
2222
key: 'file',
23-
name: i18n.get('menuBarItems.file.main'),
23+
name: i18n`menuBarItems.file.main`,
2424
items: [
2525
{
2626
key: 'newFile',
27-
name: i18n.get('menuBarItems.file.newFile'),
27+
name: i18n`menuBarItems.file.newFile`,
2828
icon: 'fa fa-file-text-o',
2929
command: 'file:new_file',
3030
showMore: true
3131
}, {
3232
key: 'newFolder',
33-
name: i18n.get('menuBarItems.file.newFolder'),
33+
name: i18n`menuBarItems.file.newFolder`,
3434
icon: 'fa fa-folder-o',
3535
command: 'file:new_folder',
3636
showMore: true
3737
}, {
3838
key: 'save',
39-
name: i18n.get('menuBarItems.file.save'),
39+
name: i18n`menuBarItems.file.save`,
4040
icon: 'fa fa-floppy-o',
4141
command: 'file:save'
4242
}
4343
]
4444
}, {
4545
key: 'edit',
46-
name: i18n.get('menuBarItems.edit.main'),
46+
name: i18n`menuBarItems.edit.main`,
4747
items: [
4848
{
4949
key: 'format',
50-
name: i18n.get('menuBarItems.edit.format'),
50+
name: i18n`menuBarItems.edit.format`,
5151
icon: '',
5252
command: 'edit:toggle_format',
5353
}, {
5454
key: 'comment',
55-
name: i18n.get('menuBarItems.edit.comment'),
55+
name: i18n`menuBarItems.edit.comment`,
5656
icon: '',
5757
command: 'edit:toggle_comment',
5858
}
5959
]
6060
}, {
6161
key: 'git',
62-
name: i18n.get('menuBarItems.git.main'),
62+
name: i18n`menuBarItems.git.main`,
6363
onOpen: onGitMenuOpen,
6464
items: [
6565
{
6666
key: 'commit',
67-
name: i18n.get('menuBarItems.git.commit'),
67+
name: i18n`menuBarItems.git.commit`,
6868
icon: 'octicon octicon-git-commit',
6969
command: 'git:commit',
7070
showMore: true,
7171
}, {
7272
key: 'pull',
73-
name: i18n.get('menuBarItems.git.pull'),
73+
name: i18n`menuBarItems.git.pull`,
7474
icon: 'octicon octicon-repo-pull',
7575
command: 'git:pull'
7676
}, {
7777
key: 'push',
78-
name: i18n.get('menuBarItems.git.push'),
78+
name: i18n`menuBarItems.git.push`,
7979
icon: 'octicon octicon-repo-push',
8080
command: 'git:push'
8181
},
8282
divider,
8383
{
8484
key: 'resolveConflicts',
8585
group: 'conflicts',
86-
name: i18n.get('menuBarItems.git.resolveConflicts'),
86+
name: i18n`menuBarItems.git.resolveConflicts`,
8787
command: 'git:resolve_conflicts',
8888
showMore: true
8989
},
9090
divider,
9191
{
9292
key: 'stash',
93-
name: i18n.get('menuBarItems.git.stashChanges'),
93+
name: i18n`menuBarItems.git.stashChanges`,
9494
command: 'git:stash',
9595
showMore: true,
9696
},
9797
{
9898
key: 'unstash',
99-
name: i18n.get('menuBarItems.git.unstashChanges'),
99+
name: i18n`menuBarItems.git.unstashChanges`,
100100
command: 'git:unstash',
101101
showMore: true
102102
},
103103
{
104104
key: 'reset',
105-
name: i18n.get('menuBarItems.git.resetHead'),
105+
name: i18n`menuBarItems.git.resetHead`,
106106
command: 'git:reset_head',
107107
showMore: true
108108
},
109109
divider,
110110
{
111111
key: 'branches',
112-
name: i18n.get('menuBarItems.git.branches'),
112+
name: i18n`menuBarItems.git.branches`,
113113
icon: 'octicon octicon-git-branch',
114114
command: 'global:show_branches',
115115
showMore: true
116116
},
117117
{
118118
key: 'merge',
119-
name: i18n.get('menuBarItems.git.mergeBranch'),
119+
name: i18n`menuBarItems.git.mergeBranch`,
120120
icon: 'octicon octicon-git-merge',
121121
command: 'git:merge',
122122
showMore: true
123123
},
124124
{
125125
key: 'tag',
126-
name: i18n.get('menuBarItems.git.tag'),
126+
name: i18n`menuBarItems.git.tag`,
127127
command: 'git:tag',
128128
showMore: true
129129
},
130130
divider,
131131
{
132132
key: 'rebase',
133-
name: i18n.get('menuBarItems.git.rebase'),
133+
name: i18n`menuBarItems.git.rebase`,
134134
command: 'git:rebase:start',
135135
showMore: true
136136
},
137137
{
138138
key: 'abort',
139-
name: i18n.get('menuBarItems.git.abortRebase'),
139+
name: i18n`menuBarItems.git.abortRebase`,
140140
command: 'git:rebase:abort',
141141
getIsDisabled,
142142
},
143143
{
144144
key: 'continue',
145-
name: i18n.get('menuBarItems.git.continueRebase'),
145+
name: i18n`menuBarItems.git.continueRebase`,
146146
command: 'git:rebase:continue',
147147
getIsDisabled,
148148
},
149149
{
150150
key: 'skipCommit',
151-
name: i18n.get('menuBarItems.git.skipCommit'),
151+
name: i18n`menuBarItems.git.skipCommit`,
152152
command: 'git:rebase:skip_commit',
153153
showMore: true,
154154
getIsDisabled,
155155
}
156156
]
157157
}, {
158158
key: 'tools',
159-
name: i18n.get('menuBarItems.tools.main'),
159+
name: i18n`menuBarItems.tools.main`,
160160
items: [
161161
{
162162
key: 'terminal',
163-
name: i18n.get('menuBarItems.tools.terminal'),
163+
name: i18n`menuBarItems.tools.terminal`,
164164

165165
icon: 'octicon octicon-terminal',
166166
items: [
167167
{
168-
name: i18n.get('menuBarItems.tools.newTerminal'),
168+
name: i18n`menuBarItems.tools.newTerminal`,
169169
icon: 'octicon octicon-terminal',
170170
command: 'tools:terminal:new_terminal'
171171
}

app/components/Panel/PanelContent.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import FileTree from '../FileTree'
99
import SideBar from './SideBar/SideBar'
1010
import { SidePanelContainer, SidePanelView } from './SideBar/SidePanel'
1111
import FileList from '../Tab/fileList'
12+
import config from '../../config'
1213

1314

1415
const PanelContent = ({ panel }) => {
@@ -55,7 +56,7 @@ const PanelContent = ({ panel }) => {
5556
}
5657
return (
5758
<SidePanelContainer side='bottom'>
58-
<SidePanelView key='terminal' label={labels.terminal} >
59+
<SidePanelView key='terminal' label={labels.terminal} active={config.isLib} >
5960
<TerminalContainer />
6061
</SidePanelView>
6162

app/components/Panel/state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import _ from 'lodash'
22
import extendObservableStrict from 'utils/extendObservableStrict'
33
import PaneScope from 'commons/Pane/state'
44
import { extendObservable, computed, action } from 'mobx'
5+
import config from '../../config'
56

67
const { state, BasePane } = PaneScope()
78

@@ -88,7 +89,7 @@ const BasePanelLayout = {
8889
{ ref: 'PANEL_RIGHT', size: 30, contentType: 'EXTENSION_RIGHT', hidden: true },
8990
],
9091
},
91-
{ ref: 'PANEL_BOTTOM', size: 25, contentType: 'PANEL_BOTTOM', hidden: true, resizable: true },
92+
{ ref: 'PANEL_BOTTOM', size: 25, contentType: 'PANEL_BOTTOM', hidden: !config.isLib, resizable: true },
9293
{ ref: 'BAR_BOTTOM', resizable: false },
9394
]
9495
},

app/components/Setting/FormInputGroup.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const FormInputGroup = defaultProps((props) => {
4545
>
4646
{settingItem.options.map(option =>
4747
isPlainObject(option) ?
48-
<option key={option.value} value={option.value}>{i18n([option.name])}</option>
48+
<option key={option.value} value={option.value}>{i18n.get(`${option.name}`)}</option>
4949
: <option key={option} value={option}>{option}</option>
5050
)}
5151
</select>

app/components/Terminal/Terminal.jsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Term extends Component {
2525
if (uiTheme === 'dark') {
2626
themeName = 'default'
2727
}
28+
_this.props.tab.title = 'Shell'
2829
var terminal = this.terminal = new Terminal({
2930
theme: themeName,
3031
cols: 80,
@@ -37,16 +38,17 @@ class Term extends Component {
3738
terminal.tabId = this.props.tab.id;
3839
this.props.tab.terminal = terminal
3940
terminal.open(this.termDOM);
41+
terminal.sizeToFit();
4042
terminal.id = this.sessionId = _.uniqueId('term_');
41-
43+
terminalManager.add(terminal);
4244
terminal.on('resize', (cols, rows) => {
4345
terminalManager.resize(terminal, cols, rows);
4446
});
45-
setTimeout(() => terminal.sizeToFit(), 0)
47+
// TODO autorun this.termDOM
48+
setTimeout(() => terminal.sizeToFit(), 2000) // 以防万一
4649
emitter.on(E.PANEL_RESIZED, this.onResize.bind(this))
4750
emitter.on(E.THEME_CHANGED, this.onTheme.bind(this))
48-
49-
terminalManager.add(terminal);
51+
5052
terminal.on('data', data => {
5153
terminalManager.getSocket().emit('term.input', {id: terminal.id, input: data})
5254
});

app/components/Terminal/TerminalContainer.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import PropTypes from 'prop-types'
33
import cx from 'classnames'
44
import { observer } from 'mobx-react'
55
import { TabBar, TabContent, TabContentItem } from 'commons/Tab'
6-
import Terminal from './Terminal'
6+
// import Terminal from './Terminal'
7+
import Terminal from './Xterm'
78
import { Tab, TabGroup } from './state'
89
import { emitter, E } from 'utils'
910

@@ -46,7 +47,7 @@ class TerminalContainer extends Component {
4647

4748
render () {
4849
return (
49-
<div className='tab-container'>
50+
<div className='tab-container terminal-panel'>
5051
<TabBar tabGroup={this.tabGroup}
5152
addTab={Actions.addTerminal}
5253
contextMenuItems={contextMenuItems}/>

0 commit comments

Comments
 (0)