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

feat(dop): project release create form releases list add latest filter #2843

Merged
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
8 changes: 6 additions & 2 deletions shell/app/common/components/list-select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface IProps<T extends object = any> {
renderItem?: (item: T) => React.ReactNode;
list: T[];
menus: Array<{ title: string }>;
rightSlot?: React.ReactNode;
}

function ListSelect<T extends object = any>(props: IProps<T>) {
Expand Down Expand Up @@ -176,6 +177,7 @@ interface ListSelectOverlayProps<T> {
parentKey: string;
value?: T[];
onChange?: (values: T[]) => void;
rightSlot?: React.ReactNode;
}

const defaultRenderItem = (item: { title: string }) => {
Expand Down Expand Up @@ -204,6 +206,7 @@ function ListSelectOverlay<T extends object = any>({
rowKey,
menuRowKey,
parentKey,
rightSlot,
}: ListSelectOverlayProps<T>) {
const defaultSelectMenu = React.useMemo(
() => ({ [menuRowKey]: 0, title: i18n.t('dop:all {name}', { name: i18n.t('App') }) }),
Expand All @@ -215,7 +218,7 @@ function ListSelectOverlay<T extends object = any>({

useUpdateEffect(() => {
onMenuChange && onMenuChange(selectedMenu);
}, [selectedMenu, menus, onMenuChange, menuRowKey]);
}, [selectedMenu, menus, menuRowKey]);

return (
<Row className="erda-list-select-overlay text-white rounded">
Expand Down Expand Up @@ -261,7 +264,7 @@ function ListSelectOverlay<T extends object = any>({
</div>
</Col>
<Col span={12} className="px-2 h-full bg-white-08">
<div className="py-3 px-2 flex items-center justify-between">
<div className="py-3 px-2 flex items-center">
<Dropdown
trigger={['click']}
getPopupContainer={(triggerNode) => triggerNode.parentElement as HTMLElement}
Expand Down Expand Up @@ -317,6 +320,7 @@ function ListSelectOverlay<T extends object = any>({
{selectedMenu.title} <ErdaIcon size={16} type="caret-down" className="ml-1 text-white-3" />
</div>
</Dropdown>
<div className="pl-4">{rightSlot}</div>
</div>
<div className="erda-list-select-right-content flex">
<div className="flex-1 pl-2 min-w-0">
Expand Down
1 change: 1 addition & 0 deletions shell/app/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@
"addon info": "addon info",
"addon setting": "addon setting",
"address": "address",
"aggregate by branch": "aggregate by branch",
"all": "all",
"all issues": "all issues",
"all iterations": "all iterations",
Expand Down
1 change: 1 addition & 0 deletions shell/app/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@
"addon info": "服务信息",
"addon setting": "服务设置",
"address": "地址",
"aggregate by branch": "按分支聚合",
"all": "全部",
"all issues": "全部事项",
"all iterations": "所有迭代",
Expand Down
12 changes: 10 additions & 2 deletions shell/app/modules/project/pages/release/components/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React from 'react';
import { Button, Upload, Spin, Progress } from 'antd';
import { Button, Upload, Spin, Progress, Checkbox } from 'antd';
import moment from 'moment';
import { RenderForm, ListSelect, MarkdownEditor, ErdaIcon } from 'common';
import i18n from 'i18n';
Expand All @@ -21,6 +21,7 @@ import { goTo, insertWhen } from 'common/utils';
import { getUploadProps } from 'common/utils/upload-props';
import releaseStore from 'project/stores/release';
import routeInfoStore from 'core/stores/route';
import { CheckboxChangeEvent } from 'antd/lib/checkbox';
import orgStore from 'app/org-home/stores/org';
import userStore from 'user/stores';
import ReactMarkdown from 'react-markdown';
Expand Down Expand Up @@ -73,6 +74,7 @@ const ReleaseForm = ({ readyOnly = false }: { readyOnly?: boolean }) => {
const [pageNo, setPageNo] = React.useState(1);
const [appId, setAppId] = React.useState<number | undefined>();
const [query, setQuery] = React.useState<string>('');
const [isLatest, setIsLatest] = React.useState(false);
const [loading] = useLoading(releaseStore, ['getAppList']);

const [releaseList, setReleaseList] = React.useState<RELEASE.ReleaseDetail[]>([] as RELEASE.ReleaseDetail[]);
Expand Down Expand Up @@ -113,6 +115,7 @@ const ReleaseForm = ({ readyOnly = false }: { readyOnly?: boolean }) => {
pageSize: PAGINATION.pageSize,
isStable: true,
q: query,
latest: isLatest,
});
const { data } = res;
if (data) {
Expand All @@ -121,7 +124,7 @@ const ReleaseForm = ({ readyOnly = false }: { readyOnly?: boolean }) => {
setReleaseTotal(total);
}
},
[projectId, query],
[projectId, query, isLatest],
);

React.useEffect(() => {
Expand Down Expand Up @@ -256,6 +259,11 @@ const ReleaseForm = ({ readyOnly = false }: { readyOnly?: boolean }) => {
getReleases(_pageNo, appId);
},
},
rightSlot: (
<Checkbox checked={isLatest} onChange={(e: CheckboxChangeEvent) => setIsLatest(e.target.checked)}>
<span className="text-white">{i18n.t('dop:aggregate by branch')}</span>
</Checkbox>
),
},
readOnlyRender: (value: RELEASE.ReleaseDetail[]) => {
return (value || []).map((item: RELEASE.ReleaseDetail) => (
Expand Down
1 change: 1 addition & 0 deletions shell/app/modules/project/services/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface ReleaseListQuery {
pageSize: number;
pageNo: number;
q?: string;
latest?: boolean;
}

interface AddReleaseParams {
Expand Down