Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feat: Add preview and edit package files #1117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,5 @@ export const DELETE_VERSION_STATUS = [
'rejected',
'suspended'
];

export const EDIT_VERSION_STATUS = ['draft', 'rejected'];
3 changes: 3 additions & 0 deletions src/locales/en/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,8 @@
"HELM_APP_NAME_TIP": "Beginning with a lowercase letter, up to 14 characters long (supports numbers/lowercase letters/hyphens)",
"MY_INSTANCES_DESCRIPTION": "A list of instances created based on the application.",

"VERSION_REVIEW_SUBMIT": "Your review has been submitted successfully.",
"VERSION_REVIEW_DESC": " The review includes application service review and platform review. Please pay attention to the review notice.",

"TIPS_DELETE_CATE": "After「{{cateName}}」is deleted, applications such as {{appNames}} will be automatically classified into 「uncategorized」"
}
8 changes: 7 additions & 1 deletion src/locales/zh/app-version.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,11 @@
"Used to describe in detail the specific content of this update": "用于详细描述此次更新的具体内容",
"Pricing information": "定价信息",
"App pricing is not supported for the time being": "暂时不支持应用定价",
"VERSION_NO_FORMAT_INFO": "输入格式错误,正确格式为小数点和数字组成"
"VERSION_NO_FORMAT_INFO": "输入格式错误,正确格式为小数点和数字组成",

"View version": "查看版本",
"VERSION_REVIEW_SUBMIT": "你的审核已提交成功",
"VERSION_REVIEW_DESC": "整个审核包括应用服务商审核和平台审核两个环节,请留意审核通知。",
"View version package": "查看版本包",
"Version Files": "版本文件"
}
21 changes: 13 additions & 8 deletions src/pages/Dashboard/Apps/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default class AppDetail extends Component {
};

renderVersionHandleMenu = item => {
const { match, t } = this.props;
const { user, match, t } = this.props;
const { appId } = match.params;

return (
Expand All @@ -164,22 +164,30 @@ export default class AppDetail extends Component {
>
<Icon name="stateful-set" type="dark" /> {t('Deploy Instance')}
</Link>
{item.status === 'active' && (
{item.status === 'active' && user.isAdmin && (
<span
onClick={() => this.openSuspendDialog(item.version_id, 'suspend-version')
}
>
<Icon name="sort-descending" type="dark" /> {t('Suspend version')}
</span>
)}
{item.status === 'suspended' && (
{item.status === 'suspended' && user.isAdmin && (
<span
onClick={() => this.openSuspendDialog(item.version_id, 'recover-version')
}
>
<Icon name="sort-ascending" type="dark" /> {t('Recover version')}
</span>
)}
<Link
to={toRoute(routes.portal.versionFiles, {
appId,
versionId: item.version_id
})}
>
<Icon name="eye" type="dark" /> {t('View version package')}
</Link>
</div>
);
};
Expand Down Expand Up @@ -273,10 +281,10 @@ export default class AppDetail extends Component {
}

renderVersions() {
const { appVersionStore, user, t } = this.props;
const { appVersionStore, t } = this.props;
const { versions, isLoading } = appVersionStore;

let columns = [
const columns = [
{
title: t('Version No'),
key: 'name',
Expand Down Expand Up @@ -317,9 +325,6 @@ export default class AppDetail extends Component {
)
}
];
if (!user.isAdmin) {
columns = columns.filter(item => item.key !== 'actions');
}

const pagination = {
tableType: 'application',
Expand Down
8 changes: 8 additions & 0 deletions src/pages/Dashboard/Reviews/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export default class ReviewDetail extends Component {

return (
<div className="operate-menu">
<Link
to={toRoute(routes.portal.versionFiles, {
appId: reviewDetail.app_id,
versionId: reviewDetail.version_id
})}
>
<Icon name="eye" type="dark" /> {t('View version package')}
</Link>
<Link
to={toRoute(routes.portal.deploy, {
appId: reviewDetail.app_id,
Expand Down
69 changes: 47 additions & 22 deletions src/pages/Dashboard/Versions/Detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { versionTypes } from 'config/version-types';
import AppDetail from 'pages/AppDetail';
import { formatTime, sleep, mappingStatus } from 'utils';
import routes, { toRoute } from 'routes';
import { DELETE_VERSION_STATUS } from 'config/version.js';
import { DELETE_VERSION_STATUS, EDIT_VERSION_STATUS } from 'config/version.js';
import Info from '../../Apps/Info';
import VersionEdit from '../VersionEdit';

Expand Down Expand Up @@ -55,6 +55,7 @@ const tags = [
rootStore,
appVersionStore: rootStore.appVersionStore,
appStore: rootStore.appStore,
appDeployStore: rootStore.appDeployStore,
clusterStore: rootStore.clusterStore,
appCreateStore: rootStore.appCreateStore,
categoryStore: rootStore.categoryStore,
Expand All @@ -70,6 +71,7 @@ export default class VersionDetail extends Component {
const {
appVersionStore,
appStore,
appDeployStore,
categoryStore,
userStore,
clusterStore,
Expand Down Expand Up @@ -108,6 +110,8 @@ export default class VersionDetail extends Component {
version_id: versionId,
noLimit: true
});

await appDeployStore.fetchFilesByVersion(versionId);
}

componentWillUnmount() {
Expand Down Expand Up @@ -233,6 +237,39 @@ export default class VersionDetail extends Component {
);
};

rederPkgHandleMenu = () => {
const {
appStore, appVersionStore, match, t
} = this.props;
const { appId, versionId } = match.params;
const { version, packageName, downloadPackage } = appVersionStore;
const { appDetail } = appStore;
const { status } = version;
const isEdit = EDIT_VERSION_STATUS.includes(status);
const pkgName = packageName || `${appDetail.name}-${version.name}`;

return (
<div className="operate-menu">
{isEdit && (
<span onClick={this.onUploadClick}>
<Icon name="pen" type="dark" /> {t('Modify')}
</span>
)}
<span onClick={() => downloadPackage(version.version_id, pkgName)}>
<Icon name="download" type="dark" /> {t('Download')}
</span>
<Link
to={toRoute(routes.portal.versionFiles, {
appId,
versionId
})}
>
<Icon name="eye" type="dark" /> {t('Package')}
</Link>
</div>
);
};

renderDeleteDialog = () => {
const { appStore, appVersionStore, t } = this.props;
const { isDialogOpen, hideModal, version } = appVersionStore;
Expand Down Expand Up @@ -502,15 +539,12 @@ export default class VersionDetail extends Component {
uploadError,
packageName,
checkPackageFile,
uploadPackage,
downloadPackage
uploadPackage
} = appVersionStore;

const { appDetail } = appStore;
const isShowUpload = isLoading || Boolean(createError);
const errorFiles = _.keys(uploadError);

const isEdit = version.status === 'draft' || version.status === 'rejected';
const pkgName = packageName || `${appDetail.name}-${version.name}`;

return (
Expand All @@ -521,20 +555,11 @@ export default class VersionDetail extends Component {
<div className={styles.time}>
{t('Upload time')}:&nbsp;
{formatTime(version.status_time, 'YYYY/MM/DD HH:mm:ss')}
<span
className={styles.link}
onClick={() => downloadPackage(version.version_id, pkgName)}
>
{t('Download')}
</span>
{isEdit && (
<span
className={styles.link}
onClick={() => this.onUploadClick()}
>
{t('Modify')}
</span>
)}
<PopoverIcon
showBorder
className={styles.operation}
content={this.rederPkgHandleMenu()}
/>
</div>
</div>
)}
Expand Down Expand Up @@ -631,13 +656,13 @@ export default class VersionDetail extends Component {
return (
<div className={styles.successMesage}>
<Icon className={styles.icon} name="checked-circle" size={48} />
<div className={styles.textHeader}>{t('你的应用已提交成功')}</div>
<div className={styles.textHeader}>{t('VERSION_REVIEW_SUBMIT')}</div>
<Button type="primary" onClick={changeSubmitCheck}>
{t('查看版本')}
{t('View version')}
</Button>
<div className={styles.note}>
<label>{t('Note')}</label>
{t('整个审核包括应用服务商审核和平台审核两个环节,请留意审核通知。')}
{t('VERSION_REVIEW_DESC')}
</div>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Dashboard/Versions/Detail/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@
box-shadow: 0 1px 0 0 $N10;
}
}

.operation {
margin-left: 12px;
}

:global {
.operate-menu {
text-align: left;
}
}
}

.updateLog {
Expand Down
Loading