mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 08:33:20 +00:00
refactor: upload
This commit is contained in:
@@ -2,10 +2,15 @@ import React, { useEffect, useRef } from 'react';
|
|||||||
import { WrapperModalProps } from './types';
|
import { WrapperModalProps } from './types';
|
||||||
import Exit from '../assets/exit.svg';
|
import Exit from '../assets/exit.svg';
|
||||||
|
|
||||||
const WrapperModal: React.FC<WrapperModalProps> = ({ children, close }) => {
|
const WrapperModal: React.FC<WrapperModalProps> = ({
|
||||||
|
children,
|
||||||
|
close,
|
||||||
|
isPerformingTask,
|
||||||
|
}) => {
|
||||||
const modalRef = useRef<HTMLDivElement>(null);
|
const modalRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (isPerformingTask) return;
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
if (
|
if (
|
||||||
modalRef.current &&
|
modalRef.current &&
|
||||||
@@ -36,9 +41,11 @@ const WrapperModal: React.FC<WrapperModalProps> = ({ children, close }) => {
|
|||||||
ref={modalRef}
|
ref={modalRef}
|
||||||
className="relative w-11/12 rounded-2xl bg-white p-10 dark:bg-outer-space sm:w-[512px]"
|
className="relative w-11/12 rounded-2xl bg-white p-10 dark:bg-outer-space sm:w-[512px]"
|
||||||
>
|
>
|
||||||
<button className="absolute top-3 right-4 m-2 w-3" onClick={close}>
|
{!isPerformingTask && (
|
||||||
<img className="filter dark:invert" src={Exit} />
|
<button className="absolute top-3 right-4 m-2 w-3" onClick={close}>
|
||||||
</button>
|
<img className="filter dark:invert" src={Exit} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export type WrapperModalProps = {
|
export type WrapperModalProps = {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
|
isPerformingTask?: boolean;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -600,7 +600,30 @@ function Upload({
|
|||||||
) : (
|
) : (
|
||||||
<button
|
<button
|
||||||
onClick={uploadRemote}
|
onClick={uploadRemote}
|
||||||
className={`ml-2 cursor-pointer rounded-3xl bg-purple-30 py-2 px-6 text-sm text-white hover:bg-[#6F3FD1]`}
|
className={`ml-2 cursor-pointer rounded-3xl bg-purple-30 py-2 px-6 text-sm text-white hover:bg-[#6F3FD1] ${
|
||||||
|
urlName.trim().length === 0 ||
|
||||||
|
url.trim().length === 0 ||
|
||||||
|
(urlType.label === 'Reddit' &&
|
||||||
|
(redditData.client_id.length === 0 ||
|
||||||
|
redditData.client_secret.length === 0 ||
|
||||||
|
redditData.user_agent.length === 0 ||
|
||||||
|
redditData.search_queries.length === 0 ||
|
||||||
|
redditData.number_posts === 0)) ||
|
||||||
|
(urlType.label === 'GitHub' && repoUrl.trim().length === 0)
|
||||||
|
? 'bg-opacity-80 text-opacity-80'
|
||||||
|
: ''
|
||||||
|
}`}
|
||||||
|
disabled={
|
||||||
|
urlName.trim().length === 0 ||
|
||||||
|
url.trim().length === 0 ||
|
||||||
|
(urlType.label === 'Reddit' &&
|
||||||
|
(redditData.client_id.length === 0 ||
|
||||||
|
redditData.client_secret.length === 0 ||
|
||||||
|
redditData.user_agent.length === 0 ||
|
||||||
|
redditData.search_queries.length === 0 ||
|
||||||
|
redditData.number_posts === 0)) ||
|
||||||
|
(urlType.label === 'GitHub' && repoUrl.trim().length === 0)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{t('modals.uploadDoc.train')}
|
{t('modals.uploadDoc.train')}
|
||||||
</button>
|
</button>
|
||||||
@@ -627,6 +650,7 @@ function Upload({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<WrapperModal
|
<WrapperModal
|
||||||
|
isPerformingTask={progress !== undefined && progress.percentage < 100}
|
||||||
close={() => {
|
close={() => {
|
||||||
close();
|
close();
|
||||||
setDocName('');
|
setDocName('');
|
||||||
|
|||||||
Reference in New Issue
Block a user