diff --git a/configs/app/features/marketplace.ts b/configs/app/features/marketplace.ts index e831df7a6c..288c14a125 100644 --- a/configs/app/features/marketplace.ts +++ b/configs/app/features/marketplace.ts @@ -4,6 +4,7 @@ import chain from '../chain'; import { getEnvValue, getExternalAssetFilePath } from '../utils'; // config file will be downloaded at run-time and saved in the public folder +const enabled = getEnvValue('NEXT_PUBLIC_MARKETPLACE_ENABLED'); const configUrl = getExternalAssetFilePath('NEXT_PUBLIC_MARKETPLACE_CONFIG_URL'); const submitFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM'); const suggestIdeasFormUrl = getEnvValue('NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM'); @@ -17,7 +18,7 @@ const config: Feature<( { api: { endpoint: string; basePath: string } } ) & { submitFormUrl: string; categoriesUrl: string | undefined; suggestIdeasFormUrl: string | undefined } > = (() => { - if (chain.rpcUrl && submitFormUrl) { + if (enabled === 'true' && chain.rpcUrl && submitFormUrl) { if (configUrl) { return Object.freeze({ title, diff --git a/deploy/tools/envs-validator/schema.ts b/deploy/tools/envs-validator/schema.ts index 9d7273f983..a94dad2f2e 100644 --- a/deploy/tools/envs-validator/schema.ts +++ b/deploy/tools/envs-validator/schema.ts @@ -83,15 +83,27 @@ const marketplaceSchema = yup NEXT_PUBLIC_MARKETPLACE_CONFIG_URL: yup .array() .json() - .of(marketplaceAppSchema), + .of(marketplaceAppSchema) + .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { + is: true, + then: (schema) => schema, + // eslint-disable-next-line max-len + otherwise: (schema) => schema.max(1, 'NEXT_PUBLIC_MARKETPLACE_CONFIG_URL cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'), + }), NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL: yup .array() .json() - .of(yup.string()), + .of(yup.string()) + .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { + is: true, + then: (schema) => schema, + // eslint-disable-next-line max-len + otherwise: (schema) => schema.max(1, 'NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'), + }), NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM: yup .string() .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { - is: (enabled: boolean) => enabled, + is: true, then: (schema) => schema.test(urlTest).required(), // eslint-disable-next-line max-len otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'), @@ -99,7 +111,7 @@ const marketplaceSchema = yup NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM: yup .string() .when('NEXT_PUBLIC_MARKETPLACE_ENABLED', { - is: (enabled: boolean) => enabled, + is: true, then: (schema) => schema.test(urlTest), // eslint-disable-next-line max-len otherwise: (schema) => schema.max(-1, 'NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM cannot not be used without NEXT_PUBLIC_MARKETPLACE_ENABLED'),