From 00a6d7af63435a9bdf89e397bbb59ed8a34c59cb Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 14:35:29 +0300 Subject: [PATCH 1/7] update the file info UI after URL re-add --- .vscode/launch.json | 15 +++++++++ .../molecules/FormFields/FilesInput/index.tsx | 32 ++++++++++++------- 2 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..c319bb15e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8000", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/src/components/molecules/FormFields/FilesInput/index.tsx b/src/components/molecules/FormFields/FilesInput/index.tsx index b99d2a40b..f779b76c5 100644 --- a/src/components/molecules/FormFields/FilesInput/index.tsx +++ b/src/components/molecules/FormFields/FilesInput/index.tsx @@ -15,6 +15,26 @@ export default function FilesInput(props: InputProps): ReactElement { const { config } = useOcean() useEffect(() => { + loadFileInfo() + }, [fileUrl, config.providerUri]) + + async function handleButtonClick(e: React.SyntheticEvent, url: string) { + // hack so the onBlur-triggered validation does not show, + // like when this field is required + helpers.setTouched(false) + + // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' + e.preventDefault() + + // In the case when the user re-add the same URL after it was removed (by accident or intentionally) + if (fileUrl === url) { + loadFileInfo() + } + + setFileUrl(url) + } + + function loadFileInfo() { const source = axios.CancelToken.source() async function validateUrl() { @@ -33,22 +53,12 @@ export default function FilesInput(props: InputProps): ReactElement { setIsLoading(false) } } + fileUrl && validateUrl() return () => { source.cancel() } - }, [fileUrl, config.providerUri]) - - async function handleButtonClick(e: React.SyntheticEvent, url: string) { - // hack so the onBlur-triggered validation does not show, - // like when this field is required - helpers.setTouched(false) - - // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() - - setFileUrl(url) } return ( From f506758bfecc180d7f1c9cb8046a4fd8db328a54 Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 15:07:25 +0300 Subject: [PATCH 2/7] change function position --- .../molecules/FormFields/FilesInput/index.tsx | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/molecules/FormFields/FilesInput/index.tsx b/src/components/molecules/FormFields/FilesInput/index.tsx index f779b76c5..e4ab3d84c 100644 --- a/src/components/molecules/FormFields/FilesInput/index.tsx +++ b/src/components/molecules/FormFields/FilesInput/index.tsx @@ -14,26 +14,6 @@ export default function FilesInput(props: InputProps): ReactElement { const [fileUrl, setFileUrl] = useState() const { config } = useOcean() - useEffect(() => { - loadFileInfo() - }, [fileUrl, config.providerUri]) - - async function handleButtonClick(e: React.SyntheticEvent, url: string) { - // hack so the onBlur-triggered validation does not show, - // like when this field is required - helpers.setTouched(false) - - // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() - - // In the case when the user re-add the same URL after it was removed (by accident or intentionally) - if (fileUrl === url) { - loadFileInfo() - } - - setFileUrl(url) - } - function loadFileInfo() { const source = axios.CancelToken.source() @@ -61,6 +41,26 @@ export default function FilesInput(props: InputProps): ReactElement { } } + useEffect(() => { + loadFileInfo() + }, [fileUrl, config.providerUri]) + + async function handleButtonClick(e: React.SyntheticEvent, url: string) { + // hack so the onBlur-triggered validation does not show, + // like when this field is required + helpers.setTouched(false) + + // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' + e.preventDefault() + + // In the case when the user re-add the same URL after it was removed (by accident or intentionally) + if (fileUrl === url) { + loadFileInfo() + } + + setFileUrl(url) + } + return ( <> {field?.value && field.value[0] && typeof field.value === 'object' ? ( From 9ecfcda20e1b3d6281776da5d79b4fc0b000ea2c Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 17:33:34 +0300 Subject: [PATCH 3/7] removed launch.json --- .vscode/launch.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c319bb15e..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "pwa-chrome", - "request": "launch", - "name": "Launch Chrome against localhost", - "url": "http://localhost:8000", - "webRoot": "${workspaceFolder}" - } - ] -} From 16254fd59b057b18b54aa322e4c9075975fe6016 Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 14:35:29 +0300 Subject: [PATCH 4/7] update the file info UI after URL re-add --- .vscode/launch.json | 15 +++++++++ .../molecules/FormFields/FilesInput/index.tsx | 32 ++++++++++++------- 2 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..c319bb15e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:8000", + "webRoot": "${workspaceFolder}" + } + ] +} diff --git a/src/components/molecules/FormFields/FilesInput/index.tsx b/src/components/molecules/FormFields/FilesInput/index.tsx index b99d2a40b..f779b76c5 100644 --- a/src/components/molecules/FormFields/FilesInput/index.tsx +++ b/src/components/molecules/FormFields/FilesInput/index.tsx @@ -15,6 +15,26 @@ export default function FilesInput(props: InputProps): ReactElement { const { config } = useOcean() useEffect(() => { + loadFileInfo() + }, [fileUrl, config.providerUri]) + + async function handleButtonClick(e: React.SyntheticEvent, url: string) { + // hack so the onBlur-triggered validation does not show, + // like when this field is required + helpers.setTouched(false) + + // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' + e.preventDefault() + + // In the case when the user re-add the same URL after it was removed (by accident or intentionally) + if (fileUrl === url) { + loadFileInfo() + } + + setFileUrl(url) + } + + function loadFileInfo() { const source = axios.CancelToken.source() async function validateUrl() { @@ -33,22 +53,12 @@ export default function FilesInput(props: InputProps): ReactElement { setIsLoading(false) } } + fileUrl && validateUrl() return () => { source.cancel() } - }, [fileUrl, config.providerUri]) - - async function handleButtonClick(e: React.SyntheticEvent, url: string) { - // hack so the onBlur-triggered validation does not show, - // like when this field is required - helpers.setTouched(false) - - // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() - - setFileUrl(url) } return ( From ab6578e982718b8e1d1cdd8763510ea9f445e859 Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 15:07:25 +0300 Subject: [PATCH 5/7] change function position --- .../molecules/FormFields/FilesInput/index.tsx | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/molecules/FormFields/FilesInput/index.tsx b/src/components/molecules/FormFields/FilesInput/index.tsx index f779b76c5..e4ab3d84c 100644 --- a/src/components/molecules/FormFields/FilesInput/index.tsx +++ b/src/components/molecules/FormFields/FilesInput/index.tsx @@ -14,26 +14,6 @@ export default function FilesInput(props: InputProps): ReactElement { const [fileUrl, setFileUrl] = useState() const { config } = useOcean() - useEffect(() => { - loadFileInfo() - }, [fileUrl, config.providerUri]) - - async function handleButtonClick(e: React.SyntheticEvent, url: string) { - // hack so the onBlur-triggered validation does not show, - // like when this field is required - helpers.setTouched(false) - - // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' - e.preventDefault() - - // In the case when the user re-add the same URL after it was removed (by accident or intentionally) - if (fileUrl === url) { - loadFileInfo() - } - - setFileUrl(url) - } - function loadFileInfo() { const source = axios.CancelToken.source() @@ -61,6 +41,26 @@ export default function FilesInput(props: InputProps): ReactElement { } } + useEffect(() => { + loadFileInfo() + }, [fileUrl, config.providerUri]) + + async function handleButtonClick(e: React.SyntheticEvent, url: string) { + // hack so the onBlur-triggered validation does not show, + // like when this field is required + helpers.setTouched(false) + + // File example 'https://oceanprotocol.com/tech-whitepaper.pdf' + e.preventDefault() + + // In the case when the user re-add the same URL after it was removed (by accident or intentionally) + if (fileUrl === url) { + loadFileInfo() + } + + setFileUrl(url) + } + return ( <> {field?.value && field.value[0] && typeof field.value === 'object' ? ( From add32088141d8d7296c9b8c64e21388abff43cc0 Mon Sep 17 00:00:00 2001 From: Dimo Dzhurenov Date: Thu, 15 Apr 2021 17:33:34 +0300 Subject: [PATCH 6/7] removed launch.json --- .vscode/launch.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index c319bb15e..000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "pwa-chrome", - "request": "launch", - "name": "Launch Chrome against localhost", - "url": "http://localhost:8000", - "webRoot": "${workspaceFolder}" - } - ] -} From a20d6d82f044c97d5262191d22ea7ddef3e4847a Mon Sep 17 00:00:00 2001 From: Jamie Hewitt Date: Wed, 21 Apr 2021 16:23:50 +0300 Subject: [PATCH 7/7] Fixing issue with Toast message appearing twice --- src/components/molecules/FormFields/FilesInput/Input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/molecules/FormFields/FilesInput/Input.tsx b/src/components/molecules/FormFields/FilesInput/Input.tsx index 7d4699b60..d676aafee 100644 --- a/src/components/molecules/FormFields/FilesInput/Input.tsx +++ b/src/components/molecules/FormFields/FilesInput/Input.tsx @@ -27,7 +27,7 @@ export default function FileInput({