From 7fc5418189af104f1888aff883bcc56ab69f1847 Mon Sep 17 00:00:00 2001 From: EnzoVezzaro Date: Wed, 2 Nov 2022 06:32:35 -0400 Subject: [PATCH] block validation link when hosting is on g drive --- .../@shared/FormFields/FilesInput/index.tsx | 10 +++++++++- src/components/Asset/Edit/FormEditMetadata.tsx | 11 ++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/@shared/FormFields/FilesInput/index.tsx b/src/components/@shared/FormFields/FilesInput/index.tsx index 8d69164e6..983f1c756 100644 --- a/src/components/@shared/FormFields/FilesInput/index.tsx +++ b/src/components/@shared/FormFields/FilesInput/index.tsx @@ -1,4 +1,4 @@ -import React, { ReactElement, useState } from 'react' +import React, { ReactElement, useEffect, useState } from 'react' import { useField, useFormikContext } from 'formik' import FileInfo from './Info' import UrlInput from '../URLInput' @@ -23,6 +23,14 @@ export default function FilesInput(props: InputProps): ReactElement { ? values?.services[0].providerUrl.url : asset.services[0].serviceEndpoint setIsLoading(true) + + // TODO: handled on provider + if (url.includes('drive.google')) { + throw Error( + 'Google Drive is not a supported hosting service. Please use an alternative.' + ) + } + const checkedFile = await getFileUrlInfo(url, providerUrl) // error if something's not right from response diff --git a/src/components/Asset/Edit/FormEditMetadata.tsx b/src/components/Asset/Edit/FormEditMetadata.tsx index 6809a125f..91f947b03 100644 --- a/src/components/Asset/Edit/FormEditMetadata.tsx +++ b/src/components/Asset/Edit/FormEditMetadata.tsx @@ -60,7 +60,16 @@ export default function FormEditMetadata({ asset?.metadata?.links?.[0] && getFileUrlInfo(asset.metadata.links[0], providerUrl).then( (checkedFile) => { - console.log(checkedFile) + // set valid false if url is using google drive + if (asset.metadata.links[0].includes('drive.google')) { + setFieldValue('links', [ + { + url: asset.metadata.links[0], + valid: false + } + ]) + return + } // initiate link with values from asset metadata setFieldValue('links', [ {