Skip to content

Commit f04024e

Browse files
authored
Merge pull request #453 from Coding/with-backend
后端我安装的插件字段由精简,前端做相应调整
2 parents 4fd1889 + 9aabb36 commit f04024e

File tree

13 files changed

+115
-97
lines changed

13 files changed

+115
-97
lines changed

app/changelog.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
<div id="pc-has-not-login" class="right">
523523
<a href="https://cloud.tencent.com/register" target="_blank" rel="noopener noreferrer">注册</a>
524524
<span class="divide">|</span>
525-
<a href="https://dev.tencent.com/login" target="_blank" rel="noopener noreferrer">登录</a>
525+
<a href="https://dev.tencent.com/login?return_url=https://studio.dev.tencent.com/changelog" target="_blank" rel="noopener noreferrer">登录</a>
526526
</div>
527527
<div id="pc-has-login" class="right" style="display: none;">
528528
<div className="title">
@@ -600,7 +600,7 @@
600600
</a>
601601
</div>
602602
<div id="mobile-has-not-login">
603-
<a class="title" href="https://dev.tencent.com/login" target="_blank" rel="noopener noreferrer">登录</a>
603+
<a class="title" href="https://dev.tencent.com/login?return_url=https://studio.dev.tencent.com/changelog" target="_blank" rel="noopener noreferrer">登录</a>
604604
<a class="title" href="https://cloud.tencent.com/register" target="_blank" rel="noopener noreferrer">注册</a>
605605
</div>
606606
<div class="blank"></div>

app/dashboard/utils/date.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const twoDigit = (num) => {
66

77
export const getModifiedTime = (now, lastModified) => {
88
const ms = now - lastModified;
9-
const d = Math.floor(ms / 3600000 / 24);
9+
const d = Math.ceil(ms / 3600000 / 24);
1010
if (d > 0) {
1111
return i18n('global.lastModified', { days: d });
1212
} else {
@@ -16,7 +16,7 @@ export const getModifiedTime = (now, lastModified) => {
1616

1717
export const getDeletedTime = (now, lastModified) => {
1818
const ms = now - lastModified;
19-
const d = Math.floor(ms / 3600000 / 24);
19+
const d = Math.ceil(ms / 3600000 / 24);
2020
if (d > 0) {
2121
return i18n('global.deletedDaysAgo', { days: d });
2222
} else {

app/dashboard/view/plugin/card/Card.js

Lines changed: 0 additions & 80 deletions
This file was deleted.

app/dashboard/view/plugin/card/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { Component } from 'react';
2+
import { Link } from 'react-router-dom';
3+
4+
import './card.css';
5+
6+
import i18n from '../../../utils/i18n';
7+
import config from '../../../utils/config';
8+
import parseStatus from '../../pluginSet/status';
9+
10+
class MCard extends Component {
11+
render() {
12+
const { id, pluginName, remark, createdBy, repoName, pluginVersions } = this.props;
13+
const { version, status, hasPrePublish, preStatus } = parseStatus(pluginVersions);
14+
const marketHref = window === window.top ? `${window.location.origin}/plugins/detail/${id}` : `${config.studioOrigin}/plugins/detail/${id}`;
15+
const wsHref = `${window === window.top ? window.location.origin : config.studioOrigin}/ws/?ownerName=${createdBy}&projectName=${repoName}`;
16+
return (
17+
<div className = "plugin-card">
18+
<div className="top">
19+
{
20+
status === 5 ? (
21+
<a className="name" href={marketHref} target="_blank" rel="noopener noreferrer">{pluginName}</a>
22+
) : <span className="name">{pluginName}</span>
23+
}
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>
32+
</div>
33+
<div className="desc">
34+
<span>{remark}</span>
35+
</div>
36+
<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>
40+
</div>
41+
);
42+
}
43+
}
44+
45+
export default MCard;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
overflow: hidden;
5454
position: relative;
5555
}
56-
.plugin-list .plugin-card .desc .ellipsis {
56+
.plugin-list .plugin-card .desc::after {
57+
content: '';
5758
width: 60px;
5859
height: 20px;
5960
background: linear-gradient(to right, transparent, #3b3b3b);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import MCard from './MCard';
2+
3+
export default MCard;

app/dashboard/view/plugin/mine/Mine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22

33
import './mine.css';
44

5-
import Card from '../card';
5+
import MCard from '../mCard';
66
import NoData from '../../../share/noData';
77
import Topbar from '../topbar';
88

@@ -21,7 +21,7 @@ class Mine extends Component {
2121
<Topbar />
2222
{
2323
plugins.length ? (
24-
plugins.map(plugin => <Card key={plugin.id} {...plugin} belong={3} />)
24+
plugins.map(plugin => <MCard key={plugin.id} {...plugin} />)
2525
) : <NoData />
2626
}
2727
</div>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React, { Component } from 'react';
2+
3+
import i18n from '../../../utils/i18n';
4+
import api from '../../../api';
5+
import config from '../../../utils/config';
6+
import { notify, NOTIFY_TYPE } from 'components/Notification/actions';
7+
8+
const httpReg = /^http/;
9+
10+
class TCard extends Component {
11+
render() {
12+
const { id, pluginName, remark, userAvatar, createdBy } = this.props;
13+
const marketHref = window === window.top ? `${window.location.origin}/plugins/detail/${id}` : `${config.studioOrigin}/plugins/detail/${id}`;
14+
const src = httpReg.test(userAvatar) ? userAvatar : `${config.qcloudOrigin}${userAvatar}`;
15+
return (
16+
< div className="plugin-card" >
17+
<div className="top">
18+
<a className="name" href={marketHref} target="_blank" rel="noopener noreferrer">{pluginName}</a>
19+
<div className="right">
20+
<img src={src} />
21+
<span>{createdBy}</span>
22+
</div>
23+
</div>
24+
<div className="desc">
25+
<span>{remark}</span>
26+
</div>
27+
<div className="control">
28+
<button className="button" onClick={() => this.handleUninstall(id)}>{i18n('global.uninstall')}</button>
29+
</div>
30+
</div >
31+
);
32+
}
33+
34+
handleUninstall = (pluginId) => {
35+
const { refresh } = this.props;
36+
// status 为 2 表示禁用
37+
api.uninstallPlugin({ pluginId, status: 2 }).then(res => {
38+
if (res.code === 0) {
39+
refresh();
40+
} else {
41+
notify({ notifyType: NOTIFY_TYPE.ERROR, message: res.msg });
42+
}
43+
}).catch(err => {
44+
notify({ notifyType: NOTIFY_TYPE.ERROR, message: err });
45+
});
46+
}
47+
}
48+
49+
export default TCard;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import TCard from './Tcard';
2+
3+
export default TCard;

0 commit comments

Comments
 (0)