重构前端逻辑
This commit is contained in:
parent
0ab4472a2f
commit
bb1faa1495
@ -23,7 +23,7 @@ const ValidationRuleEditor: React.FC<ValidationRuleEditorProps> = ({ value = [],
|
||||
};
|
||||
const newRules = [...value, newRule];
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('➕ [ValidationRuleEditor] 添加验证规则:', newRules);
|
||||
console.log('➕ [ValidationRuleEditor] 添加验证规则:', newRules);
|
||||
}
|
||||
onChange?.(newRules);
|
||||
};
|
||||
@ -31,7 +31,7 @@ const ValidationRuleEditor: React.FC<ValidationRuleEditorProps> = ({ value = [],
|
||||
const handleDeleteRule = (index: number) => {
|
||||
const newRules = value.filter((_, i) => i !== index);
|
||||
if (import.meta.env.DEV) {
|
||||
console.log('🗑️ [ValidationRuleEditor] 删除验证规则:', newRules);
|
||||
console.log('🗑️ [ValidationRuleEditor] 删除验证规则:', newRules);
|
||||
}
|
||||
onChange?.(newRules);
|
||||
};
|
||||
@ -40,7 +40,7 @@ const ValidationRuleEditor: React.FC<ValidationRuleEditorProps> = ({ value = [],
|
||||
const newRules = [...value];
|
||||
newRules[index] = { ...newRules[index], [field]: fieldValue };
|
||||
if (import.meta.env.DEV) {
|
||||
console.log(`✏️ [ValidationRuleEditor] 修改验证规则 [${field}]:`, newRules);
|
||||
console.log(`✏️ [ValidationRuleEditor] 修改验证规则 [${field}]:`, newRules);
|
||||
}
|
||||
onChange?.(newRules);
|
||||
};
|
||||
|
||||
@ -4,7 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const badgeVariants = cva(
|
||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
||||
"inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
|
||||
@ -47,7 +47,7 @@ const DialogOverlay = React.forwardRef<
|
||||
<DialogPrimitive.Overlay
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
"fixed inset-0 z-50 bg-black/80 outline-none focus:outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@ -64,13 +64,13 @@ const DialogContent = React.forwardRef<
|
||||
<DialogPrimitive.Content
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-lg max-h-[90vh] translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
"fixed left-[50%] top-[50%] z-50 flex flex-col w-full max-w-lg max-h-[90vh] translate-x-[-50%] translate-y-[-50%] border bg-background shadow-lg duration-200 outline-none focus:outline-none focus-visible:outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</DialogPrimitive.Close>
|
||||
|
||||
@ -66,7 +66,7 @@ const SheetContent = React.forwardRef<
|
||||
>
|
||||
{children}
|
||||
{showClose && (
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">Close</span>
|
||||
</SheetPrimitive.Close>
|
||||
|
||||
@ -61,7 +61,7 @@ const ToastAction = React.forwardRef<
|
||||
<ToastPrimitives.Action
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
||||
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-destructive/30 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus-visible:ring-destructive",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
@ -76,7 +76,7 @@ const ToastClose = React.forwardRef<
|
||||
<ToastPrimitives.Close
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
||||
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 focus:outline-none focus-visible:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus-visible:ring-red-400 group-[.destructive]:focus-visible:ring-offset-red-600",
|
||||
className
|
||||
)}
|
||||
toast-close=""
|
||||
|
||||
@ -89,4 +89,12 @@
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
|
||||
/* 🔥 完全移除所有可能的焦点边框效果 */
|
||||
[role="menu"],
|
||||
[role="menuitem"],
|
||||
[data-radix-dropdown-menu-content] {
|
||||
outline: none !important;
|
||||
box-shadow: none !important;
|
||||
}
|
||||
}
|
||||
@ -333,27 +333,40 @@ export const ApplicationCard: React.FC<ApplicationCardProps> = ({
|
||||
</div>
|
||||
|
||||
{/* 部署按钮 */}
|
||||
<Button
|
||||
onClick={() => setDeployDialogOpen(true)}
|
||||
disabled={!environment.enabled || isDeploying || app.isDeploying}
|
||||
size="sm"
|
||||
className={cn(
|
||||
'w-full text-xs h-8',
|
||||
environment.requiresApproval && 'bg-amber-600 hover:bg-amber-700'
|
||||
)}
|
||||
>
|
||||
{(isDeploying || app.isDeploying) ? (
|
||||
<>
|
||||
<Loader2 className="h-3 w-3 mr-1 animate-spin" />
|
||||
部署中
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Rocket className="h-3 w-3 mr-1" />
|
||||
{environment.requiresApproval ? '申请部署' : '立即部署'}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<div className="w-full">
|
||||
<Button
|
||||
onClick={() => setDeployDialogOpen(true)}
|
||||
disabled={!environment.enabled || !environment.canDeploy || isDeploying || app.isDeploying}
|
||||
size="sm"
|
||||
className={cn(
|
||||
'w-full text-xs h-8',
|
||||
environment.requiresApproval && 'bg-amber-600 hover:bg-amber-700'
|
||||
)}
|
||||
>
|
||||
{(isDeploying || app.isDeploying) ? (
|
||||
<>
|
||||
<Loader2 className="h-3 w-3 mr-1 animate-spin" />
|
||||
部署中
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Rocket className="h-3 w-3 mr-1" />
|
||||
{environment.requiresApproval ? '申请部署' : '立即部署'}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
{!environment.canDeploy && (
|
||||
<TooltipContent>
|
||||
<p>您没有部署权限</p>
|
||||
</TooltipContent>
|
||||
)}
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
||||
{/* 部署表单对话框 */}
|
||||
<DeploymentFormModal
|
||||
|
||||
@ -63,7 +63,7 @@ const DeploymentFormModal: React.FC<DeploymentFormModalProps> = ({
|
||||
// 审批信息
|
||||
approval: {
|
||||
required: environment.requiresApproval ? 'true' : 'false',
|
||||
userIds: environment.approvers?.map(a => a.userId.toString()).join(',') || '',
|
||||
userNames: environment.approvers?.map(a => a.username) || [],
|
||||
},
|
||||
// 通知信息(使用环境配置的通知设置)
|
||||
notification: {
|
||||
|
||||
@ -78,19 +78,20 @@ const Dashboard: React.FC = () => {
|
||||
|
||||
const response = await getDeployEnvironments();
|
||||
|
||||
if (response && response.teams) {
|
||||
// ✅ 新接口直接返回 teams 数组
|
||||
if (response && response.length > 0) {
|
||||
const prevTeamId = currentTeamId;
|
||||
const prevEnvId = currentEnvId;
|
||||
|
||||
setTeams(response.teams);
|
||||
setTeams(response);
|
||||
|
||||
if (isInitialLoad) {
|
||||
// 首次加载:默认选中第一个团队和第一个环境
|
||||
if (response.teams.length > 0) {
|
||||
setCurrentTeamId(response.teams[0].teamId);
|
||||
if (response.length > 0) {
|
||||
setCurrentTeamId(response[0].teamId);
|
||||
|
||||
if (response.teams[0].environments.length > 0) {
|
||||
setCurrentEnvId(response.teams[0].environments[0].environmentId);
|
||||
if (response[0].environments.length > 0) {
|
||||
setCurrentEnvId(response[0].environments[0].environmentId);
|
||||
}
|
||||
}
|
||||
setIsInitialLoad(false);
|
||||
@ -98,12 +99,12 @@ const Dashboard: React.FC = () => {
|
||||
// 后续刷新:保持当前选中的团队和环境
|
||||
// 如果之前选中的团队/环境仍然存在,保持选中
|
||||
if (prevTeamId !== null) {
|
||||
const teamExists = response.teams.some(t => t.teamId === prevTeamId);
|
||||
const teamExists = response.some(t => t.teamId === prevTeamId);
|
||||
if (teamExists) {
|
||||
setCurrentTeamId(prevTeamId);
|
||||
|
||||
if (prevEnvId !== null) {
|
||||
const team = response.teams.find(t => t.teamId === prevTeamId);
|
||||
const team = response.find(t => t.teamId === prevTeamId);
|
||||
const envExists = team?.environments.some(e => e.environmentId === prevEnvId);
|
||||
if (envExists) {
|
||||
setCurrentEnvId(prevEnvId);
|
||||
@ -112,11 +113,11 @@ const Dashboard: React.FC = () => {
|
||||
setCurrentEnvId(team.environments[0].environmentId);
|
||||
}
|
||||
}
|
||||
} else if (response.teams.length > 0) {
|
||||
} else if (response.length > 0) {
|
||||
// 如果之前的团队不存在了,选择第一个团队
|
||||
setCurrentTeamId(response.teams[0].teamId);
|
||||
if (response.teams[0].environments.length > 0) {
|
||||
setCurrentEnvId(response.teams[0].environments[0].environmentId);
|
||||
setCurrentTeamId(response[0].teamId);
|
||||
if (response[0].environments.length > 0) {
|
||||
setCurrentEnvId(response[0].environments[0].environmentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,7 +128,7 @@ const Dashboard: React.FC = () => {
|
||||
let hasChanges = false;
|
||||
|
||||
// 遍历所有团队、环境、应用,检查部署状态
|
||||
response.teams.forEach(team => {
|
||||
response.forEach(team => {
|
||||
team.environments.forEach(env => {
|
||||
env.applications.forEach(app => {
|
||||
// 如果应用在 deploying 状态中,但最新状态不是 RUNNING,则移除
|
||||
|
||||
@ -45,10 +45,12 @@ export interface ApplicationConfig {
|
||||
applicationName: string;
|
||||
applicationDesc?: string;
|
||||
branch: string;
|
||||
deployBranch?: string; // 🆕 部署分支
|
||||
deploySystemId?: number;
|
||||
deploySystemName?: string;
|
||||
deployJob?: string;
|
||||
workflowDefinitionId?: number;
|
||||
workflowDefinitionFormId?: number; // 🆕 工作流表单ID
|
||||
workflowDefinitionName?: string;
|
||||
workflowDefinitionKey?: string;
|
||||
deployStatistics?: DeployStatistics;
|
||||
@ -68,24 +70,31 @@ export interface DeployEnvironment {
|
||||
notificationEnabled: boolean; // 🆕 是否启用通知
|
||||
notificationChannelId: number; // 🆕 通知渠道ID
|
||||
requireCodeReview: boolean; // 🆕 是否需要代码审查
|
||||
canDeploy: boolean; // 🆕 当前用户是否可以发起部署
|
||||
canApprove: boolean; // 🆕 当前用户是否可以审批部署
|
||||
applications: ApplicationConfig[];
|
||||
}
|
||||
|
||||
export interface TeamMember {
|
||||
userId: number;
|
||||
username: string;
|
||||
realName: string;
|
||||
roleInTeam: string;
|
||||
}
|
||||
|
||||
export interface DeployTeam {
|
||||
teamId: number;
|
||||
teamCode: string;
|
||||
teamName: string;
|
||||
teamRole: string | null; // ✅ 可能为 null
|
||||
description?: string;
|
||||
ownerId: number; // 🆕 团队负责人ID
|
||||
ownerName: string; // 🆕 团队负责人名称
|
||||
members: TeamMember[]; // 🆕 团队成员列表
|
||||
environments: DeployEnvironment[];
|
||||
}
|
||||
|
||||
export interface DeployEnvironmentsResponse {
|
||||
userId: number;
|
||||
username: string;
|
||||
realName: string;
|
||||
teams: DeployTeam[];
|
||||
}
|
||||
// ✅ 新接口直接返回 teams 数组
|
||||
export type DeployEnvironmentsResponse = DeployTeam[];
|
||||
|
||||
export interface StartDeploymentRequest {
|
||||
teamApplicationId: number;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user