Skip to content

Commit bdc4ea1

Browse files
author
sakuraash
committed
suport pre deploy, update plugindev style
1 parent 3d18c60 commit bdc4ea1

13 files changed

Lines changed: 160 additions & 89 deletions

File tree

‎app/backendAPI/packageAPI.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@ export const fetchUserPackagelist = () => {
5959
export const fetchUserPackageScript = (url) => {
6060
return axios.get(url).then(res => res.data)
6161
}
62+
63+
export const fethUserPreDeployPlugins = () => {
64+
return request.get('/user-plugin/pre/deploy/list')
65+
}

‎app/components/MonacoEditor/utils/initializationOptions.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default {
1919
}
2020
},
2121
trace: {
22-
server: 'verbose'
22+
server: 'off'
2323
},
2424
import: {
2525
gradle: {
@@ -103,6 +103,9 @@ export default {
103103
workspaceFolders: [],
104104
settings: {
105105
pyls: {
106+
trace: {
107+
server: 'off'
108+
},
106109
configurationSources: ['pycodestyle'],
107110
rope: { ropeFolder: null, extensionModules: null },
108111
plugins: {

‎app/components/PluginDev/index.js‎

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,58 @@ import { pluginDevStore } from 'components/Plugins/store'
55

66
@observer
77
class PluginDev extends PureComponent {
8+
handleGoDoc = () => {
9+
window.open('codingide.coding.me/WebIDE-Plugin-Template/#/')
10+
}
11+
812
render () {
913
return (
1014
<div className='plugin-dev-container'>
1115
<div className='panel-heading'>
12-
<i className='icon fa fa-cubes' />
13-
{i18n`plugin.header`}
16+
<p>
17+
<i className='icon fa fa-cubes' />
18+
{i18n`plugin.header`}
19+
</p>
20+
<span onClick={this.handleGoDoc}>
21+
<i className='fa fa-book' aria-hidden />
22+
开发文档
23+
</span>
1424
</div>
15-
<a>如何开发 Cloud Studio 插件?</a>
16-
<p>请先确保已在终端内启动插件开发服务(yarn start)</p>
17-
<p>
18-
名称:
19-
<span>
25+
<div className='plugin-detail-panel'>
26+
<p className='plugin-name'>
2027
{pluginDevStore.infomation &&
2128
(pluginDevStore.infomation.displayName || pluginDevStore.infomation.name)}
22-
</span>
23-
</p>
24-
<p>
25-
描述:
26-
<span>{pluginDevStore.infomation && pluginDevStore.infomation.description}</span>
27-
</p>
28-
<p>
29-
版本:
30-
{pluginDevStore.infomation && pluginDevStore.infomation.version}
31-
</p>
32-
<p>
33-
插件服务状态:
34-
{pluginDevStore.online ? '连接成功' : '未连接'}
35-
</p>
36-
<p>
37-
编译状态:
38-
<span>{pluginDevStore.progress && pluginDevStore.progress.progress}%</span>
39-
<span>{pluginDevStore.progress && pluginDevStore.progress.msg}</span>
40-
</p>
41-
<button
42-
className='btn btn-default'
43-
onClick={() => dispatchCommand(pluginDevStore.online ? 'plugin:unmount' : 'plugin:mount')}
44-
>
45-
{pluginDevStore.online ? '卸载插件' : '加载插件'}
46-
</button>
47-
{pluginDevStore.online && (
48-
<button className='btn btn-default' onClick={() => dispatchCommand('plugin:remount')}>
49-
重载插件
50-
</button>
51-
)}
29+
</p>
30+
<p className='plugin-description'>
31+
{pluginDevStore.infomation && pluginDevStore.infomation.description}
32+
</p>
33+
<p className='plugin-description'>
34+
{pluginDevStore.infomation && `当前版本:${pluginDevStore.infomation.version}`}
35+
</p>
36+
<div className='plugin-dev-server'>
37+
<p>请先确保已在终端内启动插件(yarn start)</p>
38+
<p>
39+
插件状态:
40+
{pluginDevStore.online ? '连接成功' : '未连接'}
41+
</p>
42+
<p>
43+
编译状态:
44+
<span>{pluginDevStore.progress && pluginDevStore.progress.progress}%</span>
45+
<span>{pluginDevStore.progress && pluginDevStore.progress.msg}</span>
46+
</p>
47+
<button
48+
className='btn btn-default'
49+
onClick={() => dispatchCommand(pluginDevStore.online ? 'plugin:unmount' : 'plugin:mount')}
50+
>
51+
{pluginDevStore.online ? '卸载插件' : '加载插件'}
52+
</button>
53+
{pluginDevStore.online && (
54+
<button className='btn btn-default' style={{ marginLeft: '10px' }} onClick={() => dispatchCommand('plugin:remount')}>
55+
重载插件
56+
</button>
57+
)}
58+
</div>
59+
</div>
5260
</div>
5361
)
5462
}

‎app/components/Plugins/actions.js‎

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { registerAction } from 'utils/actions'
22
import { PluginRegistry } from 'utils/plugins'
3-
import React from 'react'
43
import { autorun, observable } from 'mobx'
54
import config from 'config'
65
import { notify, NOTIFY_TYPE } from 'components/Notification/actions'
@@ -167,31 +166,50 @@ export const fetchUserPackage = registerAction(FETCH_USER_PACKAGE, (pkg) => {
167166
.then(pkgId => togglePackage({ pkgId, shouldEnable: true, type: 'Required' }))
168167
})
169168

169+
const loadUserPackages = async (packages) => {
170+
const convert = packages.map((p) => ({
171+
name: p.pluginName,
172+
author: p.createdBy || '',
173+
description: p.remark,
174+
displayName: p.pluginName,
175+
enabled: true,
176+
id: p.id,
177+
requirement: 'Required',
178+
status: 'Available',
179+
version: p.currentVersion || '[pre deploy]',
180+
userPlugin: true,
181+
filePath: p.pluginFilePath
182+
}))
183+
184+
/* eslint-disable */
185+
for (const pkg of convert) {
186+
store.list.push(pkg)
187+
try {
188+
await fetchUserPackage(pkg)
189+
/* eslint-enable */
190+
} catch (err) {
191+
console.error(`Failed to load plugin ${pkg.name}: ${err.message}.`)
192+
}
193+
}
194+
}
195+
170196
export const loadPackagesByUser = registerAction(PRELOAD_USER_EXTENSION, () => {
171197
const userPackagePromise = api.fetchUserPackagelist()
172-
return userPackagePromise.then(async (response) => {
173-
if (response.code === 0) {
174-
const { data } = response
175-
const convert = data.map((p) => ({
176-
name: p.pluginName,
177-
author: p.createdBy,
178-
description: p.remark,
179-
displayName: p.pluginName,
180-
enabled: true,
181-
id: p.id,
182-
requirement: 'Required',
183-
status: 'Available',
184-
version: p.currentVersion,
185-
userPlugin: true,
186-
filePath: p.pluginFilePath
187-
}))
188-
189-
for (const pkg of convert) {
190-
store.list.push(pkg)
191-
await fetchUserPackage(pkg)
192-
}
193-
}
194-
})
198+
const preDeployPackagePromise = api.fethUserPreDeployPlugins()
199+
return Promise.all([userPackagePromise, preDeployPackagePromise])
200+
.then(async ([userpackages, preDeployPackages]) => {
201+
const userPlugins = userpackages.data
202+
const preDeployPlugins = preDeployPackages.data
203+
const enableUserPackages = userPlugins.reduce((pre, cur) => {
204+
if (!preDeployPlugins.find(prePackage => prePackage.id === cur.id)) {
205+
pre.push(cur)
206+
}
207+
return pre
208+
}, [])
209+
store.preDeployPlugins = preDeployPlugins
210+
211+
loadUserPackages([...enableUserPackages, ...preDeployPlugins])
212+
})
195213
})
196214

197215
export const mountPackagesByType = (type) => {
@@ -275,7 +293,7 @@ export const startRemoteHMRServer = registerAction('plugin:mount', () => {
275293
})
276294

277295
devSocket.on('connect_error', () => {
278-
notify({ notifyType: NOTIFY_TYPE.ERROR, message: '无法连接到插件开发服务,请确保已经执行 yarn start 且服务正常启动' })
296+
notify({ notifyType: NOTIFY_TYPE.ERROR, message: '无法连接到插件服务,请确保已经执行 yarn start 且正常启动' })
279297
})
280298

281299
devSocket.on('progress', (progress) => {
@@ -347,7 +365,7 @@ export const startRemoteHMRServer = registerAction('plugin:mount', () => {
347365
devSocket.on('disconnect', () => {
348366
notify({
349367
notifyType: NOTIFY_TYPE.INFO,
350-
message: '插件开发服务已断开连接'
368+
message: '插件已断开连接'
351369
})
352370
store.pluginDevState.online = false
353371
const { infomation: { name, version } } = store.pluginDevState

‎app/components/Plugins/store.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ const store = {
1515
infomation: null,
1616
online: false,
1717
}),
18-
pluginSettingsItem: observable.map()
18+
pluginSettingsItem: observable.map(),
19+
preDeployPlugins: observable([])
1920
}
2021

2122
// for test

‎app/extensions/PluginApp.ext.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createProvider, connectAdvanced } from 'react-redux'
77

88
import settings from '../settings'
99

10-
class PluginApp {
10+
class PluginContext {
1111
constructor (options) {
1212
this.sdk = new CodingSDK(options) || ''
1313
this.inializeData = this.sdk.getData() || {}
@@ -120,4 +120,4 @@ export const IPropertiesType = {
120120
boolean: 'boolean'
121121
}
122122

123-
export default PluginApp
123+
export default PluginContext

‎app/styles/core-ui/Plugin.styl‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
.plugin-dev-container {
3+
.panel-heading {
4+
height: 28px;
5+
line-height: 28px;
6+
padding: 0 10px;
7+
display: flex;
8+
justify-content: space-between;
9+
.fa {
10+
margin-right: 4px;
11+
}
12+
&>p {
13+
margin: 0px;
14+
}
15+
}
16+
.plugin-detail-panel {
17+
padding: 16px;
18+
.plugin-name {
19+
font-size: 18px;
20+
margin-top: 0px;
21+
margin-bottom: 10px;
22+
}
23+
.plugin-description {
24+
font-size: 12px;
25+
margin: 5px 0px;
26+
}
27+
.plugin-dev-server {
28+
margin-top: 20px;
29+
}
30+
}
31+
}

‎app/styles/core-ui/index.styl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@
3131
@import "./FileTreeTool";
3232
@import "./MonacoEditor";
3333
@import "./Search";
34+
@import "./Plugin";

‎app/styles/dark/styles/plugin.styl‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
.plugin-dev-container {
33
color: #ccc !important;
44
.panel-heading {
5-
height: 28px;
6-
line-height: 28px;
75
background-color: $pane-item-background-color;
8-
padding: 0 10px;
9-
color: #ccc !important;
106
border-color: $tab-bar-border-color;
11-
.fa {
12-
margin-right: 4px;
7+
color: #ccc !important;
8+
}
9+
.plugin-detail-panel {
10+
.plugin-dev-server {
11+
color: #aaa;
1312
}
14-
}
13+
}
1514
}

‎app/styles/light/index.styl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
@import './styles/debug';
1818
@import './styles/settings';
1919
@import './styles/search';
20+
@import './styles/plugin';

0 commit comments

Comments
 (0)