Skip to content

Commit 8d97585

Browse files
authored
Merge pull request #503 from Coding/global-disabled
自己可以禁用安装的插件以及全局禁用插件的样式改动
2 parents ed491d4 + 9a66f50 commit 8d97585

File tree

18 files changed

+332
-107
lines changed

18 files changed

+332
-107
lines changed

app/dashboard/api/axios.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ axios.get = (url, overrideHeaders = {}) => {
2828
credentials: 'include',
2929
headers: { ...headers, ...overrideHeaders },
3030
}).then(res => {
31-
return res.json();
31+
if (res.status !== 204) {
32+
return res.json();
33+
}
3234
}).catch(err => {
3335
notify({ message: String(err), notifyType: NOTIFY_TYPE.ERROR });
3436
});

app/dashboard/api/plugin.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import axios from './axios';
22

3-
export const getEnablePlugin = () => {
4-
return axios.get('/user-plugin/enable/list');
3+
export const getInstalledPlugin = () => {
4+
return axios.get('/user-plugin/install/list');
5+
}
6+
7+
export const getInstalledDisabledPlugin = () => {
8+
return axios.get('/user-plugin/global_disable/list');
59
}
610

711
export const getBuiltinPlugin = () => {
@@ -32,12 +36,12 @@ export const uninstallPlugin = (data) => {
3236
return axios.put('/user-plugin/enable', data);
3337
}
3438

35-
export const updatePluginVersion = (data) => {
36-
return axios.post('/user-plugin/version', data);
39+
export const switchPluginEnable = ({ pluginId, status }) => {
40+
return axios.put(`/user-plugin/enable_status?pluginId=${pluginId}&status=${status}`);
3741
}
3842

39-
export const switchPluginEnable = (data) => {
40-
return axios.put('/user-plugin/enable', data);
43+
export const updatePluginVersion = (data) => {
44+
return axios.post('/user-plugin/version', data);
4145
}
4246

4347
export const publishPlugin = (data) => {

app/dashboard/i18n/en_US/plugin.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"searchPlugin": "Search Plugins",
4141
"userCount": " person rating",
4242
"published": "Published",
43+
"disabled": "Disabled",
4344
"newVersion": "New Version",
4445
"nowPrePublish": "You are currently using a Pre-Publish version. ",
4546
"status0": "Your plugin has not been published yet and is not visible to the outside world. You can publish the plugin by clicking「Publish」below.",
@@ -70,5 +71,8 @@
7071
"preStat3": "The last Pre-Publish build failed. ",
7172
"preStat3Click": "See details.",
7273
"preStat3Desc": "The last pre-publish build failed, you can modify the code and re-publish it. The build log is as follows:",
73-
"preStat3Action": "Pre-Publish Again"
74+
"preStat3Action": "Pre-Publish Again",
75+
"pluginDisabled": "Disabled due to non-compliance",
76+
"pluginDisabledStatus": "Your plugin has been disabled due to non-compliance.",
77+
"pluginDisabledTip": "The plugin has been disabled and cannot be published."
7478
}

app/dashboard/i18n/zh_CN/global.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,5 @@
7474
"period": "",
7575
"globalTip": "您还没有设置用户名,请先设置用户名,该用户名将作为您在该平台上的唯一标识。",
7676
"submitting": "提交中...",
77-
"eventStreamBulletin1": "尊敬的开发者,由于受 ",
78-
"eventStreamBulletin2": "[ event-stream 包事件 ]",
79-
"eventStreamBulletin3": " 影响,您的插件需要手动删除 `yarn.lock` 文件并重新安装依赖,再推送代码发布新版本或预发布。"
77+
"remove": "移除"
8078
}

app/dashboard/i18n/zh_CN/plugin.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
"creatingPlugin": "正在创建插件...",
1919
"hasPrePublish": "该插件已经预发布,您可以在自己的所有工作空间预览该插件。",
2020
"cancelPrePublish": "关闭预发布",
21-
"cannotPublishForAuditing": "上次发布正在审核中,暂时无法发布",
22-
"cannotPublishForBuilding": "上次发布正在构建中,暂时无法发布",
21+
"cannotPublishForAuditing": "上次发布正在审核中,暂时无法发布",
22+
"cannotPublishForBuilding": "上次发布正在构建中,暂时无法发布",
2323
"publishing": "正在发布...",
2424
"pluginSet": "插件设置",
2525
"basicSet": "基本设置",
@@ -40,6 +40,7 @@
4040
"searchPlugin": "搜索插件",
4141
"userCount": "人评分",
4242
"published": "已发布",
43+
"disabled": "已被禁用",
4344
"newVersion": "新版本",
4445
"nowPrePublish": "您目前使用的是预发布版本。",
4546
"status0": "您的插件尚未发布版本,处于对外不可见状态,您可以点击下方「发布」来发布插件。",
@@ -70,5 +71,8 @@
7071
"preStat3": "上次预发布构建失败。",
7172
"preStat3Click": "查看详情",
7273
"preStat3Desc": "上次预发布构建失败,您可以修改代码后重新预发布。构建日志如下:",
73-
"preStat3Action": "重新预发布"
74+
"preStat3Action": "重新预发布",
75+
"pluginDisabled": "该插件因不符合规范已被禁用",
76+
"pluginDisabledStatus": "您的插件因不符合规范已被禁用。",
77+
"pluginDisabledTip": "插件已被禁用,无法发布。"
7478
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React, { PureComponent } from 'react';
2+
3+
import './switch.css';
4+
5+
class Switch extends PureComponent {
6+
state = {
7+
on: this.props.on,
8+
loading: false,
9+
}
10+
11+
render() {
12+
const { loading } = this.state;
13+
const { on } = this.props;
14+
return (
15+
<div className={`dash-switch${on ? ' on' : ''}${loading ? ' loading' : ''}`} onClick={this.handleClick}>
16+
<div className="circle">
17+
<div className="moon"></div>
18+
</div>
19+
</div>
20+
);
21+
}
22+
23+
handleClick = () => {
24+
const { on, handler } = this.props;
25+
this.setState({ on, loading: true });
26+
handler();
27+
}
28+
29+
componentDidUpdate() {
30+
const { on, loading } = this.state;
31+
if (on !== this.props.on && loading) {
32+
this.setState({ loading: false });
33+
}
34+
}
35+
}
36+
37+
export default Switch;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Switch from './Switch';
2+
3+
export default Switch;
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.dash-switch {
2+
width: 38px;
3+
height: 18px;
4+
border-radius: 9px;
5+
background-color: #252526;
6+
cursor: pointer;
7+
transition: background-color .2s ease;
8+
position: relative;
9+
}
10+
.dash-switch.loading {
11+
background-color: #2d2d2d;
12+
}
13+
.dash-switch.on {
14+
background-color: #337ab7;
15+
}
16+
.dash-switch.on.loading {
17+
background-color: #37648c;
18+
}
19+
.dash-switch .circle {
20+
width: 12px;
21+
height: 12px;
22+
border-radius: 50%;
23+
background-color: #fff;
24+
overflow: hidden;
25+
transition: left .2s ease;
26+
position: absolute;
27+
top: 3px;
28+
left: 3px;
29+
}
30+
.dash-switch.loading .circle {
31+
background-color: #ccc;
32+
}
33+
.dash-switch.on .circle {
34+
left: 23px;
35+
}
36+
.dash-switch .circle .moon {
37+
display: none;
38+
width: 10px;
39+
height: 10px;
40+
border: 2px solid;
41+
border-color: #999 transparent transparent transparent;
42+
border-radius: 50%;
43+
animation: loading 1s linear infinite;
44+
position: absolute;
45+
top: 1px;
46+
left: 1px;
47+
}
48+
.dash-switch.loading .circle .moon {
49+
display: block;
50+
}
51+
@keyframes loading {
52+
0% {
53+
transform: rotate(0deg);
54+
}
55+
100% {
56+
transform: rotate(360deg);
57+
}
58+
}

app/dashboard/view/home/Home.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Home extends Component {
2424
super(props);
2525
this.state = {
2626
loaded: false,
27-
isMaskOn: true,
27+
isMaskOn: false,
2828
isBellOn: false,
2929
isProfileOn: false,
3030
};
@@ -34,7 +34,7 @@ class Home extends Component {
3434
render() {
3535
const { loaded, isMaskOn, isBellOn, isProfileOn } = this.state;
3636
const { isMbarOn, wsCount, hideMbar } = this.props;
37-
if (loaded && isMaskOn) {
37+
if (isMaskOn) {
3838
return <Mask />;
3939
}
4040
return (
@@ -59,13 +59,13 @@ class Home extends Component {
5959
<NavLink className="nav-item" activeClassName="active" to="/dashboard/plugin">{i18n('global.plugin')}</NavLink>
6060
<NavLink className="nav-item" activeClassName="active" to="/dashboard/setting">{i18n('global.setting')}</NavLink>
6161
</div>
62-
{!isMaskOn && <Bell on={isBellOn} togglePanel={this.toggleBellPanel} />}
63-
{!isMaskOn && <Profile on={isProfileOn} togglePanel={this.toggleProfilePanel} />}
62+
{loaded && !isMaskOn && <Bell on={isBellOn} togglePanel={this.toggleBellPanel} />}
63+
{loaded && !isMaskOn && <Profile on={isProfileOn} togglePanel={this.toggleProfilePanel} />}
6464
</div>
6565
<div className="dash-main">
6666
<Banner />
6767
<div className="dash-view">
68-
{!isMaskOn && (
68+
{loaded && !isMaskOn && (
6969
<Switch>
7070
<Route exact path="/dashboard/workspace" component={Workspace}></Route>
7171
<Route exact path="/dashboard/workspace/create" component={Create}></Route>
@@ -117,9 +117,10 @@ class Home extends Component {
117117
if (res.code === 0) {
118118
if (!/^dtid_[a-z0-9]+/i.test(res.data.global_key)) {
119119
this.props.logIn(res.data);
120-
this.setState({ isMaskOn: false });
121120
// 获取工作空间数量信息
122121
this.fetchWorkspaceCount();
122+
} else {
123+
this.setState({ isMaskOn: true });
123124
}
124125
} else {
125126
window.top.postMessage({ path: '/intro' }, '*');

app/dashboard/view/plugin/mCard/MCard.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,37 @@ import parseStatus from '../../pluginSet/status';
99

1010
class MCard extends Component {
1111
render() {
12-
const { id, pluginName, remark, createdBy, repoName, pluginVersions } = this.props;
12+
const { id, pluginName, remark, createdBy, repoName, pluginVersions, globalStatus } = this.props;
1313
const { version, status, hasPrePublish, preStatus } = parseStatus(pluginVersions);
1414
const marketHref = window === window.top ? `${window.location.origin}/plugins/detail/${id}` : `${config.studioOrigin}/plugins/detail/${id}`;
1515
const wsHref = `${window === window.top ? window.location.origin : config.studioOrigin}/ws/?ownerName=${createdBy}&projectName=${repoName}`;
1616
return (
1717
<div className = "plugin-card">
1818
<div className="top">
1919
{
20-
status === 5 ? (
20+
(status === 5 && globalStatus === 1) ? (
2121
<a className="name" href={marketHref} target="_blank" rel="noopener noreferrer">{pluginName}</a>
2222
) : <span className="name">{pluginName}</span>
2323
}
24-
<div className="right">
25-
{status === 5 && <div className="version">v{version}</div>}
26-
{
27-
(hasPrePublish && preStatus === 2) ? (
28-
<div className="tag">{i18n('plugin.prePublish')}</div>
29-
) : (status === 5 && <div className="tag">{i18n('plugin.published')}</div>)
30-
}
31-
</div>
24+
{globalStatus === 1 ? (
25+
<div className="right">
26+
{status === 5 && <div className="version">v{version}</div>}
27+
{
28+
(hasPrePublish && preStatus === 2) ? (
29+
<div className="tag">{i18n('plugin.prePublish')}</div>
30+
) : (status === 5 && <div className="tag">{i18n('plugin.published')}</div>)
31+
}
32+
</div>
33+
) : <div className="right"><div className="tag">{i18n('plugin.disabled')}</div></div>}
3234
</div>
3335
<div className="desc">
3436
<span>{remark}</span>
3537
</div>
3638
<div className="control">
37-
<Link className="button" to={`/dashboard/plugin/mine/${id}`}>{i18n('global.manage')}</Link>
38-
<a className="button" href={wsHref} target="_blank" rel="noopener noreferrer">{i18n('global.workspace')}</a>
39+
<div className="button-wrap">
40+
<Link className="button" to={`/dashboard/plugin/mine/${id}`}>{i18n('global.manage')}</Link>
41+
<a className="button" href={wsHref} target="_blank" rel="noopener noreferrer">{i18n('global.workspace')}</a>
42+
</div>
3943
</div>
4044
</div>
4145
);

0 commit comments

Comments
 (0)