PreCheckStatus.tsx 26.4 KB
Newer Older
R
Rongfeng Fu 已提交
1
import { intl } from '@/utils/intl';
R
Rongfeng Fu 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
import { useEffect, useState } from 'react';
import { useModel } from 'umi';
import {
  Space,
  Button,
  Progress,
  Timeline,
  Checkbox,
  Typography,
  Tooltip,
  Tag,
  Spin,
  message,
  Empty,
} from 'antd';
import { ProCard } from '@ant-design/pro-components';
import {
  CloseOutlined,
  QuestionCircleFilled,
  ReadFilled,
  CheckCircleFilled,
  CloseCircleFilled,
} from '@ant-design/icons';
import useRequest from '@/utils/useRequest';
import {
  preCheck,
  preCheckStatus,
R
Rongfeng Fu 已提交
29
  deployAndStartADeployment,
R
Rongfeng Fu 已提交
30 31 32
  createDeploymentConfig,
  recover,
} from '@/services/ob-deploy-web/Deployments';
R
Rongfeng Fu 已提交
33
import { handleQuit, getErrorInfo } from '@/utils';
R
Rongfeng Fu 已提交
34
import NP from 'number-precision';
R
Rongfeng Fu 已提交
35 36 37 38 39 40
import { getLocale } from 'umi';
import EnStyles from './indexEn.less';
import ZhStyles from './indexZh.less';

const locale = getLocale();
const styles = locale === 'zh-CN' ? ZhStyles : EnStyles;
R
Rongfeng Fu 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65

const { Text } = Typography;

const statusColorConfig = {
  PASSED: 'green',
  PENDING: 'gray',
  FAILED: 'red',
};

let timerScroll: NodeJS.Timer;
let timerFailed: NodeJS.Timer;
const initDuration = 3;
let durationScroll = initDuration;
let durationFailed = initDuration;

const errCodeUrl = 'https://www.oceanbase.com/product/ob-deployer/error-codes';

export default function PreCheckStatus() {
  const {
    setCurrentStep,
    configData,
    setCheckOK,
    handleQuitProgress,
    getInfoByName,
    setConfigData,
R
Rongfeng Fu 已提交
66 67 68
    setErrorVisible,
    setErrorsList,
    errorsList,
R
Rongfeng Fu 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  } = useModel('global');
  const oceanbase = configData?.components?.oceanbase;
  const name = configData?.components?.oceanbase?.appname;
  const [statusData, setStatusData] = useState<API.PreCheckResult>({});
  const [failedList, setFailedList] = useState<API.PreCheckInfo[]>([]);
  const [showFailedList, setShowFailedList] = useState<API.PreCheckInfo[]>([]);
  const [hasAuto, setHasAuto] = useState(false);
  const [hasManual, setHasManual] = useState(false);
  const [onlyManual, setOnlyManual] = useState(false);
  const [checkFinished, setCheckFinished] = useState(false);
  const [isScroll, setIsScroll] = useState(false);
  const [isScrollFailed, setIsScrollFailed] = useState(false);
  const [loading, setLoading] = useState(false);
  const [checkStatus, setCheckStatus] = useState(true);
  const [currentPage, setCurrentPage] = useState(true);
  const [firstErrorTimestamp, setFirstErrorTimestamp] = useState<number>();

  const { run: fetchPreCheckStatus } = useRequest(preCheckStatus, {
    onSuccess: ({ success, data }: API.OBResponsePreCheckResult_) => {
      if (success) {
        let timer: NodeJS.Timer;
        setStatusData(data || {});
        if (data?.status === 'RUNNING') {
          timer = setTimeout(() => {
            fetchPreCheckStatus({ name });
          }, 1000);
        }
        if (data?.status === 'FAILED') {
R
Rongfeng Fu 已提交
97 98 99 100 101 102 103 104 105
          let errorInfo: API.ErrorInfo = {
            title: intl.formatMessage({
              id: 'OBD.pages.components.PreCheckStatus.RequestError',
              defaultMessage: '请求错误',
            }),
            desc: data?.message,
          };
          setErrorVisible(true);
          setErrorsList([...errorsList, errorInfo]);
R
Rongfeng Fu 已提交
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
          setCheckStatus(false);
        } else {
          if (data?.all_passed) {
            setFailedList([]);
            setShowFailedList([]);
          } else {
            const newFailedList =
              data?.info?.filter((item) => item.result === 'FAILED') || [];
            newFailedList.forEach((item) => {
              if (item.recoverable) {
                setHasAuto(true);
              } else {
                setHasManual(true);
              }
            });
            setFailedList(newFailedList);
            setShowFailedList(newFailedList);
          }
          const isFinished = !!data?.total && data?.finished === data?.total;
          setCheckFinished(isFinished);
          if (isFinished) {
            clearTimeout(timer);
          }
          if (!isScroll && !isFinished) {
            setTimeout(() => {
              const timelineContainer =
                document.getElementById('timeline-container');
              const runningItemDom = document.getElementById(
                'running-timeline-item',
              );
R
Rongfeng Fu 已提交
136

R
Rongfeng Fu 已提交
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
              timelineContainer.scrollTop = NP.minus(
                NP.strip(runningItemDom?.offsetTop),
                150,
              );
            }, 10);
          }

          if (!isScrollFailed && !isFinished && failedList) {
            setTimeout(() => {
              const failedContainer =
                document.getElementById('failed-container');
              if (failedContainer) {
                failedContainer.scrollTop = NP.strip(
                  failedContainer?.scrollHeight,
                );
              }
            }, 10);
          }
          setCheckStatus(true);
        }
        if (loading) {
          setLoading(false);
        }
      }
    },
    onError: ({ response, data, type }: any) => {
      const handleError = () => {
R
Rongfeng Fu 已提交
164 165 166
        const errorInfo = getErrorInfo({ response, data, type });
        setErrorVisible(true);
        setErrorsList([...errorsList, errorInfo]);
R
Rongfeng Fu 已提交
167 168
      };
      if (response?.status === 504 || (!response && type === 'TypeError')) {
R
Rongfeng Fu 已提交
169
        const nowTime = Date.now();
R
Rongfeng Fu 已提交
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
        if (!firstErrorTimestamp) {
          setFirstErrorTimestamp(nowTime);
        }
        if (NP.divide(nowTime - firstErrorTimestamp) > 60000) {
          handleError();
          setCheckStatus(false);
          if (loading) {
            setLoading(false);
          }
        } else {
          if (currentPage) {
            setTimeout(() => {
              fetchPreCheckStatus({ name });
            }, 1000);
          }
        }
      } else {
        handleError();
      }
    },
  });

  const { run: handlePreCheck, loading: preCheckLoading } = useRequest(
    preCheck,
    {
      onSuccess: ({ success }: API.OBResponse) => {
        if (success) {
          handleStartCheck();
        }
      },
R
Rongfeng Fu 已提交
200
      onError: (e: any) => {
R
Rongfeng Fu 已提交
201 202 203 204
        setCheckStatus(false);
        if (loading) {
          setLoading(false);
        }
R
Rongfeng Fu 已提交
205 206 207
        const errorInfo = getErrorInfo(e);
        setErrorVisible(true);
        setErrorsList([...errorsList, errorInfo]);
R
Rongfeng Fu 已提交
208 209 210 211
      },
    },
  );

R
Rongfeng Fu 已提交
212 213 214 215 216 217 218
  const { run: handleInstallConfirm } = useRequest(deployAndStartADeployment, {
    onError: (e: any) => {
      const errorInfo = getErrorInfo(e);
      setErrorVisible(true);
      setErrorsList([...errorsList, errorInfo]);
    },
  });
R
Rongfeng Fu 已提交
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237

  const handelCheck = async () => {
    setLoading(true);
    try {
      await handlePreCheck({ name });
    } catch {
      setLoading(false);
    }
  };

  const { run: handleCreateConfig, loading: createLoading } = useRequest(
    createDeploymentConfig,
    {
      onSuccess: ({ success }: API.OBResponse) => {
        if (success) {
          handelCheck();
        }
        setLoading(false);
      },
R
Rongfeng Fu 已提交
238
      onError: (e: any) => {
R
Rongfeng Fu 已提交
239 240 241 242
        setCheckStatus(false);
        if (loading) {
          setLoading(false);
        }
R
Rongfeng Fu 已提交
243 244 245
        const errorInfo = getErrorInfo(e);
        setErrorVisible(true);
        setErrorsList([...errorsList, errorInfo]);
R
Rongfeng Fu 已提交
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
      },
    },
  );

  const handleRetryCheck = (newConfigData?: any) => {
    setStatusData({});
    setFailedList([]);
    setShowFailedList([]);
    setCheckFinished(false);
    let params = { ...configData };
    if (newConfigData) {
      params = { ...newConfigData };
    }
    setLoading(true);
    handleCreateConfig({ name: oceanbase?.appname }, { ...params });
  };

  const { run: handleRecover, loading: recoverLoading } = useRequest(recover, {
    onSuccess: async ({
      success,
    }: API.OBResponseDataListRecoverChangeParameter_) => {
      if (success) {
R
Rongfeng Fu 已提交
268 269 270 271 272 273
        message.success(
          intl.formatMessage({
            id: 'OBD.pages.components.PreCheckStatus.AutomaticRepairSucceeded',
            defaultMessage: '自动修复成功',
          }),
        );
R
Rongfeng Fu 已提交
274 275 276 277 278 279 280 281 282
        try {
          const { success: nameSuccess, data: nameData } = await getInfoByName({
            name,
          });
          if (nameSuccess) {
            const { config } = nameData;
            setConfigData(config || {});
            handleRetryCheck(config);
          } else {
R
Rongfeng Fu 已提交
283 284 285 286 287 288
            message.error(
              intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.FailedToObtainConfigurationInformation',
                defaultMessage: '获取配置信息失败',
              }),
            );
R
Rongfeng Fu 已提交
289 290
          }
        } catch (e: any) {
R
Rongfeng Fu 已提交
291 292 293
          const errorInfo = getErrorInfo(e);
          setErrorVisible(true);
          setErrorsList([...errorsList, errorInfo]);
R
Rongfeng Fu 已提交
294 295 296
        }
      }
    },
R
Rongfeng Fu 已提交
297 298 299 300 301
    onError: (e: any) => {
      const errorInfo = getErrorInfo(e);
      setErrorVisible(true);
      setErrorsList([...errorsList, errorInfo]);
    },
R
Rongfeng Fu 已提交
302 303 304 305 306 307 308 309 310 311
  });

  const handleStartCheck = () => {
    fetchPreCheckStatus({ name });
  };

  const prevStep = () => {
    setCheckOK(false);
    setCurrentStep(3);
    setCurrentPage(false);
R
Rongfeng Fu 已提交
312 313 314
    setErrorVisible(false);
    setErrorsList([]);
    window.scrollTo(0, 0);
R
Rongfeng Fu 已提交
315 316 317 318 319 320 321
  };

  const handleInstall = async () => {
    const { success } = await handleInstallConfirm({ name });
    if (success) {
      setCurrentStep(5);
      setCurrentPage(false);
R
Rongfeng Fu 已提交
322 323
      setErrorVisible(false);
      setErrorsList([]);
R
Rongfeng Fu 已提交
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
    }
  };

  const handleScrollTimeline = () => {
    if (!checkFinished) {
      setIsScroll(true);
      clearInterval(timerScroll);
      durationScroll = initDuration;
      timerScroll = setInterval(() => {
        if (durationScroll === 0) {
          clearInterval(timerScroll);
          setIsScroll(false);
          durationScroll = initDuration;
        } else {
          durationScroll -= 1;
        }
      }, 1000);
    }
  };

  const handleScrollFailed = () => {
    if (!checkFinished) {
      setIsScrollFailed(true);
      clearInterval(timerFailed);
      durationFailed = initDuration;
      timerFailed = setInterval(() => {
        if (durationFailed === 0) {
          clearInterval(timerFailed);
          setIsScrollFailed(false);
          durationFailed = initDuration;
        } else {
          durationFailed -= 1;
        }
      }, 1000);
    }
  };

  const handleAutoRepair = () => {
    setHasAuto(false);
    handleRecover({ name });
  };

  useEffect(() => {
    if (onlyManual) {
      const newShowFailedList = failedList.filter((item) => !item.recoverable);
      setShowFailedList(newShowFailedList);
    } else {
      setShowFailedList(failedList);
    }
  }, [onlyManual]);

  useEffect(() => {
    handelCheck();
    const timelineContainer = document.getElementById('timeline-container');
    timelineContainer.onmousewheel = handleScrollTimeline; // ie , chrome
    timelineContainer?.addEventListener('DOMMouseScroll', handleScrollTimeline); // firefox
    return () => {
      timelineContainer.onmousewheel = () => {};
      timelineContainer?.removeEventListener(
        'DOMMouseScroll',
        handleScrollTimeline,
      );
    };
  }, []);

  useEffect(() => {
    const addEventFailedContainer = () => {
      const failedContainer = document.getElementById('failed-container');
      if (failedList?.length && failedContainer) {
        if (!failedContainer.onmousewheel) {
          failedContainer.onmousewheel = handleScrollFailed; // ie , chrome
          failedContainer?.addEventListener(
            'DOMMouseScroll',
            handleScrollFailed,
R
Rongfeng Fu 已提交
398 399
          );
          // firefox
R
Rongfeng Fu 已提交
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
        }
      } else {
        setTimeout(() => {
          addEventFailedContainer();
        }, 3000);
      }
    };

    addEventFailedContainer();
    return () => {
      const failedContainer = document.getElementById('failed-container');
      if (failedContainer) {
        failedContainer.onmousewheel = () => {};
        failedContainer?.removeEventListener(
          'DOMMouseScroll',
          handleScrollFailed,
        );
      }
    };
  }, [failedList]);

  let progressStatus = 'active';
  if (statusData?.status === 'FAILED') {
    progressStatus = 'exception';
  } else if (checkFinished) {
    if (statusData?.all_passed) {
      progressStatus = 'success';
    } else {
      progressStatus = 'exception';
    }
  }

  const shape = (
    <div className={styles.shapeContainer}>
      <div className={styles.shape}></div>
      <div className={styles.shape}></div>
      <div className={styles.shape}></div>
      <div className={styles.shape}></div>
    </div>
  );

R
Rongfeng Fu 已提交
441 442 443 444 445
  const checkItemLength = `${statusData?.finished || 0}/${
    statusData?.total || 0
  }`;
  const failedItemLength = failedList?.length;

R
Rongfeng Fu 已提交
446 447 448 449
  return (
    <Space className={styles.spaceWidth} direction="vertical" size="middle">
      <ProCard
        title={
R
Rongfeng Fu 已提交
450 451 452 453 454 455 456 457 458 459 460 461 462 463
          checkStatus
            ? checkFinished
              ? intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.CheckCompleted',
                  defaultMessage: '检查完成',
                })
              : intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.Checking',
                  defaultMessage: '检查中',
                })
            : intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.CheckFailed',
                defaultMessage: '检查失败',
              })
R
Rongfeng Fu 已提交
464 465 466 467 468
        }
        gutter={16}
        className="card-padding-bottom-24"
      >
        <ProCard
R
Rongfeng Fu 已提交
469 470 471 472 473 474 475
          title={intl.formatMessage(
            {
              id: 'OBD.pages.components.PreCheckStatus.CheckItemCheckitemlength',
              defaultMessage: '检查项 {checkItemLength}',
            },
            { checkItemLength: checkItemLength },
          )}
R
Rongfeng Fu 已提交
476 477 478 479 480 481 482 483 484 485 486
          colSpan={12}
          className={`${styles.preCheckSubCard} card-padding-bottom-24 `}
          extra={
            <Button
              className={styles.preCheckBtn}
              disabled={
                checkStatus &&
                (!checkFinished || createLoading || preCheckLoading)
              }
              onClick={() => handleRetryCheck()}
              data-aspm-click="c307513.d317293"
R
Rongfeng Fu 已提交
487 488 489 490
              data-aspm-desc={intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.PreCheckResultReCheck',
                defaultMessage: '预检查结果-重新检查',
              })}
R
Rongfeng Fu 已提交
491 492 493
              data-aspm-param={``}
              data-aspm-expo
            >
R
Rongfeng Fu 已提交
494 495 496 497
              {intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.ReCheck',
                defaultMessage: '重新检查',
              })}
R
Rongfeng Fu 已提交
498 499 500 501 502 503 504 505
            </Button>
          }
          headStyle={{ paddingLeft: '16px', paddingRight: '16px' }}
        >
          <Spin
            spinning={loading}
            style={{ width: 400, lineHeight: '300px' }}
          />
R
Rongfeng Fu 已提交
506

R
Rongfeng Fu 已提交
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
          {loading ? null : (
            <>
              <Progress
                className={styles.preCheckProgress}
                percent={
                  statusData?.finished
                    ? NP.times(
                        NP.divide(statusData?.finished, statusData?.total),
                        100,
                      )
                    : 0
                }
                status={checkStatus ? progressStatus : 'exception'}
                showInfo={false}
              />
              <Timeline
                className={styles.timelineContainer}
                id="timeline-container"
              >
                {statusData?.info?.map(
                  (item: API.PreCheckInfo, index: number) => (
                    <Timeline.Item
                      id={`${
                        (statusData?.info[index - 1]?.status === 'FINISHED' &&
                          item.status === 'PENDING') ||
                        (statusData?.all_passed &&
                          index === statusData?.info.length - 1)
                          ? 'running-timeline-item'
                          : ''
                      }`}
                      color={
                        statusColorConfig[
                          item.status === 'FINISHED' ? item.result : item.status
                        ]
                      }
                      dot={
                        item?.result ? (
                          item?.result === 'FAILED' ? (
                            <CloseCircleFilled style={{ fontSize: 10 }} />
                          ) : (
                            <CheckCircleFilled style={{ fontSize: 10 }} />
                          )
                        ) : null
                      }
                    >
                      {item?.name} {item?.server}
                    </Timeline.Item>
                  ),
                )}
              </Timeline>
            </>
          )}
        </ProCard>
        <ProCard
R
Rongfeng Fu 已提交
561 562 563 564 565 566 567
          title={intl.formatMessage(
            {
              id: 'OBD.pages.components.PreCheckStatus.FailedItemFaileditemlength',
              defaultMessage: '失败项 {failedItemLength}',
            },
            { failedItemLength: failedItemLength },
          )}
R
Rongfeng Fu 已提交
568 569 570 571 572 573 574 575 576 577 578 579
          split="horizontal"
          colSpan={12}
          className={styles.preCheckSubCard}
          headerBordered
          headStyle={{ paddingLeft: '16px', paddingRight: '16px' }}
          extra={
            <Space size={4}>
              {hasManual ? (
                <Checkbox
                  onChange={(e) => setOnlyManual(e.target.checked)}
                  disabled={!checkFinished || statusData?.all_passed}
                >
R
Rongfeng Fu 已提交
580 581 582 583
                  {intl.formatMessage({
                    id: 'OBD.pages.components.PreCheckStatus.OnlyManualFixes',
                    defaultMessage: '只看手动修复项',
                  })}
R
Rongfeng Fu 已提交
584 585 586 587 588 589 590 591 592
                </Checkbox>
              ) : null}
              <Button
                className={styles.preCheckBtn}
                type="primary"
                disabled={!checkFinished || !hasAuto}
                onClick={handleAutoRepair}
                loading={recoverLoading}
                data-aspm-click="c307513.d317292"
R
Rongfeng Fu 已提交
593 594 595 596
                data-aspm-desc={intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.PreCheckResultAutomaticRepair',
                  defaultMessage: '预检查结果-自动修复',
                })}
R
Rongfeng Fu 已提交
597 598 599
                data-aspm-param={``}
                data-aspm-expo
              >
R
Rongfeng Fu 已提交
600 601 602 603
                {intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.AutomaticRepair',
                  defaultMessage: '自动修复',
                })}
R
Rongfeng Fu 已提交
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
              </Button>
            </Space>
          }
        >
          {showFailedList?.length ? (
            <div className={styles.failedContainer} id="failed-container">
              {showFailedList?.map((item, index) => {
                let reason = '';
                if (item?.description) {
                  const index = item?.description.indexOf(':');
                  reason = item?.description.substring(
                    index,
                    item?.description.length,
                  );
                }
                return (
                  <Space
                    className={`${styles.spaceWidth} ${styles.failedItem}`}
                    size={4}
                    direction="vertical"
                    key={`${item.name}_${index}`}
                  >
R
Rongfeng Fu 已提交
626
                    <Text style={{ verticalAlign: 'top' }}>
R
Rongfeng Fu 已提交
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642
                      <span
                        className={`${styles.iconContainer} ${styles.failedItemIcon} error-color mr-10 `}
                      >
                        <CloseOutlined className={styles.icon} />
                      </span>
                      {item.name}
                    </Text>
                    <Tooltip
                      title={item.description}
                      overlayClassName="list-tooltip"
                    >
                      <Text ellipsis>
                        <QuestionCircleFilled
                          className={`${styles.failedItemIcon} mr-10`}
                          style={{ color: '#8592ad', fontSize: '10px' }}
                        />
R
Rongfeng Fu 已提交
643 644 645 646
                        {intl.formatMessage({
                          id: 'OBD.pages.components.PreCheckStatus.Reason',
                          defaultMessage: '原因:',
                        })}
R
Rongfeng Fu 已提交
647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
                        <a href={errCodeUrl} target="_blank">
                          OBD-{item.code}
                        </a>{' '}
                        {reason}
                      </Text>
                    </Tooltip>
                    <Tooltip
                      title={item.advisement?.description}
                      overlayClassName="list-tooltip"
                    >
                      <Text ellipsis>
                        <ReadFilled
                          className={`${styles.failedItemIcon} mr-10`}
                          style={{ color: '#8592ad', fontSize: '10px' }}
                        />
R
Rongfeng Fu 已提交
662 663 664 665
                        {intl.formatMessage({
                          id: 'OBD.pages.components.PreCheckStatus.Suggestions',
                          defaultMessage: '建议:',
                        })}
R
Rongfeng Fu 已提交
666
                        {item.recoverable ? (
R
Rongfeng Fu 已提交
667 668 669 670 671 672
                          <Tag className="green-tag">
                            {intl.formatMessage({
                              id: 'OBD.pages.components.PreCheckStatus.AutomaticRepair',
                              defaultMessage: '自动修复',
                            })}
                          </Tag>
R
Rongfeng Fu 已提交
673
                        ) : (
R
Rongfeng Fu 已提交
674 675 676 677 678 679
                          <Tag className="default-tag">
                            {intl.formatMessage({
                              id: 'OBD.pages.components.PreCheckStatus.ManualRepair',
                              defaultMessage: '手动修复',
                            })}
                          </Tag>
R
Rongfeng Fu 已提交
680 681 682 683 684
                        )}{' '}
                        {item.advisement?.description}
                      </Text>
                      <br />
                      <a
R
Rongfeng Fu 已提交
685
                        className={styles.preCheckLearnMore}
R
Rongfeng Fu 已提交
686 687 688
                        href={errCodeUrl}
                        target="_blank"
                      >
R
Rongfeng Fu 已提交
689 690 691 692
                        {intl.formatMessage({
                          id: 'OBD.pages.components.PreCheckStatus.LearnMore',
                          defaultMessage: '了解更多方案',
                        })}
R
Rongfeng Fu 已提交
693 694 695 696 697 698 699 700 701 702 703 704 705 706
                      </a>
                    </Tooltip>
                  </Space>
                );
              })}
              {!checkFinished ? (
                <div style={{ marginLeft: 15 }}>{shape}</div>
              ) : null}
            </div>
          ) : checkFinished ? (
            <Empty
              image="/assets/empty.png"
              style={{ marginTop: '100px' }}
              description={
R
Rongfeng Fu 已提交
707 708 709 710 711 712
                <span style={{ color: '#8592ad' }}>
                  {intl.formatMessage({
                    id: 'OBD.pages.components.PreCheckStatus.GreatNoFailedItems',
                    defaultMessage: '太棒了!无失败项',
                  })}
                </span>
R
Rongfeng Fu 已提交
713 714 715 716 717 718
              }
            />
          ) : (
            <div className={styles.preLoading}>
              {shape}
              <div className={styles.desc} style={{ color: '#8592ad' }}>
R
Rongfeng Fu 已提交
719 720 721 722
                {intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.NoFailedItemsFoundYet',
                  defaultMessage: '暂未发现失败项',
                })}
R
Rongfeng Fu 已提交
723 724 725 726 727 728 729 730 731 732 733 734 735 736 737
              </div>
            </div>
          )}
        </ProCard>
      </ProCard>
      <footer className={styles.pageFooterContainer}>
        <div className={styles.pageFooter}>
          <Space className={styles.foolterAction}>
            <Button
              onClick={() => handleQuit(handleQuitProgress, setCurrentStep)}
              disabled={
                checkStatus &&
                (!checkFinished || recoverLoading || createLoading)
              }
              data-aspm-click="c307513.d317294"
R
Rongfeng Fu 已提交
738 739 740 741
              data-aspm-desc={intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.PreCheckResultExit',
                defaultMessage: '预检查结果-退出',
              })}
R
Rongfeng Fu 已提交
742 743 744
              data-aspm-param={``}
              data-aspm-expo
            >
R
Rongfeng Fu 已提交
745 746 747 748
              {intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.Exit',
                defaultMessage: '退出',
              })}
R
Rongfeng Fu 已提交
749 750 751 752 753
            </Button>
            <Button
              onClick={prevStep}
              disabled={checkStatus && !checkFinished}
              data-aspm-click="c307513.d317291"
R
Rongfeng Fu 已提交
754 755 756 757
              data-aspm-desc={intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.PreCheckResultsPreviousStep',
                defaultMessage: '预检查结果-上一步',
              })}
R
Rongfeng Fu 已提交
758 759 760
              data-aspm-param={``}
              data-aspm-expo
            >
R
Rongfeng Fu 已提交
761 762 763 764
              {intl.formatMessage({
                id: 'OBD.pages.components.PreCheckStatus.PreviousStep',
                defaultMessage: '上一步',
              })}
R
Rongfeng Fu 已提交
765 766
            </Button>
            {!statusData?.all_passed ? (
R
Rongfeng Fu 已提交
767 768 769 770 771 772
              <Tooltip
                title={intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.FixAllFailedItems',
                  defaultMessage: '请修复全部失败项',
                })}
              >
R
Rongfeng Fu 已提交
773 774 775 776
                <Button
                  type="primary"
                  disabled={true}
                  data-aspm-click="c307510.d317287"
R
Rongfeng Fu 已提交
777 778 779 780
                  data-aspm-desc={intl.formatMessage({
                    id: 'OBD.pages.components.PreCheckStatus.PreCheckFailedDeploymentGreyed',
                    defaultMessage: '预检查失败-部署置灰',
                  })}
R
Rongfeng Fu 已提交
781 782 783
                  data-aspm-param={``}
                  data-aspm-expo
                >
R
Rongfeng Fu 已提交
784 785 786 787
                  {intl.formatMessage({
                    id: 'OBD.pages.components.PreCheckStatus.Deployment',
                    defaultMessage: '部署',
                  })}
R
Rongfeng Fu 已提交
788 789 790 791 792 793 794
                </Button>
              </Tooltip>
            ) : (
              <Button
                type="primary"
                onClick={handleInstall}
                data-aspm-click="c307503.d317272"
R
Rongfeng Fu 已提交
795 796 797 798
                data-aspm-desc={intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.PreCheckSuccessfulDeployment',
                  defaultMessage: '预检查成功-部署',
                })}
R
Rongfeng Fu 已提交
799 800 801
                data-aspm-param={``}
                data-aspm-expo
              >
R
Rongfeng Fu 已提交
802 803 804 805
                {intl.formatMessage({
                  id: 'OBD.pages.components.PreCheckStatus.Deployment',
                  defaultMessage: '部署',
                })}
R
Rongfeng Fu 已提交
806 807 808 809 810 811 812 813
              </Button>
            )}
          </Space>
        </div>
      </footer>
    </Space>
  );
}