From 314cafce8871b379d3fd78428500f9c8c666dfa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E9=9B=BE=E4=B8=89=E8=AF=AD?= <32354856+baiwusanyu-c@users.noreply.github.com> Date: Tue, 11 Apr 2023 21:54:25 +0800 Subject: [PATCH] fix: model theme fail --- .../chrome-option/components/Pr-List.tsx | 28 +++++++++---------- packages/extension/chrome-option/main.tsx | 10 ++++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/packages/extension/chrome-option/components/Pr-List.tsx b/packages/extension/chrome-option/components/Pr-List.tsx index 815f8f3..6f05b4c 100644 --- a/packages/extension/chrome-option/components/Pr-List.tsx +++ b/packages/extension/chrome-option/components/Pr-List.tsx @@ -1,5 +1,5 @@ import { useThrottleFn } from 'ahooks' -import { Button, Input, Modal, Space, Table, Tag, Tooltip, message } from 'antd' +import { App, Button, Input, Space, Table, Tag, Tooltip } from 'antd' import { ExclamationCircleFilled } from '@ant-design/icons' import { useEffect, useRef, useState } from 'react' import { createRunList } from '@pr-checker/utils/common' @@ -7,7 +7,6 @@ import { compareBranch, getPRDetail, rebasePr } from '@pr-checker/fetchGit' import type React from 'react' import type { IRepoWithPRs } from './Repo-List' import type { ColumnsType } from 'antd/es/table' - interface PrListProps { opType: string repoInfo: IRepoWithPRs @@ -28,9 +27,8 @@ interface DataType { // TODO merge // TODO merge all select handle -// TODO rebase all select handle - // TODO refactor +// TODO: rerender fail ? export const PrList = (props: PrListProps) => { const [tableData, settableData] = useState([]) const tableDataCache = useRef([]) @@ -38,9 +36,8 @@ export const PrList = (props: PrListProps) => { useEffect(() => { if (props.repoInfo.pullRequests.length > 0) { setLoading(true) - if(props.opType === 'rebase'){ + if (props.opType === 'rebase') handleTableData(props.repoInfo.pullRequests) - } } }, [props.repoInfo, props.opType]) @@ -101,8 +98,8 @@ export const PrList = (props: PrListProps) => { { wait: 300 }, ) - const { confirm } = Modal - const [messageApi, contextHolder] = message.useMessage() + const { modal, message } = App.useApp() + const { confirm } = modal const handleOp = async(item: DataType) => { confirm({ title: 'Tips', @@ -117,9 +114,11 @@ export const PrList = (props: PrListProps) => { return new Promise((resolve) => { const run = async() => { if (props.opType === 'rebase') { - const res = await rebasePrList(props.token, item.repoName, [item.number]) - resolve(res) + window.alert('a') + //await rebasePrList(props.token, item.repoName, [item.number]) + setLoading(true) handleTableData(props.repoInfo.pullRequests) + resolve(true) } } run() @@ -133,7 +132,7 @@ export const PrList = (props: PrListProps) => { await Promise.all(createRunList(numberArr.length, async(i: number) => { await rebasePr(token, repoName, numberArr[i]) })) - messageApi.open({ + message.open({ type: 'success', content: 'rebase success', }) @@ -153,7 +152,7 @@ export const PrList = (props: PrListProps) => { const handleOpAll = async() => { if (selectedNumberData.length === 0) { - messageApi.open({ + message.open({ type: 'warning', content: 'Select the row you want to work on', }) @@ -171,10 +170,10 @@ export const PrList = (props: PrListProps) => { return new Promise((resolve) => { const run = async() => { if (props.opType === 'rebase') { - const res = await rebasePrList(props.token, props.repoInfo.uname, selectedNumberData) - resolve(res) + //await rebasePrList(props.token, props.repoInfo.uname, selectedNumberData) setLoading(true) handleTableData(props.repoInfo.pullRequests) + resolve(true) } } run() @@ -285,7 +284,6 @@ export const PrList = (props: PrListProps) => { scroll={{ y: 'calc(100vh - 200px)' }} pagination={false} /> - {contextHolder} ) } diff --git a/packages/extension/chrome-option/main.tsx b/packages/extension/chrome-option/main.tsx index b7eeb58..60f2ad6 100644 --- a/packages/extension/chrome-option/main.tsx +++ b/packages/extension/chrome-option/main.tsx @@ -5,7 +5,7 @@ import store from '../store' import { OptionPage } from './view/OptionPage' import 'antd/dist/reset.css' import 'uno.css' - +import { App } from 'antd'; ReactDOM.createRoot(document.getElementById('app') as HTMLElement).render( - - - + + + + + , )