@@ -14,6 +14,7 @@ import config from 'config'
1414import pluginStore from 'components/Plugins/store'
1515import WelcomePage from './WelcomePage'
1616import Changelog from './Changelog'
17+ import state from './state'
1718
1819const contextMenuItems = [
1920 {
@@ -30,15 +31,6 @@ const contextMenuItems = [
3031 command : 'tab:close_all'
3132 } ,
3233 { isDivider : true } ,
33- {
34- name : i18n `tab.contextMenu.verticalSplit` ,
35- icon : '' ,
36- command : 'tab:split_v'
37- } , {
38- name : i18n `tab.contextMenu.horizontalSplit` ,
39- icon : '' ,
40- command : 'tab:split_h'
41- }
4234]
4335
4436@observer
@@ -70,9 +62,27 @@ class TabContainer extends Component {
7062 } )
7163 }
7264
65+ // Render split menu in correct time
66+ renderItem = ( tabGroup ) => {
67+ const isDisabled = tabGroup . tabs . length === 1
68+
69+ if ( contextMenuItems . length === 4 || isDisabled ) {
70+ return contextMenuItems . concat ( [ {
71+ name : i18n `tab.contextMenu.verticalSplit` ,
72+ icon : '' ,
73+ isDisabled,
74+ command : 'tab:split_v'
75+ } , {
76+ name : i18n `tab.contextMenu.horizontalSplit` ,
77+ icon : '' ,
78+ isDisabled,
79+ command : 'tab:split_h'
80+ } ] )
81+ }
82+ }
83+
7384 componentWillUnmount ( ) {
7485 if ( this . dispose ) {
75- console . log ( this . dispose )
7686 this . dispose ( )
7787 }
7888 }
@@ -83,7 +93,7 @@ class TabContainer extends Component {
8393 return (
8494 < div className = { cx ( 'tab-container' , { fullscreen : fullScreenActiveContent } ) } >
8595 < TabBar tabGroup = { tabGroup }
86- contextMenuItems = { contextMenuItems }
96+ contextMenuItems = { this . renderItem ( tabGroup ) }
8797 closePane = { closePane }
8898 handleFullScreen = { this . handleFullScreen }
8999 />
0 commit comments