Skip to content

Commit cc803ca

Browse files
hujiahao-hjhZero-Rock
authored andcommitted
fix(dop): project release management bug (erda-project#2441)
1 parent e5fee1b commit cc803ca

File tree

5 files changed

+53
-7
lines changed

5 files changed

+53
-7
lines changed

shell/app/modules/project/pages/release/components/application-detail.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,17 @@ const ReleaseApplicationDetail = () => {
3939
userId,
4040
createdAt,
4141
labels = {} as RELEASE.Labels,
42-
markdown,
42+
changelog,
4343
images = [],
4444
isFormal,
4545
} = releaseDetail;
4646

4747
const getDetail = React.useCallback(async () => {
4848
if (releaseID) {
49-
const detail = await getReleaseDetail({ releaseID });
50-
setReleaseDetail(detail);
49+
const res = await getReleaseDetail({ releaseID });
50+
if (res.success) {
51+
setReleaseDetail(res.data);
52+
}
5153
}
5254
}, [releaseID, setReleaseDetail]);
5355

@@ -103,7 +105,7 @@ const ReleaseApplicationDetail = () => {
103105
<div className="mb-2">
104106
<div className="text-black-400 mb-2">{i18n.t('content')}</div>
105107
<div>
106-
<ReactMarkdown remarkPlugins={[remarkGfm]}>{markdown || i18n.t('dop:no content yet')}</ReactMarkdown>
108+
<ReactMarkdown remarkPlugins={[remarkGfm]}>{changelog || i18n.t('dop:no content yet')}</ReactMarkdown>
107109
</div>
108110
</div>
109111
</div>

shell/app/modules/project/pages/release/components/form.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { getReleaseList, getReleaseDetail, addRelease, updateRelease } from 'pro
3030

3131
import './form.scss';
3232

33-
const ReleaseForm = ({ readyOnly = false }: { readyOnly: boolean }) => {
33+
const ReleaseForm = ({ readyOnly = false }: { readyOnly?: boolean }) => {
3434
const formRef = React.useRef<FormInstance>();
3535
const { params } = routeInfoStore.getState((s) => s);
3636
const { projectId, releaseID } = params;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2021 Terminus, Inc.
2+
//
3+
// This program is free software: you can use, redistribute, and/or modify
4+
// it under the terms of the GNU Affero General Public License, version 3
5+
// or later ("AGPL"), as published by the Free Software Foundation.
6+
//
7+
// This program is distributed in the hope that it will be useful, but WITHOUT
8+
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9+
// FITNESS FOR A PARTICULAR PURPOSE.
10+
//
11+
// You should have received a copy of the GNU Affero General Public License
12+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
13+
14+
import React from 'react';
15+
import routeInfoStore from 'core/stores/route';
16+
import { getReleaseDetail } from 'project/services/release';
17+
import ReleaseForm from './form';
18+
import ReleaseApplicationDetail from './application-detail';
19+
20+
const ReleaseUpdate = () => {
21+
const { params } = routeInfoStore.getState((s) => s);
22+
const { releaseID } = params;
23+
const [releaseDetail, setReleaseDetail] = React.useState<RELEASE.ReleaseDetail>({} as RELEASE.ReleaseDetail);
24+
const { isProjectRelease } = releaseDetail;
25+
26+
const getDetail = React.useCallback(async () => {
27+
if (releaseID) {
28+
const res = await getReleaseDetail({ releaseID });
29+
if (res.success) {
30+
const { data } = res;
31+
setReleaseDetail(data);
32+
}
33+
}
34+
}, [releaseID, setReleaseDetail]);
35+
36+
React.useEffect(() => {
37+
getDetail();
38+
}, [getDetail]);
39+
40+
return <div>{isProjectRelease ? <ReleaseForm /> : <ReleaseApplicationDetail isEdit={true} />}</div>;
41+
};
42+
43+
export default ReleaseUpdate;

shell/app/modules/project/router.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ function getProjectRouter(): RouteConfigItem[] {
418418
{
419419
path: 'updateRelease/:releaseID',
420420
pageName: i18n.t('edit {name}', { name: i18n.t('Artifact') }),
421-
getComp: (cb) => cb(import('project/pages/release/components/form')),
421+
getComp: (cb) => cb(import('project/pages/release/components/update')),
422422
},
423423
],
424424
},

shell/app/modules/project/types/release.d.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ declare namespace RELEASE {
2727
createdAt: string;
2828
labels: Labels;
2929
isFormal: boolean;
30-
markdown: string;
30+
changelog: string;
3131
images: string[];
3232
diceyml: string;
33+
isProjectRelease?: boolean;
3334
}
3435

3536
interface ApplicationDetail {

0 commit comments

Comments
 (0)