Skip to content

Commit

Permalink
feat(dop): project release create form releases list add latest filter
Browse files Browse the repository at this point in the history
  • Loading branch information
hujiahao-hjh committed Jan 26, 2022
1 parent e27d2e9 commit ade9d2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion 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 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
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 'core/common/interface';
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">按分支聚合</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

0 comments on commit ade9d2a

Please sign in to comment.