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

always show search input #906

Merged
merged 1 commit into from
Aug 11, 2021
Merged
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
149 changes: 75 additions & 74 deletions shell/app/modules/application/pages/repo/repo-branch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ const RepoBranch = () => {
clearListByType('branch');
};
}, [getListByType, clearListByType]);
if (!list.length) {
return <EmptyHolder relative style={{ justifyContent: 'start' }} />;
}
const goToCompare = (branch: string) => {
goTo(`./compare/${info.defaultBranch}...${encodeURIComponent(branch)}`);
};
Expand All @@ -77,90 +74,94 @@ const RepoBranch = () => {
<IF check={info.isLocked}>
<Alert message={i18n.t('lock-repository-tip')} type="error" />
</IF>
<div className="repo-branch-list">
{list.map((item) => {
const { name, id, commit, isProtect, isDefault, isMerged } = item;
const { commitMessage, author = {} } = commit || {};
const { name: committerName, when } = author as any;
const isProtectBranch = get(find(branchInfo, { name }), 'isProtect');
const curAuth = isProtectBranch ? permMap.writeProtected.pass : permMap.writeNormal.pass;
return (
<div key={name} className="branch-item flex justify-between items-center">
<div className="branch-item-left">
<div className="font-medium flex items-center text-base mb-3">
{isProtect ? (
<Tooltip title={i18n.t('protected branch')}>
<ErdaCustomIcon size="22" type="baohu" />
</Tooltip>
) : (
<ErdaCustomIcon opacity={0.8} fill="black" size="22" type="fz" />
)}
<Link to={mergeRepoPathWith(`/tree/${name}`)}>
<span className="text-normal hover-active">{name}</span>
</Link>
{isDefault && <span className="tag-primary">{i18n.t('default')}</span>}
{isMerged && <span className="tag-success">{i18n.t('application:Merged')}</span>}
</div>
<div className="flex items-center text-sub">
<IF check={list.length}>
<div className="repo-branch-list">
{list.map((item) => {
const { name, id, commit, isProtect, isDefault, isMerged } = item;
const { commitMessage, author = {} } = commit || {};
const { name: committerName, when } = author as any;
const isProtectBranch = get(find(branchInfo, { name }), 'isProtect');
const curAuth = isProtectBranch ? permMap.writeProtected.pass : permMap.writeNormal.pass;
return (
<div key={name} className="branch-item flex justify-between items-center">
<div className="branch-item-left">
<div className="font-medium flex items-center text-base mb-3">
{isProtect ? (
<Tooltip title={i18n.t('protected branch')}>
<ErdaCustomIcon size="22" type="baohu" />
</Tooltip>
) : (
<ErdaCustomIcon opacity={0.8} fill="black" size="22" type="fz" />
)}
<Link to={mergeRepoPathWith(`/tree/${name}`)}>
<span className="text-normal hover-active">{name}</span>
</Link>
{isDefault && <span className="tag-primary">{i18n.t('default')}</span>}
{isMerged && <span className="tag-success">{i18n.t('application:Merged')}</span>}
</div>
<div className="flex items-center text-sub">
<span className="inline-flex items-center">
<Avatar showName name={committerName} />
&nbsp;{i18n.t('committed at')}
</span>
<span className="ml-1">{fromNow(when)}</span>
<span className="ml-6 text-desc nowrap flex">
<span className="ml-1">{fromNow(when)}</span>
<span className="ml-6 text-desc nowrap flex">
<GotoCommit length={6} commitId={id} />
&nbsp;·&nbsp;
<Tooltip title={commitMessage.length > 50 ? commitMessage : null}>
&nbsp;·&nbsp;
<Tooltip title={commitMessage.length > 50 ? commitMessage : null}>
<Link className="text-desc hover-active" to={getCommitPath(id)}>
{replaceEmoji(commitMessage)}
</Link>
</Tooltip>
</span>
</div>
</div>
</div>
<div className="branch-item-right flex">
<Button className="mr-3" disabled={info.isLocked} onClick={() => goToCompare(name)}>
{i18n.t('application:compare')}
</Button>
<DeleteConfirm
onConfirm={() => {
deleteBranch({ branch: name });
}}
>
<WithAuth pass={curAuth}>
<Button disabled={info.isLocked || isDefault} className="mr-3" ghost type="danger">
{i18n.t('delete')}
</Button>
</WithAuth>
</DeleteConfirm>
<Dropdown
overlay={
<Menu
onClick={(e) => {
switch (e.key) {
case 'setDefault':
setDefaultBranch(name);
break;
default:
break;
}
}}
>
<Menu.Item key="setDefault" disabled={!curAuth || info.isLocked || isDefault}>
{i18n.t('application:set as default')}
</Menu.Item>
</Menu>
}
>
<Button>
<ErdaCustomIcon opacity={0.85} className="hover mt-1" fill="black" size="16" type="more" />
<div className="branch-item-right flex">
<Button className="mr-3" disabled={info.isLocked} onClick={() => goToCompare(name)}>
{i18n.t('application:compare')}
</Button>
</Dropdown>
<DeleteConfirm
onConfirm={() => {
deleteBranch({ branch: name });
}}
>
<WithAuth pass={curAuth}>
<Button disabled={info.isLocked || isDefault} className="mr-3" ghost type="danger">
{i18n.t('delete')}
</Button>
</WithAuth>
</DeleteConfirm>
<Dropdown
overlay={
<Menu
onClick={(e) => {
switch (e.key) {
case 'setDefault':
setDefaultBranch(name);
break;
default:
break;
}
}}
>
<Menu.Item key="setDefault" disabled={!curAuth || info.isLocked || isDefault}>
{i18n.t('application:set as default')}
</Menu.Item>
</Menu>
}
>
<Button>
<ErdaCustomIcon opacity={0.85} className="hover mt-1" fill="black" size="16" type="more" />
</Button>
</Dropdown>
</div>
</div>
</div>
);
})}
</div>
);
})}
</div>
<IF.ELSE />
<EmptyHolder relative style={{ justifyContent: 'start' }} />;
</IF>
</Spin>
);
};
Expand Down