diff --git a/src/@utils/yup.ts b/src/@utils/yup.ts index 95d4fbcb5..1e0f7f994 100644 --- a/src/@utils/yup.ts +++ b/src/@utils/yup.ts @@ -2,23 +2,36 @@ import { isCID } from '@utils/ipfs' import isUrl from 'is-url-superb' import * as Yup from 'yup' -export function testLinks() { +export function testLinks(isEdit?: boolean) { return Yup.string().test((value, context) => { const { type } = context.parent let validField let errorMessage switch (type) { + // we allow submit if the type input is hidden as will be ignore + case 'hidden': + validField = true + break case 'url': validField = isUrl(value?.toString() || '') + // if we're in publish, the field must be valid if (!validField) { + validField = false errorMessage = 'Must be a valid url.' - } else { - if (value?.toString().includes('drive.google')) { - validField = false - errorMessage = - 'Google Drive is not a supported hosting service. Please use an alternative.' - } + } + // we allow submit if we're in the edit page and the field is empty + if ( + (!value?.toString() && isEdit) || + (!value?.toString() && context.path === 'services[0].links[0].url') + ) { + validField = true + } + // if the url has google drive, we need to block the user from submit + if (value?.toString().includes('drive.google')) { + validField = false + errorMessage = + 'Google Drive is not a supported hosting service. Please use an alternative.' } break case 'ipfs': diff --git a/src/components/@shared/atoms/TabsFile/index.module.css b/src/components/@shared/atoms/TabsFile/index.module.css index 0920eb964..8c2fa8a6d 100644 --- a/src/components/@shared/atoms/TabsFile/index.module.css +++ b/src/components/@shared/atoms/TabsFile/index.module.css @@ -25,6 +25,10 @@ border: 0; } +.tabHidden { + display: none !important; +} + .tab, .tab label { cursor: pointer; @@ -61,13 +65,13 @@ border-top: 0; } -.tabLabel{ +.tabLabel { color: var(--font-color-text); - font-size: var(--font-size-small); - font-family: var(--font-family-heading); - line-height: 1.2; - display: block; - margin-bottom: calc(var(--spacer) / 2); + font-size: var(--font-size-small); + font-family: var(--font-family-heading); + line-height: 1.2; + display: block; + margin-bottom: calc(var(--spacer) / 2); } @media (min-width: 40rem) { diff --git a/src/components/@shared/atoms/TabsFile/index.tsx b/src/components/@shared/atoms/TabsFile/index.tsx index 3662d3b82..06642abb8 100644 --- a/src/components/@shared/atoms/TabsFile/index.tsx +++ b/src/components/@shared/atoms/TabsFile/index.tsx @@ -55,11 +55,11 @@ export default function TabsFile({