@electerm/electerm-react 2.1.8 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -107,6 +107,12 @@ export const settingMap = buildConst([
107
107
  'profiles'
108
108
  ])
109
109
 
110
+ export const staticNewItemTabs = new Set([
111
+ 'terminalThemes',
112
+ 'quickCommands',
113
+ 'profiles'
114
+ ])
115
+
110
116
  export const infoTabs = buildConst([
111
117
  'info',
112
118
  'deps',
@@ -24,7 +24,7 @@ export default (arr, tab) => {
24
24
  } else if (tab === settingMap.quickCommands) {
25
25
  return {
26
26
  id: '',
27
- name: encodeURIComponent(newQuickCommand)
27
+ name: e(newQuickCommand)
28
28
  }
29
29
  } else if (tab === settingMap.profiles) {
30
30
  return {
@@ -138,13 +138,6 @@ export default function QuickCommandForm (props) {
138
138
  const wiki = 'https://github.com/electerm/electerm/wiki/quick-command-templates'
139
139
  return (
140
140
  <>
141
- <p>
142
- <b className='mg1r'>{e('templates')}:</b>
143
- <span className='mg1r'>{templatesStr}</span>
144
- <HelpIcon
145
- link={wiki}
146
- />
147
- </p>
148
141
  <Form
149
142
  form={form}
150
143
  onFinish={handleSubmit}
@@ -210,6 +203,13 @@ export default function QuickCommandForm (props) {
210
203
  </Button>
211
204
  </p>
212
205
  </FormItem>
206
+ <p>
207
+ <b className='mg1r'>{e('templates')}:</b>
208
+ <span className='mg1r'>{templatesStr}</span>
209
+ <HelpIcon
210
+ link={wiki}
211
+ />
212
+ </p>
213
213
  </Form>
214
214
  </>
215
215
  )
@@ -9,7 +9,8 @@ import createName, { createTitleTag } from '../../common/create-title'
9
9
  import classnames from 'classnames'
10
10
  import { noop } from 'lodash-es'
11
11
  import highlight from '../common/highlight'
12
- import { settingSyncId, settingCommonId } from '../../common/constants'
12
+ import { settingSyncId, settingCommonId, staticNewItemTabs } from '../../common/constants'
13
+ import getInitItem from '../../common/init-setting-item'
13
14
  import './list.styl'
14
15
 
15
16
  const e = window.translate
@@ -95,6 +96,17 @@ export default class ItemList extends React.PureComponent {
95
96
  return icon
96
97
  }
97
98
 
99
+ renderNewItem () {
100
+ const { type } = this.props
101
+
102
+ if (!staticNewItemTabs.has(type)) {
103
+ return null
104
+ }
105
+
106
+ const newItem = getInitItem([], type)
107
+ return this.renderItem(newItem, -1)
108
+ }
109
+
98
110
  renderItem = (item, i) => {
99
111
  const { onClickItem, type, activeItemId } = this.props
100
112
  const { id } = item
@@ -175,6 +187,7 @@ export default class ItemList extends React.PureComponent {
175
187
  {this.renderLabels ? this.renderLabels() : null}
176
188
  {this.renderSearch()}
177
189
  <div className='item-list-wrap' style={listStyle}>
190
+ {this.renderNewItem()}
178
191
  {
179
192
  list.map(this.renderItem)
180
193
  }
@@ -38,7 +38,7 @@ export default class ScrollFiles extends Component {
38
38
  pageSize: this.state.pageSize,
39
39
  total: this.props.list.length,
40
40
  showSizeChanger: false,
41
- size: 'small',
41
+ simple: true,
42
42
  onChange: this.onChange
43
43
  }
44
44
  return (
@@ -144,6 +144,14 @@ class ShortcutControl extends React.PureComponent {
144
144
  window.store.cloneToNextLayout()
145
145
  }, 500)
146
146
 
147
+ duplicateTabShortcut = throttle((e) => {
148
+ e.stopPropagation()
149
+ const { activeTabId } = window.store
150
+ if (activeTabId) {
151
+ window.store.duplicateTab(activeTabId)
152
+ }
153
+ }, 500)
154
+
147
155
  prevTabShortcut = throttle((e) => {
148
156
  e.stopPropagation()
149
157
  window.store.clickPrevTab()
@@ -21,6 +21,11 @@ export default () => {
21
21
  shortcut: 'ctrl+/',
22
22
  shortcutMac: 'meta+/'
23
23
  },
24
+ {
25
+ name: 'app_duplicateTab',
26
+ shortcut: 'alt+c',
27
+ shortcutMac: 'alt+c'
28
+ },
24
29
  {
25
30
  name: 'app_newBookmark',
26
31
  shortcut: 'ctrl+n',
@@ -268,6 +268,7 @@ class Tab extends Component {
268
268
  const reloadShortcut = this.getShortcut('app_reloadCurrentTab')
269
269
  const closeShortcut = this.getShortcut('app_closeCurrentTab')
270
270
  const cloneToNextShortcut = this.getShortcut('app_cloneToNextLayout')
271
+ const duplicateShortcut = this.getShortcut('app_duplicateTab')
271
272
 
272
273
  const x = [
273
274
  {
@@ -294,7 +295,8 @@ class Tab extends Component {
294
295
  {
295
296
  key: 'handleDup',
296
297
  icon: <iconsMap.CopyOutlined />,
297
- label: e('duplicate')
298
+ label: e('duplicate'),
299
+ extra: duplicateShortcut
298
300
  },
299
301
  {
300
302
  key: 'cloneToNextLayout',
@@ -7,7 +7,8 @@ import { LoadingOutlined, CheckCircleOutlined } from '@ant-design/icons'
7
7
  import { pick } from 'lodash-es'
8
8
  import { Pagination } from 'antd'
9
9
  import ThemeListItem from './theme-list-item'
10
- import { defaultTheme } from '../../common/constants'
10
+ import { defaultTheme, settingMap } from '../../common/constants'
11
+ import getInitItem from '../../common/init-setting-item'
11
12
  import './terminal-theme-list.styl'
12
13
 
13
14
  const e = window.translate
@@ -58,13 +59,33 @@ export default class ThemeList extends List {
58
59
  )
59
60
  }
60
61
 
62
+ renderNewItem () {
63
+ const newThemeItem = getInitItem([], settingMap.terminalThemes)
64
+ const itemProps = {
65
+ item: newThemeItem,
66
+ renderDelBtn: this.renderDelBtn,
67
+ activeItemId: this.props.activeItemId,
68
+ ...pick(
69
+ this.props,
70
+ [
71
+ 'onClickItem',
72
+ 'theme',
73
+ 'keyword'
74
+ ]
75
+ )
76
+ }
77
+ return (
78
+ <ThemeListItem key='new-theme' {...itemProps} />
79
+ )
80
+ }
81
+
61
82
  filter = list => {
62
- const { keyword, ready } = this.state
83
+ const { keyword } = this.state
63
84
  return keyword
64
- ? list.slice(0, ready ? list.length : 2).filter(item => {
85
+ ? list.filter(item => {
65
86
  return item.name.toLowerCase().includes(keyword.toLowerCase())
66
87
  })
67
- : list.slice(0, ready ? list.length : 2)
88
+ : list
68
89
  }
69
90
 
70
91
  paged = list => {
@@ -77,6 +98,13 @@ export default class ThemeList extends List {
77
98
 
78
99
  render () {
79
100
  const { ready, page, pageSize } = this.state
101
+ if (!ready) {
102
+ return (
103
+ <div className='pd3 aligncenter'>
104
+ <LoadingOutlined />
105
+ </div>
106
+ )
107
+ }
80
108
  let {
81
109
  list = [],
82
110
  type,
@@ -92,6 +120,7 @@ export default class ThemeList extends List {
92
120
  {this.renderSearch()}
93
121
  {this.renderCurrentTheme()}
94
122
  <div className='item-list-wrap' style={listStyle}>
123
+ {this.renderNewItem()}
95
124
  {
96
125
  list.map(this.renderItem)
97
126
  }
@@ -101,17 +130,10 @@ export default class ThemeList extends List {
101
130
  total={all}
102
131
  current={page}
103
132
  pageSize={pageSize}
133
+ showLessItems
134
+ simple
104
135
  onShowSizeChange={this.handlePageSizeChange}
105
136
  />
106
- {
107
- ready
108
- ? null
109
- : (
110
- <div className='pd3 aligncenter'>
111
- <LoadingOutlined />
112
- </div>
113
- )
114
- }
115
137
  </div>
116
138
  )
117
139
  }
@@ -309,6 +309,10 @@ export default class ItemListTree extends Component {
309
309
  store.storeAssign({
310
310
  currentBookmarkGroupId: id
311
311
  })
312
+ const func = this.props.expandedKeys.includes(id)
313
+ ? this.onUnExpandKey
314
+ : this.onExpandKey
315
+ func({ id })
312
316
  } else {
313
317
  store.storeAssign({
314
318
  currentBookmarkGroupId: findBookmarkGroupId(store.bookmarkGroups, id)
@@ -32,7 +32,8 @@ import getBrand from '../components/ai/get-brand'
32
32
  import {
33
33
  settingMap,
34
34
  terminalSshConfigType,
35
- paneMap
35
+ paneMap,
36
+ staticNewItemTabs
36
37
  } from '../common/constants'
37
38
  import getInitItem from '../common/init-setting-item'
38
39
  import createTitle from '../common/create-title'
@@ -149,10 +150,12 @@ class Store {
149
150
  const initItem = getInitItem(arr, settingTab)
150
151
  return settingTab === settingMap.history
151
152
  ? arr
152
- : [
153
- deepCopy(initItem),
154
- ...arr
155
- ]
153
+ : staticNewItemTabs.has(settingTab)
154
+ ? arr // Don't add initItem for these tabs, they will be handled separately
155
+ : [
156
+ deepCopy(initItem),
157
+ ...arr
158
+ ]
156
159
  }
157
160
 
158
161
  get terminalCommandSuggestions () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "2.1.8",
3
+ "version": "2.1.16",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",