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(design): Add Modal.Progress component #97

Merged
merged 4 commits into from
Aug 29, 2023
Merged

Conversation

dengfuping
Copy link
Collaborator

@dengfuping dengfuping commented Aug 17, 2023

Summary

  • 长任务反馈模态框,用于异步任务或耗时较长的场景。

Motivation

用户提交任务后,系统需要一段时间执行某类任务后,才会反馈任务结果,如集群创建的预检查场景。

Design Guide

任务耗时建议不超过1分钟,若任务耗时较长建议采用页面内置步骤或异步任务方式并使用全局同时告知用户任务提交成功和预计耗时等。使用注意点:

  1. 底部辅助信息说明区为可选。
  2. 执行中:无法获取进度则展示循环 loading,可获取进度则展示百分比。
  3. 成功态:3s 自动消失,同时可配置自动跳转指定 URL
  4. 失败态:点击取消关闭弹窗

image

Detailed Design

  • 新增 Modal.Progress 组件,用于异步任务或耗时较长的场景。
  • Modal.Progress 使用 Modal 组件实现,而不是 Modal.method()。因为静态方法无法消费 React 状态,导致状态无法更新到对话框内部。
  • 除支持 Modal 属性之外,Modal.Progress 还扩展出以下三项配置,具体用法见下面的 API 说明:
    • loading
    • progress
    • description
  • 实现上和设计差异的点:
    • 成功态的弹窗不会 3s 自动消失,包括跳转到指定 URL,需要业务侧自行处理相关逻辑。
    • 右上角透出关闭 icon,执行过程中也可能有手动管理的诉求。

API

参数 说明 类型 默认值 版本
width 对话框宽度 string | number 480 -
maskClosable 点击蒙层是否允许关闭 boolean false -
title 标题 ReactNode - -
loading 是否加载中 boolean false -
progress 进度条属性 ProgressProps { type: 'circle', size: 150 } -
description 描述 ReactNode - -
footer 底部内容 ReactNode null -

Basic Example

  • Modal.Progress with progress.percent:
<Modal.Progress
  title="Cluster is creating..."
  open={open}
  progress={{
    percent: 60
  }}
  description="Please waiting for a few seconds."
/>
  • Modal.Progress with progress.status:
<Modal.Progress
  title="Fail to create cluster"
  open={open}
  progress={{
    status: 'exeception'
  }}
  description="Please try again later."
/>
  • Modal.Progress with loading:
<Modal.Progress
  title="Cluster is creating..."
  open={open}
  loading={loading}
  description="Please waiting for a few seconds."
/>

Advanced Usage

Modal.Progress from percent to success Modal.Progress from percent to fail Modal.Progress from loading to success
2023-08-21 16-49-50 2023-08-21 16_51_18 2023-08-21 16-51-57 2023-08-21 16_53_19 2023-08-21 16-53-50 2023-08-21 16_54_47

Tests

  • Unit tests
  • Snapshot tests

@github-actions
Copy link

github-actions bot commented Aug 17, 2023

@dengfuping dengfuping changed the title feat(design): Add Modal.Progress component [WIP] feat(design): Add Modal.Progress component Aug 17, 2023
@dengfuping dengfuping mentioned this pull request Aug 8, 2023
97 tasks
@dengfuping dengfuping changed the title [WIP] feat(design): Add Modal.Progress component [WIP] 🔥 feat(design): Add Modal.Progress component Aug 17, 2023
@dengfuping dengfuping changed the title [WIP] 🔥 feat(design): Add Modal.Progress component 🔥 feat(design): Add Modal.Progress component Aug 18, 2023
@dengfuping dengfuping merged commit d43d0ed into master Aug 29, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant