From e5a841fcc3ff69078d93066472753716fea56766 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Thu, 22 Aug 2024 11:35:30 +0800 Subject: [PATCH] add repo clone err msg in lunar app --- lunar/src/components/RepoList.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lunar/src/components/RepoList.tsx b/lunar/src/components/RepoList.tsx index 58d48873f..cac071c1f 100644 --- a/lunar/src/components/RepoList.tsx +++ b/lunar/src/components/RepoList.tsx @@ -1,6 +1,6 @@ 'use client' -import { Input, Modal, Space, Table, TableProps, Badge, Button, Skeleton } from 'antd/lib' +import { Space, Table, TableProps, Badge, Button, Skeleton, message } from 'antd/lib' import { useState } from 'react' import { format, fromUnixTime } from 'date-fns' import { DownloadOutlined } from '@ant-design/icons'; @@ -19,9 +19,9 @@ interface DataType { } const DataList = ({ data }) => { + const [messageApi, contextHolder] = message.useMessage(); const { status, isLoading, isError } = useMegaStatus(); const [loadings, setLoadings] = useState([]); - const [modal, contextHolder] = Modal.useModal(); if (isLoading) return ; @@ -41,13 +41,21 @@ const DataList = ({ data }) => { }); } - const showSuccModel = (text) => { - modal.success({ - title: 'Fork from remote success! Clone by command:', - content: `${text}`, + const msg_error = () => { + messageApi.open({ + type: 'error', + content: 'Failed to clone repo', }); }; + const msg_success = () => { + messageApi.open({ + type: 'success', + content: 'Clone success', + }); + }; + + var columns: TableProps['columns'] = [ { title: 'Name', @@ -115,9 +123,13 @@ const DataList = ({ data }) => { console.log("repo fork result", res); if (res.req_result) { invoke('clone_repository', { repoUrl: res.data, name: record.name }) + .then(() => msg_success()) .catch((error) => { console.error(`Failed to get service status: ${error}`); + msg_error(); }); + } else { + msg_error(); } } catch (error) { console.error('Error fetching data:', error); @@ -147,7 +159,7 @@ const DataList = ({ data }) => { async function getRepoFork(identifier) { const res = await fetch(`${endpoint}/api/v1/mega/ztm/repo_fork?identifier=${identifier}`); const response = await res.json(); - return response.data + return response } export default DataList;